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());
}
Aggregations