regex, updated examples
diff --git a/examples/bsp2.json b/examples/bsp2.json
index 71d089a..78a60d8 100644
--- a/examples/bsp2.json
+++ b/examples/bsp2.json
@@ -1 +1,36 @@
-{"context":"http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld","query":{"@type":"korap:group","operation":"operation:sequence","inOrder":true,"distances":[{"@type":"korap:distance","key":"w","min":1,"max":3}],"operands":[{"@type":"korap:token","wrap":{"@type":"korap:term","key":"Der","layer":"orth","match":"match:eq"}},{"@type":"korap:token","wrap":{"@type":"korap:term","key":"Mann","layer":"orth","match":"match:eq"}}]}}
\ No newline at end of file
+{
+ "context":"http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query":{
+ "@type":"korap:group",
+ "operation":"operation:sequence",
+ "inOrder":true,
+ "distances":[
+ {
+ "@type":"korap:distance",
+ "key":"w",
+ "min":1,
+ "max":3
+ }
+ ],
+ "operands":[
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"Der",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ },
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"Mann",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/examples/bsp3.json b/examples/bsp3.json
index 7577689..760a75a 100644
--- a/examples/bsp3.json
+++ b/examples/bsp3.json
@@ -1 +1,48 @@
-{"context":"http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld","query":{"@type":"korap:group","operation":"operation:sequence","inOrder":true,"distances":[{"@type":"korap:group","operation":"operation:and","operands":[{"@type":"korap:distance","key":"w","min":1,"max":3},{"@type":"korap:distance","key":"s","min":1,"max":1}]}],"operands":[{"@type":"korap:token","wrap":{"@type":"korap:term","key":"Der","layer":"orth","match":"match:eq"}},{"@type":"korap:token","wrap":{"@type":"korap:term","key":"Mann","layer":"orth","match":"match:eq"}}]}}
\ No newline at end of file
+{
+ "context":"http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query":{
+ "@type":"korap:group",
+ "operation":"operation:sequence",
+ "inOrder":true,
+ "distances":[
+ {
+ "@type":"korap:group",
+ "operation":"operation:and",
+ "operands":[
+ {
+ "@type":"korap:distance",
+ "key":"w",
+ "min":1,
+ "max":3
+ },
+ {
+ "@type":"korap:distance",
+ "key":"s",
+ "min":1,
+ "max":1
+ }
+ ]
+ }
+ ],
+ "operands":[
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"Der",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ },
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"Mann",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/examples/bsp4.json b/examples/bsp4.json
index 4d2c046..4eb25c8 100644
--- a/examples/bsp4.json
+++ b/examples/bsp4.json
@@ -1 +1,72 @@
-{"context":"http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld","query":{"@type":"korap:group","operation":"operation:sequence","inOrder":true,"distances":[{"@type":"korap:distance","key":"w","min":0,"max":5}],"operands":[{"@type":"korap:group","operation":"operation:sequence","inOrder":true,"distances":[{"@type":"korap:group","operation":"operation:and","operands":[{"@type":"korap:distance","key":"w","min":1,"max":3},{"@type":"korap:distance","key":"s","min":1,"max":1}]}],"operands":[{"@type":"korap:token","wrap":{"@type":"korap:term","key":"Der","layer":"orth","match":"match:eq"}},{"@type":"korap:token","wrap":{"@type":"korap:term","key":"Mann","layer":"orth","match":"match:eq"}}]},{"@type":"korap:token","wrap":{"@type":"korap:term","key":"geht","layer":"orth","match":"match:eq"}}]}}
\ No newline at end of file
+{
+ "context":"http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query":{
+ "@type":"korap:group",
+ "operation":"operation:sequence",
+ "inOrder":true,
+ "distances":[
+ {
+ "@type":"korap:distance",
+ "key":"w",
+ "min":0,
+ "max":5
+ }
+ ],
+ "operands":[
+ {
+ "@type":"korap:group",
+ "operation":"operation:sequence",
+ "inOrder":true,
+ "distances":[
+ {
+ "@type":"korap:group",
+ "operation":"operation:and",
+ "operands":[
+ {
+ "@type":"korap:distance",
+ "key":"w",
+ "min":1,
+ "max":3
+ },
+ {
+ "@type":"korap:distance",
+ "key":"s",
+ "min":1,
+ "max":1
+ }
+ ]
+ }
+ ],
+ "operands":[
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"Der",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ },
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"Mann",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ }
+ ]
+ },
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"geht",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/examples/bsp5.json b/examples/bsp5.json
index b4aaadc..8e156cf 100644
--- a/examples/bsp5.json
+++ b/examples/bsp5.json
@@ -1 +1,72 @@
-{"context":"http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld","query":{"@type":"korap:group","operation":"operation:sequence","inOrder":true,"distances":[{"@type":"korap:distance","key":"w","min":0,"max":5}],"operands":[{"@type":"korap:token","wrap":{"@type":"korap:term","key":"geht","layer":"orth","match":"match:eq"}},{"@type":"korap:group","operation":"operation:sequence","inOrder":true,"distances":[{"@type":"korap:group","operation":"operation:and","operands":[{"@type":"korap:distance","key":"w","min":1,"max":3},{"@type":"korap:distance","key":"s","min":1,"max":1}]}],"operands":[{"@type":"korap:token","wrap":{"@type":"korap:term","key":"Der","layer":"orth","match":"match:eq"}},{"@type":"korap:token","wrap":{"@type":"korap:term","key":"Mann","layer":"orth","match":"match:eq"}}]}]}}
\ No newline at end of file
+{
+ "context":"http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query":{
+ "@type":"korap:group",
+ "operation":"operation:sequence",
+ "inOrder":true,
+ "distances":[
+ {
+ "@type":"korap:distance",
+ "key":"w",
+ "min":0,
+ "max":5
+ }
+ ],
+ "operands":[
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"geht",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ },
+ {
+ "@type":"korap:group",
+ "operation":"operation:sequence",
+ "inOrder":true,
+ "distances":[
+ {
+ "@type":"korap:group",
+ "operation":"operation:and",
+ "operands":[
+ {
+ "@type":"korap:distance",
+ "key":"w",
+ "min":1,
+ "max":3
+ },
+ {
+ "@type":"korap:distance",
+ "key":"s",
+ "min":1,
+ "max":1
+ }
+ ]
+ }
+ ],
+ "operands":[
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"Der",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ },
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"Mann",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/examples/bsp6.json b/examples/bsp6.json
index 1b7050d..a1741e9 100644
--- a/examples/bsp6.json
+++ b/examples/bsp6.json
@@ -1 +1,87 @@
-{"context":"http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld","query":{"@type":"korap:group","operation":"operation:sequence","inOrder":true,"distances":[{"@type":"korap:distance","key":"w","min":0,"max":5}],"operands":[{"@type":"korap:group","operation":"operation:sequence","inOrder":true,"distances":[{"@type":"korap:group","operation":"operation:and","operands":[{"@type":"korap:distance","key":"w","min":1,"max":3},{"@type":"korap:distance","key":"s","min":1,"max":1}]}],"operands":[{"@type":"korap:token","wrap":{"@type":"korap:term","key":"Der","layer":"orth","match":"match:eq"}},{"@type":"korap:token","wrap":{"@type":"korap:term","key":"Mann","layer":"orth","match":"match:eq"}}]},{"@type":"korap:group","operation":"operation:sequence","operands":[{"@type":"korap:token","wrap":{"@type":"korap:term","key":"geht","layer":"orth","match":"match:eq"}},{"@type":"korap:token","wrap":{"@type":"korap:term","key":"weg","layer":"orth","match":"match:eq"}}]}]}}
\ No newline at end of file
+{
+ "context":"http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query":{
+ "@type":"korap:group",
+ "operation":"operation:sequence",
+ "inOrder":true,
+ "distances":[
+ {
+ "@type":"korap:distance",
+ "key":"w",
+ "min":0,
+ "max":5
+ }
+ ],
+ "operands":[
+ {
+ "@type":"korap:group",
+ "operation":"operation:sequence",
+ "inOrder":true,
+ "distances":[
+ {
+ "@type":"korap:group",
+ "operation":"operation:and",
+ "operands":[
+ {
+ "@type":"korap:distance",
+ "key":"w",
+ "min":1,
+ "max":3
+ },
+ {
+ "@type":"korap:distance",
+ "key":"s",
+ "min":1,
+ "max":1
+ }
+ ]
+ }
+ ],
+ "operands":[
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"Der",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ },
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"Mann",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ }
+ ]
+ },
+ {
+ "@type":"korap:group",
+ "operation":"operation:sequence",
+ "operands":[
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"geht",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ },
+ {
+ "@type":"korap:token",
+ "wrap":{
+ "@type":"korap:term",
+ "key":"weg",
+ "layer":"orth",
+ "match":"match:eq"
+ }
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
index 3625562..b4f22a1 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
@@ -461,7 +461,7 @@
value = valNode.getChild(0).getChild(0).toStringTree(poliqarpParser); //e.g. (simple_query (sq_segment foo))
} else if (valType.equals("re_query")) {
value = valNode.getChild(0).toStringTree(poliqarpParser); //e.g. (re_query "bar*")
- fieldMap.put("@subtype", "term:regex");
+ fieldMap.put("type", "type:regex");
value = value.substring(1,value.length()-1); //remove trailing quotes
}
fieldMap.put("key", value);
@@ -563,7 +563,7 @@
if (nodeCat.equals("re_query")) {
LinkedHashMap<String,Object> reQuery = new LinkedHashMap<String,Object>();
- reQuery.put("@subtype", "term:regex");
+ reQuery.put("type", "type:regex");
String regex = node.getChild(0).toStringTree(poliqarpParser);
reQuery.put("key", regex);
reQuery.put("match", "match:"+"eq");
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
index 89db3e7..ff7d432 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
@@ -111,8 +111,8 @@
throws QueryException {
if (ql.toLowerCase().equals("poliqarp")) {
ast = new PoliqarpPlusTree(query);
-// } else if (ql.toLowerCase().equals("cosmas")) {
-// ast = new CosmasTree(query);
+ } else if (ql.toLowerCase().equals("cosmas")) {
+ ast = new CosmasTree(query);
} else if (ql.toLowerCase().equals("poliqarpplus")) {
ast = new PoliqarpPlusTree(query);
} else {
diff --git a/src/test/java/PoliqarpPlusTreeTest.java b/src/test/java/PoliqarpPlusTreeTest.java
index 9b19447..b51bc9a 100644
--- a/src/test/java/PoliqarpPlusTreeTest.java
+++ b/src/test/java/PoliqarpPlusTreeTest.java
@@ -68,7 +68,7 @@
@Test
public void testRegex() throws QueryException {
String query = "[orth=\"M(a|ä)nn(er)?\"]";
- String re1 = "{@type=korap:token, wrap={@type=korap:term, @subtype=term:regex, key=M(a|ä)nn(er)?, layer=orth, match=match:eq}}";
+ String re1 = "{@type=korap:token, wrap={@type=korap:term, type=type:regex, key=M(a|ä)nn(er)?, layer=orth, match=match:eq}}";
ppt = new PoliqarpPlusTree(query);
map = ppt.getRequestMap().get("query").toString();
assertEquals(re1.replaceAll(" ", ""), map.replaceAll(" ", ""));