use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestRepetitionIndex method testCase5.
@Test
public void testCase5() throws IOException {
ki = new KrillIndex();
ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"), true);
ki.commit();
SpanQuery sq0, sq1, sq2;
sq0 = new SpanTermQuery(new Term("tokens", "tt/p:NN"));
sq1 = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens", "tt/p:ADJA")), 2, 3, true);
sq2 = new SpanNextQuery(sq1, sq0);
kr = ki.search(sq2, (short) 10);
assertEquals((long) 2, kr.getTotalResults());
assertEquals(73, kr.getMatch(0).getStartPos());
assertEquals(77, kr.getMatch(0).getEndPos());
assertEquals(74, kr.getMatch(1).getStartPos());
assertEquals(77, kr.getMatch(1).getEndPos());
sq2 = new SpanNextQuery(new SpanTermQuery(new Term("tokens", "s:offenen")), sq2);
kr = ki.search(sq2, (short) 10);
assertEquals((long) 1, kr.getTotalResults());
assertEquals(73, kr.getMatch(0).getStartPos());
assertEquals(77, kr.getMatch(0).getEndPos());
/*
for (Match km : kr.getMatches()){
System.out.println(km.getSnippetBrackets());
System.out.println(km.getStartPos() +","+km.getEndPos());
}*/
}
use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestRepetitionIndex method testCase2.
/**
* Skip to
*/
@Test
public void testCase2() throws IOException {
ki = new KrillIndex();
ki.addDoc(createFieldDoc0());
ki.addDoc(createFieldDoc3());
ki.addDoc(createFieldDoc2());
ki.addDoc(createFieldDoc1());
ki.commit();
SpanQuery sq;
// c{2,2}
// sq = new SpanRepetitionQuery(
// new SpanTermQuery(new Term("base", "s:c")), 2, 2, true);
// kr = ki.search(sq, (short) 10);
// // doc1 2-4, 3-5, 4-6
// assertEquals((long) 6, kr.getTotalResults());
// ec{2,2}
sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:e")), new SpanRepetitionQuery(new SpanTermQuery(new Term("base", "s:c")), 2, 2, true));
kr = ki.search(sq, (short) 10);
assertEquals((long) 2, kr.getTotalResults());
assertEquals(3, kr.getMatch(1).getLocalDocID());
}
use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestRepetitionIndex method testRepetitionInSequences.
@Test
public void testRepetitionInSequences() throws IOException {
ki = new KrillIndex();
ki.addDoc(createFieldDoc0());
ki.commit();
SpanQuery sq, sq2;
// ec{1,2}
sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:e")), new SpanRepetitionQuery(new SpanTermQuery(new Term("base", "s:c")), 1, 2, true));
kr = ki.search(sq, (short) 10);
// 1-3, 1-4, 4-6
assertEquals((long) 3, kr.getTotalResults());
assertEquals(1, kr.getMatch(0).getStartPos());
assertEquals(3, kr.getMatch(0).getEndPos());
assertEquals(1, kr.getMatch(1).getStartPos());
assertEquals(4, kr.getMatch(1).getEndPos());
assertEquals(4, kr.getMatch(2).getStartPos());
assertEquals(6, kr.getMatch(2).getEndPos());
// ec{1,2}d
sq2 = new SpanNextQuery(sq, new SpanTermQuery(new Term("base", "s:d")));
kr = ki.search(sq2, (short) 10);
assertEquals((long) 2, kr.getTotalResults());
assertEquals(1, kr.getMatch(0).startPos);
assertEquals(5, kr.getMatch(0).endPos);
assertEquals(4, kr.getMatch(1).startPos);
assertEquals(7, kr.getMatch(1).endPos);
// Multiple documents
ki.addDoc(createFieldDoc1());
ki.commit();
kr = ki.search(sq2, (short) 10);
assertEquals((long) 5, kr.getTotalResults());
}
use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestSegmentIndex method testCase4.
/**
* Matching a SpanElementQuery and a SpanNextQuery
* Multiple atomic indices
*/
@Test
public void testCase4() throws IOException {
// log.trace("Testcase4");
ki = new KrillIndex();
ki.addDoc(createFieldDoc0());
ki.commit();
ki.addDoc(createFieldDoc1());
ki.addDoc(createFieldDoc2());
ki.commit();
sq = new SpanSegmentQuery(new SpanElementQuery("base", "e"), new SpanNextQuery(new SpanTermQuery(new Term("base", "s:a")), new SpanTermQuery(new Term("base", "s:b"))));
kr = ki.search(sq, (short) 10);
ki.close();
assertEquals("totalResults", kr.getTotalResults(), 2);
// Match #0
assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
assertEquals("StartPos", 3, kr.getMatch(0).startPos);
assertEquals("EndPos", 5, kr.getMatch(0).endPos);
// Match #1
assertEquals("doc-number", 0, kr.getMatch(1).getLocalDocID());
assertEquals("StartPos", 1, kr.getMatch(1).startPos);
assertEquals("EndPos", 3, kr.getMatch(1).endPos);
}
use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestUnorderedElementDistanceIndex method testCase4.
/**
* Multiple documents
* Skip to
*/
@Test
public void testCase4() throws IOException {
// System.out.println("testCase4");
ki = new KrillIndex();
ki.addDoc(createFieldDoc1());
ki.addDoc(createFieldDoc0());
ki.addDoc(createFieldDoc3());
ki.addDoc(createFieldDoc4());
ki.commit();
SpanQuery sq, edq;
edq = createQuery("s", "s:b", "s:c", 1, 1, false);
sq = new SpanNextQuery(edq, new SpanTermQuery(new Term("base", "s:e")));
kr = ki.search(sq, (short) 10);
assertEquals((long) 4, kr.getTotalResults());
assertEquals(0, kr.getMatch(0).startPos);
assertEquals(3, kr.getMatch(0).endPos);
assertEquals(1, kr.getMatch(1).startPos);
assertEquals(6, kr.getMatch(1).endPos);
assertEquals(3, kr.getMatch(2).startPos);
assertEquals(6, kr.getMatch(2).endPos);
assertEquals(3, kr.getMatch(3).getLocalDocID());
assertEquals(0, kr.getMatch(3).startPos);
assertEquals(4, kr.getMatch(3).endPos);
}
Aggregations