add quote to distance,
update CQLTest
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 b58d3b2..92f74e5 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
@@ -116,7 +116,7 @@
checkBooleanModifier(node);
sb.append("{\"@type\":\"korap:group\", \"operation\":");
sb.append(OPERATION_SEQUENCE);
- sb.append(", distances:[{\"@type\":\"korap:distance\", \"key\":\"t\"," +
+ sb.append(", \"distances\":[{\"@type\":\"korap:distance\", \"key\":\"t\"," +
" \"min\":0, \"max\":0}]");
sb.append(", \"operands\":[");
parseCQLNode(node.getLeftOperand());
diff --git a/src/test/java/CQLTest.java b/src/test/java/CQLTest.java
index d9dba01..df48e52 100644
--- a/src/test/java/CQLTest.java
+++ b/src/test/java/CQLTest.java
@@ -17,34 +17,34 @@
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=t, 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}}," +
- "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
+ "{@type:korap:group, operation:operation:sequence, distances:[" +
+ "{@type:korap:distance, key:t, 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}}," +
+ "{@type:korap:token, wrap:{@type:korap:term, key:Mond, layer:orth, match:match:eq}}" +
"]}," +
- "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
+ "{@type:korap:token, wrap:{@type:korap:term, key:scheint, layer:orth, match:match:eq}}" +
"]}";
CQLTree cqlTree = new CQLTree(query, version);
String serializedQuery = cqlTree.getRequestMap().get("query").toString();
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
+ assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
query="(scheint) and ((Sonne) or (Mond))";
jsonLd =
- "{@type=korap:group, operation=operation:sequence, distances=[" +
- "{@type=korap:distance, key=t, 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=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
- "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
+ "{@type:korap:group, operation:operation:sequence, distances:[" +
+ "{@type:korap:distance, key:t, 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:[" +
+ "{@type:korap:token, wrap:{@type:korap:term, key:Sonne, layer:orth, match:match:eq}}," +
+ "{@type:korap:token, wrap:{@type:korap:term, key:Mond, layer:orth, match:match:eq}}" +
"]}" +
"]}";
cqlTree = new CQLTree(query, version);
serializedQuery = cqlTree.getRequestMap().get("query").toString();
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
+ assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
}
@@ -52,79 +52,79 @@
public void testOrQuery() throws CQLParseException, IOException, QueryException{
query = "(Sonne) or (Mond)";
String jsonLd =
- "{@type=korap:group, operation=operation:or, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}," +
- "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
+ "{@type:korap:group, operation:operation:or, operands:[" +
+ "{@type:korap:token, wrap:{@type:korap:term, key:Sonne, layer:orth, match:match:eq}}," +
+ "{@type:korap:token, wrap:{@type:korap:term, key:Mond, layer:orth, match:match:eq}}" +
"]}";
CQLTree cqlTree = new CQLTree(query, version);
String serializedQuery = cqlTree.getRequestMap().get("query").toString();
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
+ assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
query="(\"Sonne scheint\") or (Mond)";
jsonLd =
- "{@type=korap:group, operation=operation:or, operands=[" +
- "{@type=korap:group, operation=operation:sequence, 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}}" +
+ "{@type:korap:group, operation:operation:or, operands:[" +
+ "{@type:korap:group, operation:operation:sequence, 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}}" +
"]}," +
- "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
+ "{@type:korap:token, wrap:{@type:korap:term, key:Mond, layer:orth, match:match:eq}}" +
"]}";
cqlTree = new CQLTree(query, version);
serializedQuery = cqlTree.getRequestMap().get("query").toString();
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
+ assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
query="(\"Sonne scheint\") or (\"Mond scheint\")";
jsonLd =
- "{@type=korap:group, operation=operation:or, operands=[" +
- "{@type=korap:group, operation=operation:sequence, 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}}" +
+ "{@type:korap:group, operation:operation:or, operands:[" +
+ "{@type:korap:group, operation:operation:sequence, 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}}" +
"]}," +
- "{@type=korap:group, operation=operation:sequence, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}," +
- "{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
+ "{@type:korap:group, operation:operation:sequence, operands:[" +
+ "{@type:korap:token, wrap:{@type:korap:term, key:Mond, layer:orth, match:match:eq}}," +
+ "{@type:korap:token, wrap:{@type:korap:term, key:scheint, layer:orth, match:match:eq}}" +
"]}" +
"]}";
cqlTree = new CQLTree(query, version);
serializedQuery = cqlTree.getRequestMap().get("query").toString();
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
+ assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
}
@Test
public void testTermQuery() throws CQLParseException, IOException, QueryException{
query = "Sonne";
- String jsonLd = "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}";
+ String jsonLd = "{@type:korap:token, wrap:{@type:korap:term, key:Sonne, layer:orth, match:match:eq}}";
CQLTree cqlTree = new CQLTree(query, version);
String serializedQuery = cqlTree.getRequestMap().get("query").toString();
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
+ assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
}
@Test
public void testPhraseQuery() throws CQLParseException, IOException, QueryException{
query="\"der Mann\"";
String jsonLd =
- "{@type=korap:group, operation=operation:sequence, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
- "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
- "]}";
+ "{@type:korap:group, operation:operation:sequence, operands:[" +
+ "{@type:korap:token, wrap:{@type:korap:term, key:der, layer:orth, match:match:eq}}," +
+ "{@type:korap:token, wrap:{@type:korap:term, key:Mann, layer:orth, match:match:eq}}" +
+ "]}";
CQLTree cqlTree = new CQLTree(query, version);
String serializedQuery = cqlTree.getRequestMap().get("query").toString();
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
+ assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
query="der Mann schläft";
jsonLd =
- "{@type=korap:group, operation=operation:sequence, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=der, layer=orth, match=match:eq}}," +
- "{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}," +
- "{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}" +
- "]}";
+ "{@type:korap:group, operation:operation:sequence, operands:[" +
+ "{@type:korap:token, wrap:{@type:korap:term, key:der, layer:orth, match:match:eq}}," +
+ "{@type:korap:token, wrap:{@type:korap:term, key:Mann, layer:orth, match:match:eq}}," +
+ "{@type:korap:token, wrap:{@type:korap:term, key:schläft, layer:orth, match:match:eq}}" +
+ "]}";
cqlTree = new CQLTree(query, version);
serializedQuery = cqlTree.getRequestMap().get("query").toString();
- assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
+ assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
}
}