started work on operators in AQL
diff --git a/src/test/java/AqlTreeTest.java b/src/test/java/AqlTreeTest.java
new file mode 100644
index 0000000..27bb1dd
--- /dev/null
+++ b/src/test/java/AqlTreeTest.java
@@ -0,0 +1,95 @@
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import de.ids_mannheim.korap.query.serialize.AqlTree;
+import de.ids_mannheim.korap.query.serialize.PoliqarpPlusTree;
+import de.ids_mannheim.korap.util.QueryException;
+
+public class AqlTreeTest {
+
+ AqlTree aqlt;
+ String map;
+ private String query;
+
+ private boolean equalsQueryContent(String res, String query) throws QueryException {
+ res = res.replaceAll(" ", "");
+ aqlt = new AqlTree(query);
+ String queryMap = aqlt.getRequestMap().get("query").toString().replaceAll(" ", "");
+ return res.equals(queryMap);
+ }
+
+ @Test
+ public void testContext() throws QueryException {
+ String contextString = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld";
+ aqlt = new AqlTree("Test");
+ assertEquals(contextString.replaceAll(" ", ""), aqlt.getRequestMap().get("@context").toString().replaceAll(" ", ""));
+ }
+
+ @Test
+ public void testSingleTokens() throws QueryException {
+ // "Mann"
+ query = "\"Mann\"";
+ String token1 = "{@type=korap:token, wrap={@type=korap:term, match=match:eq, key=Mann}}";
+ assertTrue(equalsQueryContent(token1, query));
+
+ // [orth!=Frau]
+ query = "tok!=\"Frau\"";
+ String token2 = "{@type=korap:token, wrap={@type=korap:term, match=match:ne, key=Frau}}";
+ assertTrue(equalsQueryContent(token2, query));
+
+ // Mann
+ query = "Mann";
+ String token4 = "{@type=korap:span, layer=Mann}";
+ assertTrue(equalsQueryContent(token4, query));
+ }
+
+ @Test
+ public void testSpans() throws QueryException {
+ query = "node";
+ String span1 =
+ "{@type=korap:span}";
+ aqlt = new AqlTree(query);
+ map = aqlt.getRequestMap().get("query").toString();
+ assertEquals(span1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+ }
+
+ @Test
+ public void testRegex() throws QueryException {
+ query = "/Mann/";
+ String regex1 = "{@type=korap:token, wrap={@type=korap:term, match=match:eq, type=type:regex, key=Mann}}";
+ aqlt = new AqlTree(query);
+ map = aqlt.getRequestMap().get("query").toString();
+ assertEquals(regex1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+ }
+
+ @Test
+ public void testLayers() throws QueryException {
+ query = "cnx/cat=\"NP\"";
+ String layers1 = "{@type=korap:span, foundry=cnx, layer=cat, match=match:eq, key=NP}";
+ aqlt = new AqlTree(query);
+ map = aqlt.getRequestMap().get("query").toString();
+ assertEquals(layers1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+ query = "treetagger/pos=\"NN\"";
+ String layers2 = "{@type=korap:token, wrap={@type=korap:term, foundry=treetagger, layer=pos, key=NN, match=match:eq}}";
+ aqlt = new AqlTree(query);
+ map = aqlt.getRequestMap().get("query").toString();
+ assertEquals(layers2.replaceAll(" ", ""), map.replaceAll(" ", ""));
+ }
+
+ @Test
+ public void testSimpleDominance() throws QueryException {
+ query = "node & node & #2 > #1";
+ String dom1 =
+ "{@type=korap:group, operation=operation:treeRelation, operands=[" +
+ "{@type=korap:span}," +
+ "{@type=korap:span}" +
+ "], treeRelation=dominance}";
+ aqlt = new AqlTree(query);
+ map = aqlt.getRequestMap().get("query").toString();
+ assertEquals(dom1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+ }
+
+}
+
diff --git a/src/test/java/CosmasTreeTest.java b/src/test/java/CosmasTreeTest.java
index b084bb4..10b6ed8 100644
--- a/src/test/java/CosmasTreeTest.java
+++ b/src/test/java/CosmasTreeTest.java
@@ -11,18 +11,6 @@
String map;
String query;
- private boolean equalsContent(String str, Object map) {
- str = str.replaceAll(" ", "");
- String mapStr = map.toString().replaceAll(" ", "");
- return str.equals(mapStr);
- }
-
- private boolean equalsQueryContent(String res, String query) throws QueryException {
- res = res.replaceAll(" ", "");
- ct = new CosmasTree(query);
- String queryMap = ct.getRequestMap().get("query").toString().replaceAll(" ", "");
- return res.equals(queryMap);
- }
@Test
public void testContext() throws QueryException {
diff --git a/src/test/java/PoliqarpPlusTreeTest.java b/src/test/java/PoliqarpPlusTreeTest.java
index 69d9293..3fab91f 100644
--- a/src/test/java/PoliqarpPlusTreeTest.java
+++ b/src/test/java/PoliqarpPlusTreeTest.java
@@ -2,7 +2,6 @@
import org.junit.Test;
-import de.ids_mannheim.korap.query.serialize.CosmasTree;
import de.ids_mannheim.korap.query.serialize.PoliqarpPlusTree;
import de.ids_mannheim.korap.util.QueryException;
@@ -11,11 +10,6 @@
PoliqarpPlusTree ppt;
String map;
- private boolean equalsContent(String str, Object map) {
- str = str.replaceAll(" ", "");
- String mapStr = map.toString().replaceAll(" ", "");
- return str.equals(mapStr);
- }
private boolean equalsQueryContent(String res, String query) throws QueryException {
res = res.replaceAll(" ", "");