Warn on use of operation:merge
Change-Id: Ib3764ebcff3222aa0bd18e28e6c3e1ff862bb170
diff --git a/src/main/java/de/ids_mannheim/korap/KrillQuery.java b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
index 45f1dda..3cfd7ee 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
@@ -442,6 +442,11 @@
/*throw new QueryException(765,
"Relations are currently not supported");*/
+ // Gracefully warn on merge support
+ case "operation:merge":
+ this.addWarning(774, "Merge operation is currently not supported");
+ return _fromKoral(operands.get(0));
+
// Deprecated in favor of operation:junction
case "operation:or":
return this._operationJunctionFromJson(operands);
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
index af53472..34fb3f1 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
@@ -601,18 +601,20 @@
@Test
- public void queryJSONregexRewrite2 () throws QueryException {
- // "der" [.*] [.*?] [.+] [.+?]
+ public void queryJSONmerge () throws QueryException {
+ // treat merging gracefully
String json = getString(getClass()
- .getResource("/queries/sequence/regex-rewrite-2.jsonld")
+ .getResource("/queries/merge.jsonld")
.getFile());
KrillQuery kq = new KrillQuery("tokens");
-
assertEquals(kq.fromKoral(json).toQuery().toString(),
- "focus(254: spanContain(<tokens:base/s:t />, {254: spanExpansion(tokens:s:der, []{4, 4}, right)}))");
+ "spanNext(tokens:s:der, tokens:s:Baum)");
+ assertEquals(kq.getWarning(0).getCode(), 774);
};
+
+
public static String getString (String path) {
StringBuilder contentBuilder = new StringBuilder();
try {
diff --git a/src/test/resources/queries/merge.jsonld b/src/test/resources/queries/merge.jsonld
new file mode 100644
index 0000000..9b50760
--- /dev/null
+++ b/src/test/resources/queries/merge.jsonld
@@ -0,0 +1,34 @@
+{
+ "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld",
+ "query": {
+ "@type": "koral:group",
+ "operation":"operation:merge",
+ "operands": [
+ {
+ "@type": "koral:group",
+ "operation": "operation:sequence",
+ "inOrder": true,
+ "operands": [
+ {
+ "@type": "koral:token",
+ "wrap": {
+ "match": "match:eq",
+ "layer": "orth",
+ "key": "der",
+ "@type": "koral:term"
+ }
+ },
+ {
+ "wrap": {
+ "match": "match:eq",
+ "layer": "orth",
+ "key": "Baum",
+ "@type": "koral:term"
+ },
+ "@type": "koral:token"
+ }
+ ]
+ }
+ ]
+ }
+}