Search in sources :

Example 56 with SpanElementQuery

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

Example 57 with SpanElementQuery

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());
}
Also used : SpanWithinQuery(de.ids_mannheim.korap.query.SpanWithinQuery) SpanSequenceQueryWrapper(de.ids_mannheim.korap.query.wrap.SpanSequenceQueryWrapper) SpanElementQuery(de.ids_mannheim.korap.query.SpanElementQuery) Test(org.junit.Test)

Aggregations

SpanElementQuery (de.ids_mannheim.korap.query.SpanElementQuery)57 Test (org.junit.Test)53 KrillIndex (de.ids_mannheim.korap.KrillIndex)37 Term (org.apache.lucene.index.Term)36 SpanTermQuery (org.apache.lucene.search.spans.SpanTermQuery)35 SpanQuery (org.apache.lucene.search.spans.SpanQuery)32 Result (de.ids_mannheim.korap.response.Result)26 SpanClassQuery (de.ids_mannheim.korap.query.SpanClassQuery)16 SpanWithinQuery (de.ids_mannheim.korap.query.SpanWithinQuery)16 DistanceConstraint (de.ids_mannheim.korap.query.DistanceConstraint)11 SpanDistanceQuery (de.ids_mannheim.korap.query.SpanDistanceQuery)11 SpanFocusQuery (de.ids_mannheim.korap.query.SpanFocusQuery)10 SpanNextQuery (de.ids_mannheim.korap.query.SpanNextQuery)9 SpanRelationQuery (de.ids_mannheim.korap.query.SpanRelationQuery)8 SpanAttributeQuery (de.ids_mannheim.korap.query.SpanAttributeQuery)6 SpanClassFilterQuery (de.ids_mannheim.korap.query.SpanClassFilterQuery)6 SpanRelationMatchQuery (de.ids_mannheim.korap.query.SpanRelationMatchQuery)6 SpanWithAttributeQuery (de.ids_mannheim.korap.query.SpanWithAttributeQuery)6 SpanSegmentQuery (de.ids_mannheim.korap.query.SpanSegmentQuery)4 ArrayList (java.util.ArrayList)4