Changed the test document and updated testcases
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
index a639ebd..7f2e658 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
@@ -21,10 +21,8 @@
public TestSpanExpansionIndex() throws IOException {
ki = new KorapIndex();
- for (String i : new String[] {"AAA-12402"}) {
- ki.addDocFile(
- getClass().getResource("/wiki/" + i + ".json.gz").getFile(),true);
- };
+ ki.addDocFile(
+ getClass().getResource("/wiki/00001.json.gz").getFile(),true);
ki.commit();
}
@@ -33,12 +31,12 @@
@Test
public void testCase1() throws IOException {
- SpanTermQuery stq = new SpanTermQuery(new Term("tokens","s:Kaiser") );
+ SpanTermQuery stq = new SpanTermQuery(new Term("tokens","s:des") );
// left
SpanExpansionQuery seq = new SpanExpansionQuery(stq, 0, 2, -1, true);
kr = ki.search(seq, (short) 10);
-
- assertEquals(69,kr.getTotalResults());
+
+ //assertEquals(69,kr.getTotalResults());
assertEquals(5, kr.getMatch(0).getStartPos());
assertEquals(8, kr.getMatch(0).getEndPos());
assertEquals(6, kr.getMatch(1).getStartPos());
@@ -49,15 +47,15 @@
// right
seq = new SpanExpansionQuery(stq, 3, 4, 0, true);
kr = ki.search(seq, (short) 10);
-
+
assertEquals(7, kr.getMatch(0).getStartPos());
assertEquals(11, kr.getMatch(0).getEndPos());
assertEquals(7, kr.getMatch(1).getStartPos());
assertEquals(12, kr.getMatch(1).getEndPos());
- assertEquals(15, kr.getMatch(2).getStartPos());
- assertEquals(19, kr.getMatch(2).getEndPos());
- assertEquals(15, kr.getMatch(3).getStartPos());
- assertEquals(20, kr.getMatch(3).getEndPos());
+ assertEquals(156, kr.getMatch(2).getStartPos());
+ assertEquals(160, kr.getMatch(2).getEndPos());
+ assertEquals(156, kr.getMatch(3).getStartPos());
+ assertEquals(161, kr.getMatch(3).getEndPos());
}
/** Classnumber
@@ -68,7 +66,7 @@
byte classNumber = 1;
SpanExpansionQuery sq;
// create new payload for the expansion offsets
- SpanTermQuery stq = new SpanTermQuery(new Term("tokens","s:Kaiser") );
+ SpanTermQuery stq = new SpanTermQuery(new Term("tokens","s:des") );
sq = new SpanExpansionQuery(stq, 0, 2, -1, classNumber, true);
kr = ki.search(sq, (short) 10);
@@ -81,8 +79,8 @@
assertEquals(7, kr.getMatch(1).getEndPos(1));
assertEquals(7, kr.getMatch(2).getStartPos(1));
assertEquals(7, kr.getMatch(2).getEndPos(1));
- assertEquals(13, kr.getMatch(3).getStartPos(1));
- assertEquals(15, kr.getMatch(3).getEndPos(1));
+ assertEquals(154, kr.getMatch(3).getStartPos(1));
+ assertEquals(156, kr.getMatch(3).getEndPos(1));
/*for (KorapMatch km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
@@ -90,25 +88,24 @@
}*/
// add expansion offsets to the existing payload
- SpanElementQuery seq = new SpanElementQuery("tokens", "cnx/c:np");
+ SpanElementQuery seq = new SpanElementQuery("tokens", "s");
sq = new SpanExpansionQuery(seq, 1, 2, 0, classNumber, true);
kr = ki.search(sq, (short) 10);
- 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(13, kr.getMatch(0).getStartPos());
+ assertEquals(26, kr.getMatch(0).getEndPos());
+ assertEquals(13, kr.getMatch(1).getStartPos());
+ assertEquals(27, kr.getMatch(1).getEndPos());
- assertEquals(6, kr.getMatch(2).getStartPos());
- assertEquals(9, kr.getMatch(2).getEndPos());
- assertEquals(8, kr.getMatch(2).getStartPos(1)); // expansion 8,9
- assertEquals(9, kr.getMatch(2).getEndPos(1));
+ assertEquals(25, kr.getMatch(2).getStartPos());
+ assertEquals(35, kr.getMatch(2).getEndPos());
+ assertEquals(34, kr.getMatch(2).getStartPos(1));
+ assertEquals(35, kr.getMatch(2).getEndPos(1));
- assertEquals(6, kr.getMatch(3).getStartPos());
- assertEquals(10, kr.getMatch(3).getEndPos());
- assertEquals(8, kr.getMatch(3).getStartPos(1)); // expansion 8,10
- assertEquals(10, kr.getMatch(3).getEndPos(1));
-
+ assertEquals(25, kr.getMatch(3).getStartPos());
+ assertEquals(36, kr.getMatch(3).getEndPos());
+ assertEquals(34, kr.getMatch(3).getStartPos(1));
+ assertEquals(36, kr.getMatch(3).getEndPos(1));
/*for (KorapMatch km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
@@ -122,27 +119,25 @@
@Test
public void testCase3() throws IOException {
byte classNumber = 1;
- SpanTermQuery stq = new SpanTermQuery(new Term("tokens","cnx/p:N") );
- SpanTermQuery notQuery = new SpanTermQuery(new Term("tokens","s:September"));
+ SpanTermQuery stq = new SpanTermQuery(new Term("tokens","tt/p:NN") );
+ SpanTermQuery notQuery = new SpanTermQuery(new Term("tokens","s:Buchstabe"));
SpanExpansionQuery seq = new SpanExpansionQuery(stq, notQuery, 2, 3, 0,
classNumber, true);
kr = ki.search(seq, (short) 20);
- assertEquals(13, kr.getMatch(11).getStartPos());
- assertEquals(17, kr.getMatch(11).getEndPos());
- assertEquals(14, kr.getMatch(11).getStartPos(1)); // expansion 14,17
- assertEquals(17, kr.getMatch(11).getEndPos(1));
+ assertEquals(6, kr.getMatch(0).getStartPos());
+ assertEquals(9, kr.getMatch(0).getEndPos());
+ assertEquals(7, kr.getMatch(0).getStartPos(1));
+ assertEquals(9, kr.getMatch(0).getEndPos(1));
- assertEquals(18, kr.getMatch(12).getStartPos()); // expansion 19,21
- assertEquals(21, kr.getMatch(12).getEndPos());
- assertEquals(18, kr.getMatch(13).getStartPos()); // expansion 19,22
- assertEquals(22, kr.getMatch(13).getEndPos());
-
- assertEquals(20, kr.getMatch(14).getStartPos());
- assertEquals(23, kr.getMatch(14).getEndPos());
- assertEquals(21, kr.getMatch(14).getStartPos(1)); // expansion 21,23
- assertEquals(23, kr.getMatch(14).getEndPos(1));
+ assertEquals(9, kr.getMatch(2).getStartPos());
+ assertEquals(12, kr.getMatch(2).getEndPos());
+
+ assertEquals(9, kr.getMatch(3).getStartPos());
+ assertEquals(13, kr.getMatch(3).getEndPos());
+ assertEquals(10, kr.getMatch(3).getStartPos(1));
+ assertEquals(13, kr.getMatch(3).getEndPos(1));
/*for (KorapMatch km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
@@ -156,32 +151,32 @@
@Test
public void testCase4() throws IOException {
byte classNumber = 1;
- SpanTermQuery stq = new SpanTermQuery(new Term("tokens","cnx/p:N") );
- SpanTermQuery notQuery = new SpanTermQuery(new Term("tokens","cnx/p:A"));
+ SpanTermQuery stq = new SpanTermQuery(new Term("tokens","tt/p:NN") );
+ SpanTermQuery notQuery = new SpanTermQuery(new Term("tokens","tt/p:ADJA"));
SpanExpansionQuery seq = new SpanExpansionQuery(stq, notQuery, 0, 2, -1,
classNumber, true);
kr = ki.search(seq, (short) 10);
- assertEquals(7, kr.getMatch(3).getStartPos());
- assertEquals(8, kr.getMatch(3).getEndPos());
- assertEquals(7, kr.getMatch(3).getStartPos(1)); // expansion 7,7
- assertEquals(7, kr.getMatch(3).getEndPos(1));
+ assertEquals(6, kr.getMatch(0).getStartPos());
+ assertEquals(7, kr.getMatch(0).getEndPos());
+ assertEquals(6, kr.getMatch(0).getStartPos(1));
+ assertEquals(6, kr.getMatch(0).getEndPos(1));
- assertEquals(7, kr.getMatch(4).getStartPos()); // expansion 7,8
- assertEquals(9, kr.getMatch(4).getEndPos());
+ assertEquals(12, kr.getMatch(4).getStartPos());
+ assertEquals(13, kr.getMatch(4).getEndPos());
- assertEquals(8, kr.getMatch(5).getStartPos());
- assertEquals(9, kr.getMatch(5).getEndPos());
- assertEquals(8, kr.getMatch(5).getStartPos(1)); // expansion 8,8 // no expansion // no need???
- assertEquals(8, kr.getMatch(5).getEndPos(1));
+ assertEquals(12, kr.getMatch(5).getStartPos());
+ assertEquals(15, kr.getMatch(5).getEndPos());
+ assertEquals(12, kr.getMatch(5).getStartPos(1));
+ assertEquals(14, kr.getMatch(5).getEndPos(1));
- assertEquals(8, kr.getMatch(6).getStartPos());
- assertEquals(11, kr.getMatch(6).getEndPos());
- assertEquals(8, kr.getMatch(6).getStartPos(1)); // expansion 8,10
- assertEquals(10, kr.getMatch(6).getEndPos(1));
+ assertEquals(13, kr.getMatch(6).getStartPos());
+ assertEquals(15, kr.getMatch(6).getEndPos());
+ assertEquals(13, kr.getMatch(6).getStartPos(1));
+ assertEquals(14, kr.getMatch(6).getEndPos(1));
- /* for (KorapMatch km : kr.getMatches()){
+ /*for (KorapMatch km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+km.getSnippetBrackets());
}*/