Fixed class payload in SpanRepetition
diff --git a/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java b/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
index 5d3e0b5..04e1d3f 100644
--- a/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
+++ b/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
@@ -7,9 +7,11 @@
import java.io.FileReader;
import java.io.IOException;
+import org.apache.lucene.search.spans.SpanQuery;
import org.junit.Test;
import de.ids_mannheim.korap.KorapIndex;
+import de.ids_mannheim.korap.KorapMatch;
import de.ids_mannheim.korap.KorapQuery;
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.KorapSearch;
@@ -56,6 +58,36 @@
kr.getMatch(1).getSnippetBrackets());
}
+ @Test
+ public void queryJSONpoly4() throws QueryException, IOException {
+
+ String jsonPath = getClass().getResource("/queries/poly4.json").getFile();
+ String jsonQuery = readFile(jsonPath);
+ SpanQueryWrapper sqwi = new KorapQuery("tokens").fromJSON(
+ jsonQuery
+ );
+ SpanQuery sq = sqwi.toQuery();
+ System.out.println(sq.toString());
+
+ ki = new KorapIndex();
+ ki.addDocFile(
+ getClass().getResource("/wiki/SSS-09803.json.gz").getFile(),true);
+
+ ki.commit();
+ kr = ki.search(sq, (short) 10);
+
+ assertEquals(827, kr.getTotalResults());
+ assertEquals(3, kr.getMatch(0).getStartPos());
+ assertEquals(5, kr.getMatch(0).getEndPos());
+
+ for (KorapMatch km : kr.getMatches()){
+ System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+ +km.getSnippetBrackets()
+ );
+ }
+ }
+
+
private String readFile(String path) {
StringBuilder sb = new StringBuilder();
try {
diff --git a/src/test/resources/queries/poly4.json b/src/test/resources/queries/poly4.json
new file mode 100644
index 0000000..8f1f1ec
--- /dev/null
+++ b/src/test/resources/queries/poly4.json
@@ -0,0 +1,85 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld",
+ "collection" : {},
+ "collections" : [
+ {
+ "@type" : "korap:meta-filter",
+ "@value" : {
+ "@field" : "korap:field#corpusID",
+ "@type" : "korap:term",
+ "@value" : "WPD"
+ }
+ }
+ ],
+ "errors" : [],
+ "messages" : [
+ [
+ 303,
+ "Deprecated 2014-07-24: 'min' and 'max' to be supported until 3 months from deprecation date."
+ ],
+ [
+ 303,
+ "Deprecated 2014-10-07: 'class' only to be supported until 3 months from deprecation date. Classes are now defined using the 'classOut' attribute."
+ ],
+ [
+ 303,
+ "Deprecated 2014-07-24: 'min' and 'max' to be supported until 3 months from deprecation date."
+ ]
+ ],
+ "meta" : {},
+ "query" : {
+ "@type" : "korap:group",
+ "boundary" : {
+ "@type" : "korap:boundary",
+ "max" : 3,
+ "min" : 1
+ },
+ "max" : 3,
+ "min" : 1,
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "class" : 1,
+ "classOut" : 1,
+ "operands" : [
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "cnx",
+ "key" : "N",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ }
+ ],
+ "operation" : "operation:class"
+ },
+ {
+ "@type" : "korap:group",
+ "boundary" : {
+ "@type" : "korap:boundary",
+ "max" : 5,
+ "min" : 1
+ },
+ "max" : 5,
+ "min" : 1,
+ "operands" : [
+ {
+ "@type" : "korap:token"
+ }
+ ],
+ "operation" : "operation:repetition"
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+ ],
+ "operation" : "operation:repetition"
+ },
+ "warnings" : []
+}
+
\ No newline at end of file