Tested repetition with min boundary zero.
Change-Id: I1a80d9fa4801a05db2d82b506da236dc95569eac
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java
index cedb868..a76bc4d 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java
@@ -13,6 +13,7 @@
import de.ids_mannheim.korap.KrillIndex;
import de.ids_mannheim.korap.query.SpanNextQuery;
import de.ids_mannheim.korap.query.SpanRepetitionQuery;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.response.Result;
public class TestRepetitionIndex {
@@ -76,22 +77,38 @@
return fd;
}
-
+ @Test
+ public void testTermQuery () throws IOException {
+ ki = new KrillIndex();
+ ki.addDoc(createFieldDoc0());
+ ki.commit();
+
+ // Quantifier only
+ // c{1,2}
+ SpanQuery sq = new SpanRepetitionQuery(
+ new SpanTermQuery(new Term("base", "s:c")), 1, 2, true);
+ kr = ki.search(sq, (short) 10);
+ // 0-1, 2-3, 2-4, 3-4, 5-6
+ assertEquals((long) 5, kr.getTotalResults());
+ assertEquals(0, kr.getMatch(0).getStartPos());
+ assertEquals(1, kr.getMatch(0).getEndPos());
+ assertEquals(2, kr.getMatch(1).getStartPos());
+ assertEquals(3, kr.getMatch(1).getEndPos());
+ assertEquals(2, kr.getMatch(2).getStartPos());
+ assertEquals(4, kr.getMatch(2).getEndPos());
+ assertEquals(3, kr.getMatch(3).getStartPos());
+ assertEquals(4, kr.getMatch(3).getEndPos());
+ assertEquals(5, kr.getMatch(4).getStartPos());
+ assertEquals(6, kr.getMatch(4).getEndPos());
+ }
+
@Test
- public void testCase1 () throws IOException {
+ public void testRepetitionInSequences() throws IOException {
ki = new KrillIndex();
ki.addDoc(createFieldDoc0());
ki.commit();
SpanQuery sq, sq2;
- // Quantifier only
- // c{1,2}
- sq = new SpanRepetitionQuery(
- new SpanTermQuery(new Term("base", "s:c")), 1, 2, true);
- kr = ki.search(sq, (short) 10);
- // 0-1, 2-3, 2-4, 3-4, 5-6
- assertEquals((long) 5, kr.getTotalResults());
-
// ec{1,2}
sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:e")),
new SpanRepetitionQuery(new SpanTermQuery(new Term("base",
@@ -100,6 +117,12 @@
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")));
@@ -117,6 +140,36 @@
assertEquals((long) 5, kr.getTotalResults());
}
+ @Test
+ public void testMinZeroRepetition() throws IOException {
+ ki = new KrillIndex();
+ ki.addDoc(createFieldDoc0());
+ ki.commit();
+
+ SpanQuery sq, sq2;
+ sq = new SpanTermQuery(new Term("base", "s:e"));
+ kr = ki.search(sq, (short) 10);
+
+ assertEquals((long) 4, kr.getTotalResults());
+ assertEquals(1, kr.getMatch(0).getStartPos());
+ assertEquals(2, kr.getMatch(0).getEndPos());
+ assertEquals(4, kr.getMatch(1).getStartPos());
+ assertEquals(5, kr.getMatch(1).getEndPos());
+ assertEquals(7, kr.getMatch(2).getStartPos());
+ assertEquals(8, kr.getMatch(2).getEndPos());
+ assertEquals(8, kr.getMatch(3).getStartPos());
+ assertEquals(9, kr.getMatch(3).getEndPos());
+
+ sq2 = new SpanNextQuery(sq,
+ new SpanRepetitionQuery(new SpanTermQuery(new Term("base",
+ "s:c")), 0, 1, true));
+
+ kr = ki.search(sq2, (short) 10);
+ for (Match km : kr.getMatches()){
+ //System.out.println(km.getSnippetBrackets());
+ System.out.println(km.getStartPos() +","+km.getEndPos());
+ }
+ }
/** Skip to */
@Test
@@ -222,10 +275,7 @@
assertEquals(77, kr.getMatch(0).getEndPos());
assertEquals(74, kr.getMatch(1).getStartPos());
assertEquals(77, kr.getMatch(1).getEndPos());
- /* for (Match km : kr.getMatches()){
- System.out.println(km.getSnippetBrackets());
- System.out.println(km.getStartPos() +","+km.getEndPos());
- }*/
+
sq2 = new SpanNextQuery(new SpanTermQuery(new Term("tokens",
"s:offenen")), sq2);