Search in sources :

Example 6 with SpanClassFilterQuery

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

the class TestClassFilterIndex method testMultipleSameClasses.

@Test
public void testMultipleSameClasses() throws IOException {
    ki = new KrillIndex();
    ki.addDoc(TestReferenceIndex.createFieldDoc0());
    ki.commit();
    SpanElementQuery seq1 = new SpanElementQuery("tokens", "nn");
    SpanElementQuery seq = new SpanElementQuery("tokens", "prp");
    SpanClassQuery scq1 = new SpanClassQuery(seq1, (byte) 1);
    SpanClassQuery scq = new SpanClassQuery(seq, (byte) 1);
    SpanDistanceQuery sdq = new SpanDistanceQuery(scq, scq1, new DistanceConstraint(3, 5, false, false), true);
    SpanElementQuery seq2 = new SpanElementQuery("tokens", "vp");
    SpanClassQuery scq2 = new SpanClassQuery(seq2, (byte) 2);
    SpanDistanceQuery sdq2 = new SpanDistanceQuery(sdq, scq2, new DistanceConstraint(0, 1, false, false), true);
    SpanClassFilterQuery sq = new SpanClassFilterQuery(sdq2, ClassOperation.INCLUDE, 2, 1, true);
    kr = ki.search(sdq2, (short) 20);
    assertEquals(6, kr.getTotalResults());
    // for (Match km : kr.getMatches()) {
    // System.out.println(km.getStartPos() + "," + km.getEndPos()
    // + " "
    // + km.getSnippetBrackets());
    // }
    kr = ki.search(sq, (short) 20);
    // for (Match km : kr.getMatches()) {
    // System.out.println(km.getStartPos() + "," + km.getEndPos()
    // + " "
    // + km.getSnippetBrackets());
    // }
    assertEquals(6, kr.getMatch(0).getStartPos());
    assertEquals(18, kr.getMatch(0).getEndPos());
    assertEquals("Frankenstein, treat my daughter well. She [[{2:is the {1:one} that saved {1:your} master who you hold so dear}]].", kr.getMatch(0).getSnippetBrackets());
}
Also used : SpanClassFilterQuery(de.ids_mannheim.korap.query.SpanClassFilterQuery) SpanClassQuery(de.ids_mannheim.korap.query.SpanClassQuery) SpanDistanceQuery(de.ids_mannheim.korap.query.SpanDistanceQuery) DistanceConstraint(de.ids_mannheim.korap.query.DistanceConstraint) KrillIndex(de.ids_mannheim.korap.KrillIndex) SpanElementQuery(de.ids_mannheim.korap.query.SpanElementQuery) Test(org.junit.Test)

Aggregations

KrillIndex (de.ids_mannheim.korap.KrillIndex)6 DistanceConstraint (de.ids_mannheim.korap.query.DistanceConstraint)6 SpanClassFilterQuery (de.ids_mannheim.korap.query.SpanClassFilterQuery)6 SpanClassQuery (de.ids_mannheim.korap.query.SpanClassQuery)6 SpanDistanceQuery (de.ids_mannheim.korap.query.SpanDistanceQuery)6 SpanElementQuery (de.ids_mannheim.korap.query.SpanElementQuery)6 Test (org.junit.Test)6