Search in sources :

Example 36 with SpanNextQuery

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);
}
Also used : SpanTermQuery(org.apache.lucene.search.spans.SpanTermQuery) SpanWithinQuery(de.ids_mannheim.korap.query.SpanWithinQuery) Term(org.apache.lucene.index.Term) KrillIndex(de.ids_mannheim.korap.KrillIndex) SpanElementQuery(de.ids_mannheim.korap.query.SpanElementQuery) SpanQuery(org.apache.lucene.search.spans.SpanQuery) SpanNextQuery(de.ids_mannheim.korap.query.SpanNextQuery) Result(de.ids_mannheim.korap.response.Result) Test(org.junit.Test)

Aggregations

SpanNextQuery (de.ids_mannheim.korap.query.SpanNextQuery)36 Test (org.junit.Test)35 Term (org.apache.lucene.index.Term)34 SpanTermQuery (org.apache.lucene.search.spans.SpanTermQuery)34 KrillIndex (de.ids_mannheim.korap.KrillIndex)31 SpanQuery (org.apache.lucene.search.spans.SpanQuery)31 Result (de.ids_mannheim.korap.response.Result)15 SpanElementQuery (de.ids_mannheim.korap.query.SpanElementQuery)9 SpanClassQuery (de.ids_mannheim.korap.query.SpanClassQuery)6 SpanFocusQuery (de.ids_mannheim.korap.query.SpanFocusQuery)6 SpanRepetitionQuery (de.ids_mannheim.korap.query.SpanRepetitionQuery)6 DistanceConstraint (de.ids_mannheim.korap.query.DistanceConstraint)3 SpanWithinQuery (de.ids_mannheim.korap.query.SpanWithinQuery)3 SpanDistanceQuery (de.ids_mannheim.korap.query.SpanDistanceQuery)2 SpanRelationQuery (de.ids_mannheim.korap.query.SpanRelationQuery)2 SpanSegmentQuery (de.ids_mannheim.korap.query.SpanSegmentQuery)2 ArrayList (java.util.ArrayList)2 SpanOrQuery (org.apache.lucene.search.spans.SpanOrQuery)2 Krill (de.ids_mannheim.korap.Krill)1 KrillQuery (de.ids_mannheim.korap.KrillQuery)1