bugfix multiword values
diff --git a/src/main/antlr/CollectionQuery.g4 b/src/main/antlr/CollectionQuery.g4
index 5949b73..d3b25b4 100644
--- a/src/main/antlr/CollectionQuery.g4
+++ b/src/main/antlr/CollectionQuery.g4
@@ -52,7 +52,7 @@
NL : [\r\n] -> skip;
ws : WS+;
-WORD : ALPHABET* ALPHA ALPHABET*; // needs to have at least one alphabetical letter
+WORD : ALPHABET* ALPHA ALPHABET*; // needs to have at least one alphabetical letter (non-numeric)
/*
* Regular expressions
@@ -139,11 +139,15 @@
value
: WORD
-| '"' (WORD ws*)+'"'
+| multiword
| date
| regex
;
+multiword
+: '"' WORD+ '"'
+;
+
relation
: (expr|exprGroup) booleanOp (expr|exprGroup|relation)
;
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryTree.java
index 8cecce4..330b01a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryTree.java
@@ -231,6 +231,12 @@
String regex = valueNode.getChild(0).getChild(0).toStringTree(parser);
map.put("value", regex.substring(1, regex.length()-1));
map.put("type", "type:regex");
+ } else if (getNodeCat(valueNode.getChild(0)).equals("multiword")) {
+ String mw = "";
+ for (int i=1; i<valueNode.getChild(0).getChildCount()-1; i++) {
+ mw += valueNode.getChild(0).getChild(i).getText() + " ";
+ }
+ map.put("value", mw.substring(0, mw.length()-1));
} else if (getNodeCat(valueNode.getChild(0)).equals("date")) {
map.put("type", "type:date");
String value = valueNode.getChild(0).getChild(0).toStringTree(parser);
@@ -348,7 +354,7 @@
if (getNodeCat(keyNode.getChild(0)).equals("regex")) {
isRegex = true;
term.put("type", "type:regex");
- key = key.substring(1, key.length()-1); // remove leading and trailing quotes
+ key = key.substring(1, key.length()-1); // remove leading and trailing slashes
}
if (mode.equals("span")) term.put("value", key);
else term.put("key", key);
@@ -437,8 +443,6 @@
query = "1990<year<2010 & genre=Sport";
query = "1990<year<2010";
query = "pubDate<Sport";
- query = "title~Hamburg";
-// query = "foo=b-ar";
// filter.verbose = true;
CollectionQueryTree filter = null;
try {
diff --git a/src/test/java/CollectionQueryTreeTest.java b/src/test/java/CollectionQueryTreeTest.java
index 349b98a..1dd488b 100644
--- a/src/test/java/CollectionQueryTreeTest.java
+++ b/src/test/java/CollectionQueryTreeTest.java
@@ -38,6 +38,14 @@
cqt.process(query);
map = cqt.getRequestMap().get("collection").toString();
assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+ query = "title~\"IDS Mannheim\"";
+ expected =
+ "{@type=korap:doc, key=title, value=IDS Mannheim, match=match:contains}";
+ cqt = new CollectionQueryTree();
+ cqt.process(query);
+ map = cqt.getRequestMap().get("collection").toString();
+ assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
}
@Test