Added arbitrary element with attribute(s) deserialization and test examples.
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanWithAttributeJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanWithAttributeJSON.java
index a04e6f7..976958a 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanWithAttributeJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanWithAttributeJSON.java
@@ -67,8 +67,46 @@
"/queries/attribute/any-element-with-attribute.jsonld")
.getFile();
SpanQueryWrapper sqwi = getJSONQuery(filepath);
- // SpanQuery sq = sqwi.toQuery();
- assertEquals(null, sqwi);
+ SpanQuery sq = sqwi.toQuery();
+ assertEquals(
+ "spanWithAttribute(spanAttribute(tokens:type:top))",
+ sq.toString());
+ }
+
+ @Test
+ public void testAnyElementWithMultipleOrAttributes() throws QueryException {
+ String filepath = getClass().getResource(
+ "/queries/attribute/any-element-with-multiple-or-attributes.jsonld")
+ .getFile();
+ SpanQueryWrapper sqwi = getJSONQuery(filepath);
+ SpanQuery sq = sqwi.toQuery();
+ assertEquals(
+ "spanOr([spanWithAttribute(spanAttribute(tokens:type:Zeitschrift)), "
+ + "spanWithAttribute(spanAttribute(tokens:complete:Y)), "
+ + "spanWithAttribute(spanAttribute(tokens:n:0))])",
+ sq.toString());
+ }
+
+ @Test
+ public void testAnyElementMultipleAndNotAttributes() throws QueryException {
+ String filepath = getClass()
+ .getResource(
+ "/queries/attribute/any-element-with-multiple-and-not-attributes.jsonld")
+ .getFile();
+ SpanQueryWrapper sqwi = getJSONQuery(filepath);
+ SpanQuery sq = sqwi.toQuery();
+ assertEquals(
+ "spanWithAttribute([spanAttribute(tokens:type:Zeitschrift), "
+ + "spanAttribute(!tokens:complete:Y), spanAttribute(tokens:n:0)])",
+ sq.toString());
+ }
+
+ @Test(expected = QueryException.class)
+ public void testAnyElementSingleNotAttribute() throws QueryException {
+ String filepath = getClass().getResource(
+ "/queries/attribute/any-element-with-single-not-attribute.jsonld")
+ .getFile();
+ SpanQueryWrapper sqwi = getJSONQuery(filepath);
}
}
diff --git a/src/test/resources/queries/attribute/any-element-with-attribute.jsonld b/src/test/resources/queries/attribute/any-element-with-attribute.jsonld
index ead458e..f53906d 100644
--- a/src/test/resources/queries/attribute/any-element-with-attribute.jsonld
+++ b/src/test/resources/queries/attribute/any-element-with-attribute.jsonld
@@ -8,11 +8,9 @@
"@type": "koral:span",
"attr": {
"@type": "koral:term",
- "arity": {
- "@type": "koral:boundary",
- "min": 2,
- "max": 2
- }
+ "layer": "type",
+ "key": "top",
+ "match": "match:eq"
}
},
"meta": {}
diff --git a/src/test/resources/queries/attribute/any-element-with-multiple-and-not-attributes.jsonld b/src/test/resources/queries/attribute/any-element-with-multiple-and-not-attributes.jsonld
new file mode 100644
index 0000000..db21c70
--- /dev/null
+++ b/src/test/resources/queries/attribute/any-element-with-multiple-and-not-attributes.jsonld
@@ -0,0 +1,35 @@
+{
+ "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld",
+ "errors": [],
+ "warnings": [],
+ "messages": [],
+ "collection": {},
+ "query": {
+ "@type": "korap:span",
+ "attr": {
+ "@type": "korap:termGroup",
+ "relation": "relation:and",
+ "operands": [
+ {
+ "@type": "korap:term",
+ "layer": "type",
+ "key": "Zeitschrift",
+ "match": "match:eq"
+ },
+ {
+ "@type": "korap:term",
+ "layer": "complete",
+ "key": "Y",
+ "match": "match:ne"
+ },
+ {
+ "@type": "korap:term",
+ "layer": "n",
+ "key": "0",
+ "match": "match:eq"
+ }
+ ]
+ }
+ },
+ "meta": {}
+}
\ No newline at end of file
diff --git a/src/test/resources/queries/attribute/any-element-with-multiple-or-attributes.jsonld b/src/test/resources/queries/attribute/any-element-with-multiple-or-attributes.jsonld
new file mode 100644
index 0000000..765531c
--- /dev/null
+++ b/src/test/resources/queries/attribute/any-element-with-multiple-or-attributes.jsonld
@@ -0,0 +1,35 @@
+{
+ "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld",
+ "errors": [],
+ "warnings": [],
+ "messages": [],
+ "collection": {},
+ "query": {
+ "@type": "korap:span",
+ "attr": {
+ "@type": "korap:termGroup",
+ "relation": "relation:or",
+ "operands": [
+ {
+ "@type": "korap:term",
+ "layer": "type",
+ "key": "Zeitschrift",
+ "match": "match:eq"
+ },
+ {
+ "@type": "korap:term",
+ "layer": "complete",
+ "key": "Y",
+ "match": "match:eq"
+ },
+ {
+ "@type": "korap:term",
+ "layer": "n",
+ "key": "0",
+ "match": "match:eq"
+ }
+ ]
+ }
+ },
+ "meta": {}
+}
\ No newline at end of file
diff --git a/src/test/resources/queries/attribute/any-element-with-single-not-attribute.jsonld b/src/test/resources/queries/attribute/any-element-with-single-not-attribute.jsonld
new file mode 100644
index 0000000..3c1ed4f
--- /dev/null
+++ b/src/test/resources/queries/attribute/any-element-with-single-not-attribute.jsonld
@@ -0,0 +1,17 @@
+{
+ "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld",
+ "errors": [],
+ "warnings": [],
+ "messages": [],
+ "collection": {},
+ "query": {
+ "@type": "korap:span",
+ "attr": {
+ "@type": "korap:term",
+ "layer": "type",
+ "key": "top",
+ "match": "match:ne"
+ }
+ },
+ "meta": {}
+}
\ No newline at end of file