Further query serialization tests
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 9917184..43f9fb1 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
@@ -90,15 +90,62 @@
assertEquals(sqwi.toQuery().toString(), "");
};
- /*
@Test
public void queryJSONBsp9 () {
SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp9.json").getFile());
// [base=Katze&orth=Katzen]
+ assertEquals(sqwi.toQuery().toString(), "spanNear([tokens:base:Katze, tokens:orth:Katzen], -1, false)");
+ };
+
+ @Test
+ public void queryJSONBsp10 () {
+ SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp10.json").getFile());
+
+ // [base=Katze][orth=und][orth=Hunde]
+ assertEquals(sqwi.toQuery().toString(), "spanNext(spanNext(tokens:base:Katze, tokens:orth:und), tokens:orth:Hunde)");
+ };
+
+ @Ignore
+ public void queryJSONBsp11 () {
+ SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp11.json").getFile());
+
+ // [!(base=Katze&orth=Katzen)]
assertEquals(sqwi.toQuery().toString(), "");
};
- */
+
+ @Test
+ public void queryJSONBsp12 () {
+ SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp12.json").getFile());
+
+ // contains(<np>,[base=Mann])
+ assertEquals(sqwi.toQuery().toString(), "spanWithin(<tokens:np />, tokens:base:Mann)");
+ };
+
+ @Ignore
+ public void queryJSONBsp13 () {
+ SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp13.json").getFile());
+
+ // startswith(<np>,[!pos=Det])
+ assertEquals(sqwi.toQuery().toString(), "");
+ };
+
+ @Test
+ public void queryJSONBsp13b () {
+ SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp13b.json").getFile());
+
+ // startswith(<np>,[!pos=Det])
+ assertEquals(sqwi.toQuery().toString(), "spanWithin(<tokens:np />, tokens:pos:Det, 1)");
+ };
+
+ @Ignore
+ public void queryJSONBsp14 () {
+ SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp14.json").getFile());
+
+ // 'vers{2,3}uch'
+ assertEquals(sqwi.toQuery().toString(), "");
+ };
+
public static String getString (String path) {
StringBuilder contentBuilder = new StringBuilder();
@@ -128,4 +175,4 @@
};
return sqwi;
};
-};
\ No newline at end of file
+};
diff --git a/src/test/resources/queries/bsp13b.json b/src/test/resources/queries/bsp13b.json
new file mode 100644
index 0000000..562c80c
--- /dev/null
+++ b/src/test/resources/queries/bsp13b.json
@@ -0,0 +1,40 @@
+{
+ "@context": {
+ "@language": "de",
+ "class": {
+ "@id": "korap:class",
+ "@type": "xsd:integer"
+ },
+ "filter": "korap:filter",
+ "korap": "http://korap.ids-mannheim.de/ns/query",
+ "meta": "korap:meta",
+ "operands": {
+ "@container": "@list",
+ "@id": "korap:operands"
+ },
+ "query": "korap:query",
+ "relation": {
+ "@id": "korap:relation",
+ "@type": "korap:relation#types"
+ }
+ },
+ "query": {
+ "@type": "korap:group",
+ "operands": [
+ {
+ "@type": "korap:element",
+ "@value": "np"
+ },
+ {
+ "@type": "korap:token",
+ "@value": {
+ "@type": "korap:term",
+ "@value": "pos:Det",
+ "relation": "="
+ }
+ }
+ ],
+ "position": "startswith",
+ "relation": "position"
+ }
+}
diff --git a/src/test/resources/queries/readme.txt b/src/test/resources/queries/readme.txt
index 36745ce..60a54f7 100644
--- a/src/test/resources/queries/readme.txt
+++ b/src/test/resources/queries/readme.txt
@@ -11,7 +11,8 @@
bsp11.json: [!(base=Katze&orth=Katzen)]
bsp12.json: contains(<np>,[base=Mann])
bsp13.json: startswith(<np>,[!pos=Det])
+bsp13b.json: startswith(<np>,[pos=Det])
bsp14.json: 'vers{2,3}uch'
bsp15.json: [orth='vers.*ch']
bsp16.json: [(base=bar|base=foo)&orth=foobar]
-bsp17.json: within(<np>,[base=Mann])
\ No newline at end of file
+bsp17.json: within(<np>,[base=Mann])