collection query tree to inherent serialisation structure from AbstractSyntaxTree
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java
index 5f1b2d8..d0e9ec0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java
@@ -58,7 +58,7 @@
ArrayList<String> announcements = new ArrayList<String>();
AbstractSyntaxTree() {
- requestMap.put("@context", "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld");
+ requestMap.put("@context", "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld");
requestMap.put("errors", errorMsgs);
requestMap.put("warnings", warnings);
requestMap.put("announcements", announcements);
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 c598ba2..15a1f11 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
@@ -19,10 +19,6 @@
private boolean verbose = false;
private List<ParseTree> visited = new ArrayList<ParseTree>();
/**
- * Top-level map representing the whole request.
- */
- LinkedHashMap<String, Object> requestMap = new LinkedHashMap<String, Object>();
- /**
* Keeps track of active object.
*/
LinkedList<LinkedHashMap<String, Object>> objectStack = new LinkedList<LinkedHashMap<String, Object>>();
@@ -36,7 +32,15 @@
LinkedList<Integer> objectsToPop = new LinkedList<Integer>();
Integer stackedObjects = 0;
- @Override
+ public CollectionQueryTree() {
+ super();
+ }
+
+ public CollectionQueryTree(String query) throws QueryException {
+ process(query);
+ }
+
+ @Override
public void process(String query) throws QueryException {
ParseTree tree = parseCollectionQuery(query);
if (this.parser != null) {
@@ -282,7 +286,7 @@
} else {
// I want the raw object, not a wrapped
// requestMap.put("filter", object);
- requestMap = object;
+ requestMap.put("query", object);
}
}
@@ -419,21 +423,14 @@
query = "1990<year<2010";
query = "pubDate<Sport";
// query = "foo=b-ar";
- CollectionQueryTree filter = new CollectionQueryTree();
// filter.verbose = true;
+ CollectionQueryTree filter = null;
try {
- filter.process(query);
+ filter = new CollectionQueryTree(query);
} catch (QueryException e) {
e.printStackTrace();
}
System.out.println(filter.getRequestMap());
}
-
- @Override
- public Map<String, Object> getRequestMap() {
- return requestMap;
- }
-
-
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
index c81f0aa..ba42dbe 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
@@ -23,7 +23,7 @@
/**
* Map representation of CosmasII syntax tree as returned by ANTLR
*
- * @author joachim
+ * @author bingel
*/
public class CosmasTree extends Antlr3AbstractSyntaxTree {
@@ -185,6 +185,7 @@
// make category-specific fieldMap entry
String attr = nodeCat.equals("OPWF") ? "orth" : "lemma";
String value = node.getChild(0).toStringTree().replaceAll("\"", "");
+ // check for wildcard string
Pattern p = Pattern.compile("[+*?]");
Matcher m = p.matcher(value);
if (m.find()) fieldMap.put("type", "type:wildcard");
@@ -1070,7 +1071,7 @@
// "Sonne /s0 Mond",
"Sonne /+w1:4 Mond /-w1:7 Sterne",
"Der:t",
- "*mond"
+ "&mond-"
};
CosmasTree.verbose=true;
for (String q : queries) {