use of de.ids_mannheim.korap.query.SpanElementQuery in project Krill by KorAP.
the class TestWithinIndex method indexExample2a.
@Test
public void indexExample2a() throws IOException {
KrillIndex ki = new KrillIndex();
// <a><a><a>h</a>hij</a>hij</a>
FieldDocument fd = new FieldDocument();
fd.addTV("base", // <a><a>hhij</a>hijh</a>ij</a>
"h h i j h i j h i j ", "[s:h|_0$<i>0<i>3|<>:a$<b>64<i>0<i>12<i>4<b>0|" + "<>:a$<b>64<i>0<i>24<i>8<b>0|" + // 1
"<>:a$<b>64<i>0<i>30<i>10<b>0]" + // 2
"[s:h|_1$<i>3<i>6]" + // 3
"[s:i|_2$<i>6<i>9]" + // 4
"[s:j|_3$<i>9<i>12]" + // 5
"[s:h|_4$<i>12<i>15]" + // 6
"[s:i|_5$<i>15<i>18]" + // 7
"[s:j|_6$<i>18<i>21]" + // 8
"[s:h|_7$<i>21<i>24]" + // 9
"[s:i|_8$<i>24<i>27]" + // 10
"[s:j|_9$<i>27<i>30]");
ki.addDoc(fd);
// Save documents
ki.commit();
assertEquals(1, ki.numberOf("documents"));
SpanQuery sq;
Result kr;
sq = new SpanElementQuery("base", "a");
kr = ki.search(sq, (short) 10);
assertEquals("totalResults", kr.getTotalResults(), 3);
assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 8, kr.getMatch(1).endPos);
assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
assertEquals("EndPos (2)", 10, kr.getMatch(2).endPos);
}
use of de.ids_mannheim.korap.query.SpanElementQuery in project Krill by KorAP.
the class TestSpanWithinQuery method spanSegmentStartsWithQuery.
@Test
public void spanSegmentStartsWithQuery() throws QueryException {
SpanSequenceQueryWrapper ssquery = new SpanSequenceQueryWrapper("field", "a", "b", "c");
SpanWithinQuery ssequery = new SpanWithinQuery(new SpanElementQuery("field", "s"), ssquery.toQuery(), SpanWithinQuery.STARTSWITH, true);
assertEquals("spanStartsWith(<field:s />, spanNext(spanNext(field:a, field:b), field:c))", ssequery.toString());
}
Aggregations