Added more tests for expansion deserialization
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
index be852ce..2f177bd 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
@@ -265,7 +265,6 @@
assertEquals(sqwi.toQuery().toString(), "shrink(1: spanEndsWith(<tokens:s />, {1: tokens:mate/p:V}))");
};
-
@Test
public void queryJSONrepetition () throws QueryException {
SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp-repetition.jsonld").getFile());
@@ -283,6 +282,10 @@
};
+ /*
+ Check extensions
+ */
+
@Test
public void queryJSONseqEmpty () throws QueryException {
SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/empty.jsonld").getFile());
@@ -353,6 +356,50 @@
assertEquals(sqwi.toQuery().toString(), "spanNext(tokens:s:der, spanExpansion(tokens:tt/p:NN, []{4, 8}, left))");
};
+ @Test
+ public void queryJSONseqEmptySurround () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/empty-surround.jsonld").getFile());
+ // [][tt/p=NN][]
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{1, 1}, left), []{1, 1}, right)");
+ };
+
+ @Test
+ public void queryJSONseqEmptySurroundClass () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/empty-surround-class.jsonld").getFile());
+ // [][tt/p=NN]{2:[]}
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{1, 1}, left), []{1, 1}, right, class:2)");
+ };
+
+ @Test
+ public void queryJSONseqEmptySurroundClass2 () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/empty-surround-class-2.jsonld").getFile());
+ // {3:[]}[tt/p=NN]{2:[]}
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{1, 1}, left, class:3), []{1, 1}, right, class:2)");
+ };
+
+ @Test
+ public void queryJSONseqEmptySurroundRepetition () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/empty-surround-repetition.jsonld").getFile());
+ // [][tt/p=NN][]{2,7}
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{1, 1}, left), []{2, 7}, right)");
+ };
+
+ @Test
+ public void queryJSONseqEmptySurroundRepetition2 () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/empty-surround-repetition-2.jsonld").getFile());
+ // []{3,5}[tt/p=NN][]{2,7}
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{3, 5}, left), []{2, 7}, right)");
+ };
+
+ @Test
+ public void queryJSONseqEmptySurroundRepetitionClass () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/empty-surround-repetition-class.jsonld").getFile());
+ // {1:[]}{3,8}[tt/p=NN]{2:[]{2,7}}
+ // Ist gleichbedeutend mit
+ // {1:[]{3,8}}[tt/p=NN]{2:[]}{2,7}
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{3, 8}, left, class:1), []{2, 7}, right, class:2)");
+ };
+
public static String getString (String path) {
StringBuilder contentBuilder = new StringBuilder();
try {
diff --git a/src/test/resources/queries/sequence/empty-surround-class-2.jsonld b/src/test/resources/queries/sequence/empty-surround-class-2.jsonld
new file mode 100644
index 0000000..5f15478
--- /dev/null
+++ b/src/test/resources/queries/sequence/empty-surround-class-2.jsonld
@@ -0,0 +1,37 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "class" : 3,
+ "operation" : "operation:class",
+ "operands" : [
+ {
+ "@type" : "korap:token"
+}]
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ },
+ {
+ "@type" : "korap:group",
+ "class" : 2,
+ "operation" : "operation:class",
+ "operands" : [
+ {
+ "@type" : "korap:token"
+ }]
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/queries/sequence/empty-surround-class.jsonld b/src/test/resources/queries/sequence/empty-surround-class.jsonld
new file mode 100644
index 0000000..2c5846f
--- /dev/null
+++ b/src/test/resources/queries/sequence/empty-surround-class.jsonld
@@ -0,0 +1,31 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@type" : "korap:token"
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ },
+ {
+ "@type" : "korap:group",
+ "class" : 2,
+ "operation" : "operation:class",
+ "operands" : [
+ {
+ "@type" : "korap:token"
+ }]
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/queries/sequence/empty-surround-repetition-2.jsonld b/src/test/resources/queries/sequence/empty-surround-repetition-2.jsonld
new file mode 100644
index 0000000..789fc53
--- /dev/null
+++ b/src/test/resources/queries/sequence/empty-surround-repetition-2.jsonld
@@ -0,0 +1,46 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "operation" : "operation:repetition",
+ "boundary": {
+ "@type" : "korap:boundary",
+ "min" : 3,
+ "max" : 5
+ },
+ "operands" : [
+ {
+ "@type" : "korap:token"
+}]
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ },
+ {
+ "@type" : "korap:group",
+ "operation" : "operation:repetition",
+ "boundary": {
+ "@type" : "korap:boundary",
+ "min" : 2,
+ "max" : 7
+ },
+ "operands" : [
+ {
+
+ "@type" : "korap:token"
+}]
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/queries/sequence/empty-surround-repetition-class.jsonld b/src/test/resources/queries/sequence/empty-surround-repetition-class.jsonld
new file mode 100644
index 0000000..8a584dc
--- /dev/null
+++ b/src/test/resources/queries/sequence/empty-surround-repetition-class.jsonld
@@ -0,0 +1,61 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "operation" : "operation:repetition",
+ "boundary": {
+ "@type" : "korap:boundary",
+ "min" : 3,
+ "max" : 8
+ },
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "class" : 1,
+ "operation" : "operation:class",
+ "operands" : [
+ {
+ "@type" : "korap:token"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ },
+ {
+ "@type" : "korap:group",
+ "class" : 2,
+ "operation" : "operation:class",
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "operation" : "operation:repetition",
+ "boundary": {
+ "@type" : "korap:boundary",
+ "min" : 2,
+ "max" : 7
+ },
+ "operands" : [
+ {
+ "@type" : "korap:token"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
diff --git a/src/test/resources/queries/sequence/empty-surround-repetition.jsonld b/src/test/resources/queries/sequence/empty-surround-repetition.jsonld
new file mode 100644
index 0000000..6b88e4f
--- /dev/null
+++ b/src/test/resources/queries/sequence/empty-surround-repetition.jsonld
@@ -0,0 +1,36 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@type" : "korap:token"
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ },
+ {
+ "@type" : "korap:group",
+ "operation" : "operation:repetition",
+ "boundary": {
+ "@type" : "korap:boundary",
+ "min" : 2,
+ "max" : 7
+ },
+ "operands" : [
+ {
+
+ "@type" : "korap:token"
+}]
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/queries/sequence/empty-surround.jsonld b/src/test/resources/queries/sequence/empty-surround.jsonld
new file mode 100644
index 0000000..2e93da6
--- /dev/null
+++ b/src/test/resources/queries/sequence/empty-surround.jsonld
@@ -0,0 +1,25 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@type" : "korap:token"
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ },
+ {
+ "@type" : "korap:token"
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
\ No newline at end of file