poliqarpPlus support in JsonGenerator
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/JsonGenerator.java b/src/main/java/de/ids_mannheim/korap/query/serialize/JsonGenerator.java
index 10c0be9..829fbdc 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/JsonGenerator.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/JsonGenerator.java
@@ -20,11 +20,23 @@
mapper = new ObjectMapper();
}
- public void run(String outFile, String query, String queryLanguage) throws JsonGenerationException, JsonMappingException, IOException {
+ /**
+ * Runs the JsonGenerator by initializing the relevant AbstractSyntaxTree implementation (depending on specified query language)
+ * and transforms and writes the tree's requestMap to the specified output file.
+ * @param outFile The file to which the serialization is written
+ * @param query The query string
+ * @param queryLanguage The query language. As of 13/11/20, this must be either 'poliqarp' or 'poliqarpplus'. Some extra maven stuff needs to done to support CosmasII ('cosmas') [that maven stuff would be to tell maven how to build the cosmas grammar and where to find the classes]
+ * @throws JsonGenerationException
+ * @throws JsonMappingException
+ * @throws IOException
+ */
+ public void run(String query, String queryLanguage, String outFile) throws JsonGenerationException, JsonMappingException, IOException {
if (queryLanguage.equals("poliqarp")) {
ast = new PoliqarpPlusTree(query);
// } else if (queryLanguage.equals("cosmas")) {
// ast = new CosmasTree(query);
+ } else if (queryLanguage.equals("poliqarpplus")) {
+ ast = new PoliqarpPlusTree(query);
}
Map<String, Object> requestMap = ast.getRequestMap();
mapper.writeValue(new File(outFile), requestMap);
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 20a37e7..0b6bacb 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
@@ -554,24 +554,24 @@
* For testing
*/
String[] queries = new String[] {
- "[base=foo]|([base=foo][base=bar])*",
- "([base=foo]|[base=bar])[base=foobar]",
- "[base=foo]([base=bar]|[base=foobar/i])",
- "[base=bar|base=foo]",
- "[base=bar]",
- "[base=foo][base=bar]",
- "[(base=bar|base=foo)&orth=wee]",
- "[base=foo/i][base=bar]{2,4}",
- "foo bar/i",
- "{[base=foo]}[orth=bar]",
- "{[base=foo]}{[orth=bar]}",
- "{1:[base=foo]<np>}",
+// "[base=foo]|([base=foo][base=bar])*",
+// "([base=foo]|[base=bar])[base=foobar]",
+// "[base=foo]([base=bar]|[base=foobar/i])",
+// "[base=bar|base=foo]",
+// "[base=bar]",
+// "[base=foo][base=bar]",
+// "[(base=bar|base=foo)&orth=wee]",
+// "[base=foo/i][base=bar]{2,4}",
+// "foo bar/i",
+// "{[base=foo]}[orth=bar]",
+// "{[base=foo]}{[orth=bar]}",
+// "{1:[base=foo]<np>}",
"shrink({[base=foo]}[orth=bar])",
- "<np>",
- "startsWith({<sentence>},<np>)",
- "startsWith({<sentence>},[base=foo])",
- "[base=foo]|([base=foo][base=bar])* meta author=Goethe&year=1815",
- "([base=foo][base=bar])*",
+// "<np>",
+// "startsWith({<sentence>},<np>)",
+// "startsWith({<sentence>},[base=foo])",
+// "[base=foo]|([base=foo][base=bar])* meta author=Goethe&year=1815",
+// "([base=foo][base=bar])*",
};
for (String q : queries) {
try {