EOF bugfix, new complex test cases
diff --git a/src/main/antlr/CollectionQuery.g4 b/src/main/antlr/CollectionQuery.g4
index 76752a2..0bd7fe5 100644
--- a/src/main/antlr/CollectionQuery.g4
+++ b/src/main/antlr/CollectionQuery.g4
@@ -87,6 +87,6 @@
;
start
-: expr EOF
+: expr
| exprGroup EOF
;
\ No newline at end of file
diff --git a/src/test/java/ExpertFilterTest.java b/src/test/java/ExpertFilterTest.java
index ca5ac4d..14a876d 100644
--- a/src/test/java/ExpertFilterTest.java
+++ b/src/test/java/ExpertFilterTest.java
@@ -10,14 +10,6 @@
ExpertFilter ef;
String map;
private String query;
-
- private boolean equalsQueryContent(String res, String query) throws QueryException {
- res = res.replaceAll(" ", "");
- ef = new ExpertFilter();
- ef.process(query);
- String queryMap = ef.getRequestMap().get("query").toString().replaceAll(" ", "");
- return res.equals(queryMap);
- }
@Test
public void testSimple() throws QueryException {
@@ -154,6 +146,77 @@
ef.process(query);
map = ef.getRequestMap().toString();
assertEquals(q2.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+ query = "(author=Goethe&year=1815)|textClass=Drama";
+ String q3 =
+ "{@type=korap:filter, filter=" +
+ "{@type=korap:termGroup, relation=relation:or, operands=[" +
+
+ "{@type=korap:termGroup, relation=relation:and, operands=[" +
+ "{@type=korap:term, attribute=author, key=Goethe, match=match:eq}," +
+ "{@type=korap:term, attribute=year, key=1815, match=match:eq}" +
+ "]}," +
+ "{@type=korap:term, attribute=textClass, key=Drama, match=match:eq}" +
+ "]}" +
+ "}";
+ ef = new ExpertFilter();
+ ef.process(query);
+ map = ef.getRequestMap().toString();
+ assertEquals(q3.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+ query = "(author=Goethe|year=1815)&textClass=Drama";
+ String q4 =
+ "{@type=korap:filter, filter=" +
+ "{@type=korap:termGroup, relation=relation:and, operands=[" +
+
+ "{@type=korap:termGroup, relation=relation:or, operands=[" +
+ "{@type=korap:term, attribute=author, key=Goethe, match=match:eq}," +
+ "{@type=korap:term, attribute=year, key=1815, match=match:eq}" +
+ "]}," +
+ "{@type=korap:term, attribute=textClass, key=Drama, match=match:eq}" +
+ "]}" +
+ "}";
+ ef = new ExpertFilter();
+ ef.process(query);
+ map = ef.getRequestMap().toString();
+ assertEquals(q4.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+ query = "(author=Goethe&year=1815)&textClass=Drama";
+ String q5 =
+ "{@type=korap:filter, filter=" +
+ "{@type=korap:termGroup, relation=relation:and, operands=[" +
+
+ "{@type=korap:termGroup, relation=relation:and, operands=[" +
+ "{@type=korap:term, attribute=author, key=Goethe, match=match:eq}," +
+ "{@type=korap:term, attribute=year, key=1815, match=match:eq}" +
+ "]}," +
+ "{@type=korap:term, attribute=textClass, key=Drama, match=match:eq}" +
+ "]}" +
+ "}";
+ ef = new ExpertFilter();
+ ef.process(query);
+ map = ef.getRequestMap().toString();
+ assertEquals(q5.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+ query = "(textClass=wissenschaft & textClass=politik) & (corpusID=A00 | corpusID=WPD)";
+ String q6 =
+ "{@type=korap:filter, filter=" +
+ "{@type=korap:termGroup, relation=relation:and, operands=[" +
+
+ "{@type=korap:termGroup, relation=relation:and, operands=[" +
+ "{@type=korap:term, attribute=textClass, key=wissenschaft, match=match:eq}," +
+ "{@type=korap:term, attribute=textClass, key=politik, match=match:eq}" +
+ "]}," +
+ "{@type=korap:termGroup, relation=relation:or, operands=[" +
+ "{@type=korap:term, attribute=corpusID, key=A00, match=match:eq}," +
+ "{@type=korap:term, attribute=corpusID, key=WPD, match=match:eq}" +
+ "]}" +
+ "]}" +
+ "}";
+ ef = new ExpertFilter();
+ ef.process(query);
+ map = ef.getRequestMap().toString();
+ assertEquals(q6.replaceAll(" ", ""), map.replaceAll(" ", ""));
}
@Test