use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestWithinIndex method indexExample5.
@Test
public void indexExample5() throws IOException {
// 1,2,3,6,9,10,12
KrillIndex ki = new KrillIndex();
// hij<a>hi<a>h<a>ij</a></a>hi</a>
FieldDocument fd = new FieldDocument();
fd.addTV("base", "hijhihijhi", "[(0-1)s:h|i:h|_0$<i>0<i>1|-:a$<i>3|-:t$<i>10]" + "[(1-2)s:i|i:i|_1$<i>1<i>2]" + "[(2-3)s:j|i:j|_2$<i>2<i>3]" + "[(3-4)s:h|i:h|_3$<i>3<i>4|<>:a$<b>64<i>3<i>10<i>10<b>0]" + "[(4-5)s:i|i:i|_4$<i>4<i>5]" + "[(5-6)s:h|i:h|_5$<i>5<i>6|<>:a$<b>64<i>5<i>8<i>8<b>0]" + "[(6-7)s:i|i:i|_6$<i>6<i>7|<>:a$<b>64<i>6<i>8<i>8<b>0]" + "[(7-8)s:j|i:j|_7$<i>7<i>8]" + "[(8-9)s:h|i:h|_8$<i>8<i>9]" + "[(9-10)s:i|i:i|_9$<i>9<i>10]");
ki.addDoc(fd);
// Save documents
ki.commit();
assertEquals(1, ki.numberOf("documents"));
SpanQuery sq = new SpanWithinQuery(new SpanElementQuery("base", "a"), new SpanNextQuery(new SpanTermQuery(new Term("base", "s:h")), new SpanTermQuery(new Term("base", "s:i"))));
Result kr = ki.search(sq, (short) 10);
assertEquals("totalResults", kr.getTotalResults(), 4);
assertEquals("StartPos (0)", 3, kr.getMatch(0).startPos);
assertEquals("EndPos (0)", 10, kr.getMatch(0).endPos);
assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 10, kr.getMatch(1).endPos);
assertEquals("StartPos (2)", 3, kr.getMatch(2).startPos);
assertEquals("EndPos (2)", 10, kr.getMatch(2).endPos);
assertEquals("StartPos (3)", 5, kr.getMatch(3).startPos);
assertEquals("EndPos (3)", 8, kr.getMatch(3).endPos);
}
Aggregations