Added const as an extensible layer
diff --git a/CHANGES b/CHANGES
index c7c5bbb..33e06bc 100644
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,7 @@
- [bugfix] Corrected small bug where null warnings where
returned in JSON (diewald)
- [cleanup] Converted error to failure (diewald)
+ - [bugfix] Added const layer rewrite (diewald)
0.48 2014-11-07
- [feature] Retrieval of token lists (diewald)
diff --git a/src/main/java/de/ids_mannheim/korap/KorapQuery.java b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
index d07c100..70267c1 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
@@ -660,6 +660,10 @@
case "orth":
layer = "s";
break;
+
+ case "const":
+ layer = "c";
+ break;
};
if (isCaseInsensitive && isTerm) {
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 32109cd..4474b10 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
@@ -301,8 +301,6 @@
assertEquals(sqwi.toQuery().toString(), "tokens:i:baum");
};
-
-
@Test
public void queryJSONunderspecifiedTokenBug () {
// ((MORPH(APPR) ODER MORPH(APPRART)) /+w1 Urlaub
@@ -315,6 +313,12 @@
};
};
+ @Test
+ public void queryJSONspecialLayerBug () throws QueryException {
+ SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bugs/special_layer.jsonld").getFile());
+ assertEquals(sqwi.toQuery().toString(), "spanNext(spanNext(spanNext(tokens:s:Baum, tokens:cnx/p:CC), tokens:tt/l:Baum), <tokens:xip/c:MC />)");
+ };
+
@Test
public void queryJSONrepetitionGroupRewriteBug () throws QueryException {
diff --git a/src/test/resources/queries/bugs/special_layer.jsonld b/src/test/resources/queries/bugs/special_layer.jsonld
new file mode 100644
index 0000000..92c03b0
--- /dev/null
+++ b/src/test/resources/queries/bugs/special_layer.jsonld
@@ -0,0 +1,45 @@
+{
+ "@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" : "opennlp",
+ "key" : "Baum",
+ "layer" : "orth",
+ "match" : "match:eq"
+ }
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "cnx",
+ "key" : "CC",
+ "layer" : "pos",
+ "match" : "match:eq"
+ }
+ },
+ {
+ "@type" : "korap:token",
+ "wrap" : {
+ "@type" : "korap:term",
+ "foundry" : "tt",
+ "key" : "Baum",
+ "layer" : "lemma",
+ "match" : "match:eq"
+ }
+ },
+ {
+ "@type" : "korap:span",
+ "foundry" : "xip",
+ "key" : "MC",
+ "layer" : "const"
+ }
+ ],
+ "operation" : "operation:sequence"
+ }
+}