Added more tests.
Change-Id: I5dd486602ad60658701f497deda24cfa6ed27c16
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLComplexTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLComplexTest.java
index 093d715..eed5aad 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLComplexTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLComplexTest.java
@@ -121,8 +121,40 @@
+ "{@type:koral:token,wrap:{@type:koral:term,key:Mann,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}"
+ "]}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
+
+ query = "[text=\"Mann\"]([pos=\"NN\"]|[cnx:pos=\"N\"])";
+ jsonLd = "{@type:koral:group,"
+ + "operation:operation:disjunction,"
+ + "operands:[{@type:koral:token,wrap:{@type:koral:term,key:NN,foundry:tt,layer:p,type:type:regex,match:match:eq}},"
+ + "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:cnx,layer:p,type:type:regex,match:match:eq}}"
+ + "]}";
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operands/1", jsonLd);
+ }
- // sequence of groups
+ @Test
+ public void testSequenceOfQueryGroups() throws IOException {
+ query = "(\"blaue\"|\"grüne\")([pos=\"NN\"]|[cnx:pos=\"N\"])";
+ FCSQLQueryProcessorTest.validateNode(query, "/query/@type",
+ "koral:group");
+ FCSQLQueryProcessorTest.validateNode(query, "/query/operation",
+ "operation:sequence");
+
+ jsonLd = "{@type:koral:group,"
+ + "operation:operation:disjunction,"
+ + "operands:["
+ + "{@type:koral:token,wrap:{@type:koral:term,key:blaue,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}},"
+ + "{@type:koral:token,wrap:{@type:koral:term,key:grüne,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}"
+ + "]}";
+ FCSQLQueryProcessorTest
+ .validateNode(query, "/query/operands/0", jsonLd);
+
+ jsonLd = "{@type:koral:group,operation:operation:disjunction,"
+ + "operands:["
+ + "{@type:koral:token,wrap:{@type:koral:term,key:NN,foundry:tt,layer:p,type:type:regex,match:match:eq}},"
+ + "{@type:koral:token,wrap:{@type:koral:term,key:N,foundry:cnx,layer:p,type:type:regex,match:match:eq}}"
+ + "]}";
+ FCSQLQueryProcessorTest
+ .validateNode(query, "/query/operands/1", jsonLd);
}
// | simple-query quantifier /* quatification */
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessorTest.java
index 666bff1..8dc4cf0 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessorTest.java
@@ -199,7 +199,6 @@
jsonLd = "{@type: koral:term, key: sein, foundry: cnx, layer: l, type:type:regex, match: match:eq}";
FCSQLQueryProcessorTest.validateNode(query, "/query/wrap/operands/0",
jsonLd);
-
}
// | expression "&" expression /* and */
@@ -246,6 +245,18 @@
+ "{@type: koral:term, key: VAFIN, foundry: mate, layer: p, type:type:regex, match: match:eq}]}}";
FCSQLQueryProcessorTest.validateNode(query, "/query/wrap/operands/1",
jsonLd);
+ FCSQLQueryProcessorTest.validateNode(query, "/query/wrap/relation",
+ "relation:and");
+
+ query = "[(cnx:lemma=\"sein\" | mate:pos=\"PPOSS\") | mate:pos=\"PPOSS\"]";
+ jsonLd = "{@type: koral:token,"
+ + " wrap: { @type: koral:termGroup,"
+ + "relation: relation:or,"
+ + " operands:["
+ + "{@type: koral:term, key: sein, foundry: cnx, layer: l, type:type:regex, match: match:eq},"
+ + "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:eq}]}}";
+ FCSQLQueryProcessorTest.validateNode(query, "/query/wrap/operands/0",
+ jsonLd);
}
// "!" expression /* not */
@@ -269,9 +280,25 @@
+ "{@type: koral:term, key: sein, foundry: mate, layer: l, type:type:regex, match: match:eq},"
+ "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:ne}]}}";
FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
-
+ }
+
+ @Test
+ public void testNotExpressionGroup() throws JsonProcessingException {
query = "[!(mate:lemma=\"sein\" & mate:pos=\"PPOSS\")]";
- FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
+ jsonLd = "{@type: koral:token,"
+ + " wrap: { "
+ + "@type: koral:termGroup,"
+ + "relation: relation:or,"
+ + " operands:["
+ + "{@type: koral:term, key: sein, foundry: mate, layer: l, type:type:regex, match: match:ne},"
+ + "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:ne}]}}";
+ //FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
+
+ error = getError(new FCSQLQueryProcessor(query, "2.0"));
+ assertEquals(399, error.get(0));
+ assertEquals(
+ "FCS diagnostic 10: Query cannot be parsed, an unexpcected occured exception while parsing",
+ error.get(1));
}
@Test