More tests on deserialized sequences
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 2f177bd..a05f837 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
@@ -336,6 +336,13 @@
};
@Test
+ public void queryJSONseqEmptyStartRepetition2 () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/empty-first-repetition-2.jsonld").getFile());
+ // []{0,0}[tt/p=NN]
+ assertEquals(sqwi.toQuery().toString(), "tokens:tt/p:NN");
+ };
+
+ @Test
public void queryJSONseqEmptyMiddle () throws QueryException {
SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/empty-middle.jsonld").getFile());
// der[][tt/p=NN]
@@ -400,6 +407,78 @@
assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{3, 8}, left, class:1), []{2, 7}, right, class:2)");
};
+ @Test
+ public void queryJSONseqNegative () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/negative.jsonld").getFile());
+
+ // [tt/p!=NN]
+ assertTrue(sqwi.isNegative());
+ };
+
+ @Test
+ public void queryJSONseqNegativeStart () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/negative-first.jsonld").getFile());
+
+ // [tt/p!=NN][tt/p=NN]
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{1, 1}, left)");
+ };
+
+ @Test
+ public void queryJSONseqNegativeEnd () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/negative-last.jsonld").getFile());
+
+ // [tt/p=NN][tt/p!=NN]
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{1, 1}, right)");
+ };
+
+ @Test
+ public void queryJSONseqNegativeStartRepetition () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/negative-first-repetition.jsonld").getFile());
+
+ // [tt/p!=NN]{4,5}[tt/p=NN]
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{4, 5}, left)");
+ };
+
+ @Test
+ public void queryJSONseqNegativeStartRepetition2 () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/negative-first-repetition-2.jsonld").getFile());
+
+ // [tt/p!=NN]{0,5}[tt/p=NN]
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{0, 5}, left)");
+ };
+
+ @Test
+ public void queryJSONseqNegativeStartRepetition3 () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/negative-first-repetition-3.jsonld").getFile());
+
+ // [tt/p!=NN]{0,0}[tt/p=NN]
+ assertEquals(sqwi.toQuery().toString(), "tokens:tt/p:NN");
+ };
+
+ @Test
+ public void queryJSONseqNegativeEndClass () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/negative-last-class.jsonld").getFile());
+
+ // [tt/p=NN]{2:[tt/p!=NN]}
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{1, 1}, right, class:2)");
+ };
+
+ @Test
+ public void queryJSONseqNegativeEndRepetitionClass () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/negative-last-class-repetition.jsonld").getFile());
+
+ // [tt/p=NN]{2:[tt/p!=NN]{4,5}}
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{4, 5}, right, class:2)");
+ };
+
+ @Test
+ public void queryJSONseqNegativeEndRepetitionClass2 () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/sequence/negative-last-class-repetition-2.jsonld").getFile());
+
+ // [tt/p=NN]{2:[tt/p!=NN]}{4,5}
+ assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{4, 5}, right, class:2)");
+ };
+
public static String getString (String path) {
StringBuilder contentBuilder = new StringBuilder();
try {
diff --git a/src/test/resources/queries/sequence/empty-first-repetition-2.jsonld b/src/test/resources/queries/sequence/empty-first-repetition-2.jsonld
new file mode 100644
index 0000000..c84cc4c
--- /dev/null
+++ b/src/test/resources/queries/sequence/empty-first-repetition-2.jsonld
@@ -0,0 +1,43 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "collections" : [
+ {
+ "@type" : "korap:meta-filter",
+ "@value" : {
+ "@field" : "korap:field#corpusID",
+ "@type" : "korap:term",
+ "@value" : "WPD"
+ }
+ }
+ ],
+ "meta" : {},
+ "query" : {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "operation" : "operation:repetition",
+ "boundary": {
+ "@type" : "korap:boundary",
+ "min" : 0,
+ "max" : 0
+ },
+ "operands" : [
+ {
+ "@type" : "korap:token"
+ }]
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
diff --git a/src/test/resources/queries/sequence/negative-first-repetition-2.jsonld b/src/test/resources/queries/sequence/negative-first-repetition-2.jsonld
new file mode 100644
index 0000000..ded4793
--- /dev/null
+++ b/src/test/resources/queries/sequence/negative-first-repetition-2.jsonld
@@ -0,0 +1,40 @@
+{
+ "@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" : 0,
+ "max" : 5
+ },
+ "operands" : [
+ {
+
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:ne"
+ }
+ }]
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
diff --git a/src/test/resources/queries/sequence/negative-first-repetition-3.jsonld b/src/test/resources/queries/sequence/negative-first-repetition-3.jsonld
new file mode 100644
index 0000000..7ab3c24
--- /dev/null
+++ b/src/test/resources/queries/sequence/negative-first-repetition-3.jsonld
@@ -0,0 +1,40 @@
+{
+ "@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" : 0,
+ "max" : 0
+ },
+ "operands" : [
+ {
+
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:ne"
+ }
+ }]
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
diff --git a/src/test/resources/queries/sequence/negative-first-repetition.jsonld b/src/test/resources/queries/sequence/negative-first-repetition.jsonld
new file mode 100644
index 0000000..63df1bf
--- /dev/null
+++ b/src/test/resources/queries/sequence/negative-first-repetition.jsonld
@@ -0,0 +1,40 @@
+{
+ "@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" : 4,
+ "max" : 5
+ },
+ "operands" : [
+ {
+
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:ne"
+ }
+ }]
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
diff --git a/src/test/resources/queries/sequence/negative-first.jsonld b/src/test/resources/queries/sequence/negative-first.jsonld
new file mode 100644
index 0000000..5f4a130
--- /dev/null
+++ b/src/test/resources/queries/sequence/negative-first.jsonld
@@ -0,0 +1,29 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:ne"
+ }
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
diff --git a/src/test/resources/queries/sequence/negative-last-class-repetition-2.jsonld b/src/test/resources/queries/sequence/negative-last-class-repetition-2.jsonld
new file mode 100644
index 0000000..4d93449
--- /dev/null
+++ b/src/test/resources/queries/sequence/negative-last-class-repetition-2.jsonld
@@ -0,0 +1,47 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@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" : 4,
+ "max" : 5
+ },
+ "operands" : [
+ {
+ "@type" : "korap:group",
+ "class" : 2,
+ "operation" : "operation:class",
+ "operands" : [
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:ne"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
diff --git a/src/test/resources/queries/sequence/negative-last-class-repetition.jsonld b/src/test/resources/queries/sequence/negative-last-class-repetition.jsonld
new file mode 100644
index 0000000..372e390
--- /dev/null
+++ b/src/test/resources/queries/sequence/negative-last-class-repetition.jsonld
@@ -0,0 +1,47 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@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" : 4,
+ "max" : 5
+ },
+ "operands" : [
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:ne"
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
diff --git a/src/test/resources/queries/sequence/negative-last-class.jsonld b/src/test/resources/queries/sequence/negative-last-class.jsonld
new file mode 100644
index 0000000..41e0d45
--- /dev/null
+++ b/src/test/resources/queries/sequence/negative-last-class.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",
+ "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",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:ne"
+ }
+ }
+ ]
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
diff --git a/src/test/resources/queries/sequence/negative-last.jsonld b/src/test/resources/queries/sequence/negative-last.jsonld
new file mode 100644
index 0000000..7b29c8b
--- /dev/null
+++ b/src/test/resources/queries/sequence/negative-last.jsonld
@@ -0,0 +1,29 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type" : "korap:group",
+ "operands" : [
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:eq"
+ }
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:ne"
+ }
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}
diff --git a/src/test/resources/queries/sequence/negative.jsonld b/src/test/resources/queries/sequence/negative.jsonld
new file mode 100644
index 0000000..c0f5c21
--- /dev/null
+++ b/src/test/resources/queries/sequence/negative.jsonld
@@ -0,0 +1,13 @@
+{
+ "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "NN",
+ "layer" : "p",
+ "match" : "match:ne"
+ }
+ }
+}