Search in sources :

Example 26 with DistanceConstraint

use of de.ids_mannheim.korap.query.DistanceConstraint in project Krill by KorAP.

the class TestSubSpanIndex method testCase1.

@Test
public void testCase1() throws IOException {
    SpanDistanceQuery sdq = new SpanDistanceQuery(new SpanTermQuery(new Term("tokens", "tt/p:NN")), new SpanTermQuery(new Term("tokens", "tt/p:VAFIN")), new DistanceConstraint(5, 5, true, false), true);
    SpanSubspanQuery ssq = new SpanSubspanQuery(sdq, 0, 2, true);
    kr = ki.search(ssq, (short) 10);
    assertEquals((long) 8, kr.getTotalResults());
    assertEquals(35, kr.getMatch(0).getStartPos());
    assertEquals(37, kr.getMatch(0).getEndPos());
    assertEquals(179, kr.getMatch(1).getStartPos());
    assertEquals(181, kr.getMatch(1).getEndPos());
    ssq = new SpanSubspanQuery(sdq, -2, 2, true);
    kr = ki.search(ssq, (short) 10);
    assertEquals(39, kr.getMatch(0).getStartPos());
    assertEquals(41, kr.getMatch(0).getEndPos());
    assertEquals(183, kr.getMatch(1).getStartPos());
    assertEquals(185, kr.getMatch(1).getEndPos());
/*
         * for (Match km : kr.getMatches()){
         * System.out.println(km.getStartPos() +","+km.getEndPos()
         * +km.getSnippetBrackets()); }
         */
}
Also used : SpanSubspanQuery(de.ids_mannheim.korap.query.SpanSubspanQuery) SpanTermQuery(org.apache.lucene.search.spans.SpanTermQuery) SpanDistanceQuery(de.ids_mannheim.korap.query.SpanDistanceQuery) DistanceConstraint(de.ids_mannheim.korap.query.DistanceConstraint) Term(org.apache.lucene.index.Term) Test(org.junit.Test)

Aggregations

DistanceConstraint (de.ids_mannheim.korap.query.DistanceConstraint)26 Test (org.junit.Test)23 KrillIndex (de.ids_mannheim.korap.KrillIndex)20 SpanDistanceQuery (de.ids_mannheim.korap.query.SpanDistanceQuery)19 Term (org.apache.lucene.index.Term)13 SpanQuery (org.apache.lucene.search.spans.SpanQuery)13 SpanTermQuery (org.apache.lucene.search.spans.SpanTermQuery)13 SpanElementQuery (de.ids_mannheim.korap.query.SpanElementQuery)11 ArrayList (java.util.ArrayList)10 SpanClassQuery (de.ids_mannheim.korap.query.SpanClassQuery)8 SpanClassFilterQuery (de.ids_mannheim.korap.query.SpanClassFilterQuery)6 SpanMultipleDistanceQuery (de.ids_mannheim.korap.query.SpanMultipleDistanceQuery)3 SpanNextQuery (de.ids_mannheim.korap.query.SpanNextQuery)3 SpanSubspanQuery (de.ids_mannheim.korap.query.SpanSubspanQuery)3 SpanFocusQuery (de.ids_mannheim.korap.query.SpanFocusQuery)2 SpanReferenceQuery (de.ids_mannheim.korap.query.SpanReferenceQuery)2 SpanRelationMatchQuery (de.ids_mannheim.korap.query.SpanRelationMatchQuery)2 SpanRelationQuery (de.ids_mannheim.korap.query.SpanRelationQuery)2 Krill (de.ids_mannheim.korap.Krill)1 QueryBuilder (de.ids_mannheim.korap.query.QueryBuilder)1