use of de.ids_mannheim.korap.query.SpanFocusQuery in project Krill by KorAP.
the class TestRelationIndex method testCase7.
/**
* Relation with specific sources, return any targets
*/
@Test
public void testCase7() throws IOException {
ki.addDoc(createFieldDoc2());
ki.commit();
// match all children that are NP
SpanElementQuery seq1 = new SpanElementQuery("base", "np");
SpanClassQuery scq1 = new SpanClassQuery(seq1, (byte) 1);
SpanRelationQuery srq = new SpanRelationQuery(new SpanTermQuery(new Term("base", ">:child-of")), true, RelationDirection.RIGHT);
srq.setTargetClass((byte) 2);
SpanRelationMatchQuery rm = new SpanRelationMatchQuery(srq, scq1, true);
// SpanQuery rv = new SpanFocusQuery(rm, (byte) 1);
// return all parents of np
SpanFocusQuery rv2 = new SpanFocusQuery(rm, (byte) 2);
rv2.setSorted(false);
assertEquals("focus(2: focus(#[1,2]spanSegment({2: target:spanRelation(base:>:child-of)}, {1: <base:np />})))", rv2.toString());
kr = ki.search(rv2, (short) 10);
assertEquals((long) 4, kr.getTotalResults());
assertEquals(0, kr.getMatch(0).getStartPos());
assertEquals(7, kr.getMatch(0).getEndPos());
assertEquals(1, kr.getMatch(1).getStartPos());
assertEquals(7, kr.getMatch(1).getEndPos());
assertEquals(2, kr.getMatch(2).getStartPos());
assertEquals(7, kr.getMatch(2).getEndPos());
assertEquals(4, kr.getMatch(3).getStartPos());
assertEquals(7, kr.getMatch(3).getEndPos());
// id problem (solved)
// return all parents of np that are PP
}
use of de.ids_mannheim.korap.query.SpanFocusQuery in project Krill by KorAP.
the class TestRelationIndex method testCase4.
/**
* Relations only with/out attribute
*/
@Test
public void testCase4() throws IOException {
ki.addDoc(createFieldDoc2());
ki.commit();
SpanRelationQuery srq = new SpanRelationQuery(new SpanTermQuery(new Term("base", ">:child-of")), true, RelationDirection.RIGHT);
SpanFocusQuery fq = new SpanFocusQuery(srq, srq.getTempClassNumbers());
fq.setMatchTemporaryClass(true);
fq.setRemoveTemporaryClasses(true);
fq.setSorted(false);
// kr = ki.search(fq, (short) 20);
// for (Match m : kr.getMatches()) {
// System.out.println(m.getStartPos() + " " + m.getEndPos());
// }
SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(new Term("base", "@:func=sbj")), true);
// kr = ki.search(saq, (short) 20);
// child-of with attr func=sbj
SpanWithAttributeQuery wq;
wq = new SpanWithAttributeQuery(fq, saq, true);
// kr = ki.search(wq, (short) 20);
// assertEquals((long) 1, kr.getTotalResults());
// assertEquals(0, kr.getMatch(0).getStartPos()); // token
// assertEquals(7, kr.getMatch(0).getEndPos());
// child-of without attr func=sbj
wq = new SpanWithAttributeQuery(fq, new SpanAttributeQuery(new SpanTermQuery(new Term("base", "@:func=sbj")), true, true), true);
kr = ki.search(wq, (short) 20);
assertEquals((long) 12, kr.getTotalResults());
}
Aggregations