use of de.ids_mannheim.korap.query.SpanRepetitionQuery in project Krill by KorAP.
the class TestWPDIndex method testCase6.
/**
* Next and repetition
*/
@Test
public void testCase6() throws IOException {
SpanQuery sq = new SpanNextQuery(new SpanTermQuery(new Term("tokens", "tt/p:NN")), new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens", "mate/p:ADJA")), 2, 2, true));
ks = new Krill(sq);
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 30223);
// 1.1s
SpanQuery sq2 = new SpanNextQuery(sq, new SpanTermQuery(new Term("tokens", "tt/p:NN")));
ks = new Krill(sq2);
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 26607);
// 1.1s
}
use of de.ids_mannheim.korap.query.SpanRepetitionQuery in project Krill by KorAP.
the class TestWPDIndex method testCase5.
/**
* Repetition
*/
@Test
public void testCase5() throws IOException {
SpanQuery sq;
sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens", "mate/p:ADJA")), 1, 2, true);
ks = new Krill(sq);
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 4116416);
// 0.9s
sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens", "mate/p:ADJA")), 1, 1, true);
ks = new Krill(sq);
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 3879671);
sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens", "mate/p:ADJA")), 2, 2, true);
ks = new Krill(sq);
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 236745);
// 0.65s
}
use of de.ids_mannheim.korap.query.SpanRepetitionQuery in project Krill by KorAP.
the class TestRepetitionIndex method testCase3.
/**
* OR
*/
@Test
public void testCase3() 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 SpanOrQuery(new SpanRepetitionQuery(new SpanTermQuery(new Term("base", "s:c")), 1, 1, true), new SpanRepetitionQuery(new SpanTermQuery(new Term("base", "s:b")), 1, 1, true)));
kr = ki.search(sq, (short) 10);
assertEquals((long) 3, kr.getTotalResults());
assertEquals(1, kr.getMatch(0).startPos);
assertEquals(3, kr.getMatch(0).endPos);
assertEquals(4, kr.getMatch(1).startPos);
assertEquals(6, kr.getMatch(1).endPos);
assertEquals(7, kr.getMatch(2).startPos);
assertEquals(9, kr.getMatch(2).endPos);
}
use of de.ids_mannheim.korap.query.SpanRepetitionQuery 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.SpanRepetitionQuery 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());
}
Aggregations