Added AND serialization with operation:sequence distance 0 in a sentence.
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CQLTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CQLTree.java
index b057eeb..a9c1d2a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CQLTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CQLTree.java
@@ -103,13 +103,13 @@
if (node instanceof CQLTermNode) {
return parseTermNode((CQLTermNode) node);
- /*} else if (node instanceof CQLAndNode) {
- return parseAndNode((CQLAndNode) node);*/
+ } else if (node instanceof CQLAndNode) {
+ return parseAndNode((CQLAndNode) node);
} else if (node instanceof CQLOrNode) {
return parseOrNode((CQLOrNode) node);
} else {
throw new QueryException(105, "SRU diagnostic 48: Only basic search including term-only " +
- "and boolean OR operator queries are currently supported.");
+ "and boolean (AND,OR) operator queries are currently supported.");
}
}
@@ -131,11 +131,12 @@
Map<String, Object> map = new LinkedHashMap<String,Object>();
map.put("@type", "korap:group");
map.put("operation", OPERATION_SEQUENCE);
+ map.put("inOrder", false);
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> distanceMap = new LinkedHashMap<String,Object>();
distanceMap.put("@type", "korap:distance");
- distanceMap.put("key", "w");
+ distanceMap.put("key", "s");
distanceMap.put("min", "0");
distanceMap.put("max", "0");
list.add(distanceMap);
diff --git a/src/test/java/CQLTest.java b/src/test/java/CQLTest.java
index e410281..0018103 100644
--- a/src/test/java/CQLTest.java
+++ b/src/test/java/CQLTest.java
@@ -62,12 +62,13 @@
}
}
-/* @Test
+ @Test
public void testAndQuery() throws CQLParseException, IOException, QueryException{
query="(Sonne) and (scheint)";
String jsonLd =
- "{@type : korap:group, operation : operation:sequence, distances:[ "+
- "{@type : korap:distance, key : w, min : 0, max : 0 } ],"+
+ "{@type : korap:group, operation : operation:sequence, inOrder : false," +
+ "distances:[ "+
+ "{@type : korap:distance, key : s, min : 0, max : 0 } ],"+
"operands : ["+
"{@type : korap:token, wrap : {@type : korap:term,key : Sonne, layer : orth, match : match:eq}}," +
"{@type : korap:token,wrap : {@type : korap:term,key : scheint,layer : orth,match : match:eq}" +
@@ -76,19 +77,18 @@
CQLTree cqlTree = new CQLTree(query, version);
String serializedQuery = mapper.writeValueAsString(cqlTree.getRequestMap().get("query"));
assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
-
- CosmasTree ct = new CosmasTree("Sonne und scheint");
- serializedQuery = mapper.writeValueAsString(cqlTree.getRequestMap().get("query"));
-
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
- }*/
+// /System.out.println(serializedQuery);
+ //CosmasTree ct = new CosmasTree("Sonne und scheint");
+ //serializedQuery = mapper.writeValueAsString(ct.getRequestMap().get("query"));
+ //assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
+ }
-/* @Test
+ @Test
public void testBooleanQuery() throws CQLParseException, IOException, QueryException{
query="((Sonne) or (Mond)) and (scheint)";
String jsonLd =
- "{@type:korap:group, operation:operation:sequence, distances:[" +
- "{@type:korap:distance, key:w, min:0, max:0}" +
+ "{@type:korap:group, operation:operation:sequence, inOrder : false, distances:[" +
+ "{@type:korap:distance, key:s, min:0, max:0}" +
"], operands:[" +
"{@type:korap:group, operation:operation:or, operands:[" +
"{@type:korap:token, wrap:{@type:korap:term, key:Sonne, layer:orth, match:match:eq}}," +
@@ -103,8 +103,8 @@
query="(scheint) and ((Sonne) or (Mond))";
jsonLd =
- "{@type:korap:group, operation:operation:sequence, distances:[" +
- "{@type:korap:distance, key:w, min:0, max:0}" +
+ "{@type:korap:group, operation:operation:sequence, inOrder : false, distances:[" +
+ "{@type:korap:distance, key:s, min:0, max:0}" +
"], operands:[" +
"{@type:korap:token, wrap:{@type:korap:term, key:scheint, layer:orth, match:match:eq}}," +
"{@type:korap:group, operation:operation:or, operands:[" +
@@ -116,7 +116,7 @@
serializedQuery = mapper.writeValueAsString(cqlTree.getRequestMap().get("query"));
assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
- }*/
+ }
@Test
public void testOrQuery() throws CQLParseException, IOException, QueryException{