Removed distances. Empty tokens are treated as normal tokens.
Change-Id: I15d3b8b9bc92f6ffd92fbc545ac371dffc965ef1
diff --git a/src/main/antlr/poliqarpplus/PoliqarpPlusParser.g4 b/src/main/antlr/poliqarpplus/PoliqarpPlusParser.g4
index 571cf12..9a597ca 100644
--- a/src/main/antlr/poliqarpplus/PoliqarpPlusParser.g4
+++ b/src/main/antlr/poliqarpplus/PoliqarpPlusParser.g4
@@ -9,7 +9,9 @@
}
/*
-- author: Joachim Bingel
- -- date: 14-06-27
+ -- date: 06-27-06-2014
+
+ -- updated: 26-10-2016 (margaretha)
Poliqarp Query Language parser
@@ -191,18 +193,16 @@
| submatch
| relation
| LRPAREN segment RRPAREN
+ | emptyTokenSequence
+ | emptyTokenSequenceClass
)
repetition?
;
sequence
-: segment* (emptyTokenSequence|emptyTokenSequenceClass) // ordering important! this subrule must precede any 'distance'-subrules to give precedence to repetition-interpretation of numbers in braces (could be mistaken for number tokens in spanclass), e.g. {2}.
-| (emptyTokenSequence|emptyTokenSequenceClass) (segment+ | sequence) (emptyTokenSequence|emptyTokenSequenceClass)?
-| alignment segment* // give precedence to this subrule over the next to make sure preceding segments come into 'alignment'
+: alignment segment* // give precedence to this subrule over the next to make sure preceding segments come into 'alignment'
| segment+ alignment segment*
-| segment segment+
-| segment (distance|emptyTokenSequenceClass) segment
-| segment (distance|emptyTokenSequenceClass)? sequence
+| segment segment+
//| alignment (segment|sequence) alignment?
;
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/EmptyTokenTest.java b/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/EmptyTokenTest.java
new file mode 100644
index 0000000..ad7873a
--- /dev/null
+++ b/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/EmptyTokenTest.java
@@ -0,0 +1,534 @@
+package de.ids_mannheim.korap.query.test.poliqarpplus;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Lists;
+
+import de.ids_mannheim.korap.query.serialize.QuerySerializer;
+
+/**
+ * Tests for JSON-LD serialization of empty/any tokens in PoliqarpPlus queries.
+ *
+ * @author Joachim Bingel (bingel@ids-mannheim.de)
+ * @author Eliza Margaretha (margaretha@ids-mannheim.de)
+ * @version 1.0
+ */
+
+public class EmptyTokenTest {
+
+ String query;
+ ArrayList<JsonNode> operands;
+
+ QuerySerializer qs = new QuerySerializer();
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode res;
+
+ @Test
+ public void testSingle() throws JsonProcessingException, IOException {
+ query = "[]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:token", res.at("/query/@type").asText());
+ assertEquals(true, res.at("/query/key").isMissingNode());
+ }
+
+ @Test
+ public void testQuantifier () throws JsonProcessingException, IOException {
+ query = "[]{3}";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:repetition",
+ res.at("/query/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+ assertEquals("koral:boundary",
+ res.at("/query/boundary/@type").asText());
+ assertEquals(3, res.at("/query/boundary/min").asInt());
+ assertEquals(3, res.at("/query/boundary/max").asInt());
+
+ query = "[]{1,3}";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:repetition",
+ res.at("/query/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+ assertEquals("koral:boundary",
+ res.at("/query/boundary/@type").asText());
+ assertEquals(1, res.at("/query/boundary/min").asInt());
+ assertEquals(3, res.at("/query/boundary/max").asInt());
+
+
+ query = "[]{ , 3}";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:repetition",
+ res.at("/query/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+ assertEquals("koral:boundary",
+ res.at("/query/boundary/@type").asText());
+ assertEquals(0, res.at("/query/boundary/min").asInt());
+ assertEquals(3, res.at("/query/boundary/max").asInt());
+
+ query = "[]{4,}";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:repetition",
+ res.at("/query/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+ assertEquals("koral:boundary",
+ res.at("/query/boundary/@type").asText());
+ assertEquals(4, res.at("/query/boundary/min").asInt());
+ assertTrue(res.at("/query/boundary/max").isMissingNode());
+ }
+
+
+ @Test
+ public void testLeading1 () throws JsonProcessingException, IOException {
+ query = "[][base=Mann]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals("koral:token", operands.get(0).at("/@type").asText());
+ assertEquals(true, operands.get(0).at("/key").isMissingNode());
+ assertEquals("koral:token", operands.get(1).at("/@type").asText());
+ assertEquals("Mann", operands.get(1).at("/wrap/key").asText());
+
+ query = "[][][base=Mann]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals(2, operands.size());
+ assertEquals("koral:group", operands.get(0).at("/@type").asText());
+ assertEquals("operation:repetition",
+ operands.get(0).at("/operation").asText());
+ assertEquals(2, operands.get(0).at("/boundary/min").asInt());
+ assertEquals(2, operands.get(0).at("/boundary/max").asInt());
+ operands = Lists
+ .newArrayList(operands.get(0).at("/operands").elements());
+ assertEquals("koral:token", operands.get(0).at("/@type").asText());
+ assertEquals(true, operands.get(0).at("/key").isMissingNode());
+ }
+
+
+ @Test
+ public void testLeading2 () throws JsonProcessingException, IOException {
+ query = "[][][base=bose][base=Mann]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals("koral:group", operands.get(0).at("/@type").asText());
+ assertEquals("operation:repetition",
+ operands.get(0).at("/operation").asText());
+ assertEquals(2, operands.get(0).at("/boundary/min").asInt());
+ assertEquals(2, operands.get(0).at("/boundary/max").asInt());
+ assertEquals("koral:token",
+ operands.get(0).at("/operands/0/@type").asText());
+ assertEquals(true,
+ operands.get(0).at("/operands/0/key").isMissingNode());
+ assertEquals("koral:token", operands.get(1).at("/@type").asText());
+ assertEquals("bose", operands.get(1).at("/wrap/key").asText());
+ assertEquals("koral:token", operands.get(2).at("/@type").asText());
+ assertEquals("Mann", operands.get(2).at("/wrap/key").asText());
+ }
+
+
+ @Test
+ public void testTrailing () throws JsonProcessingException, IOException {
+ query = "[base=Mann][]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals("koral:token", operands.get(1).at("/@type").asText());
+ assertEquals(true, operands.get(1).at("/key").isMissingNode());
+
+ query = "[base=Mann][]{3}";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ res = operands.get(1);
+ assertEquals("koral:group", res.at("/@type").asText());
+ assertEquals(true, res.at("/wrap/key").isMissingNode());
+ assertEquals("operation:repetition", res.at("/operation").asText());
+ assertEquals(3, res.at("/boundary/min").asInt());
+ assertEquals(3, res.at("/boundary/max").asInt());
+
+ query = "[base=der][base=Mann][]{3}";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals(3, operands.size());
+ assertEquals("koral:token", operands.get(0).at("/@type").asText());
+ assertEquals("der", operands.get(0).at("/wrap/key").asText());
+ assertEquals("koral:token", operands.get(1).at("/@type").asText());
+ assertEquals("Mann", operands.get(1).at("/wrap/key").asText());
+ }
+
+
+ @Test
+ public void testBetweenTokens1 ()
+ throws JsonProcessingException, IOException {
+ query = "[base=der][][base=Mann]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals(3, operands.size());
+ assertEquals("koral:token", operands.get(0).at("/@type").asText());
+ assertEquals("der", operands.get(0).at("/wrap/key").asText());
+ assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
+ assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
+ assertEquals("koral:token", operands.get(1).at("/@type").asText());
+ assertEquals(true, operands.get(1).at("/wrap/key").isMissingNode());
+ assertEquals("koral:token", operands.get(2).at("/@type").asText());
+ assertEquals("Mann", operands.get(2).at("/wrap/key").asText());
+ assertEquals("lemma", operands.get(2).at("/wrap/layer").asText());
+ assertEquals("match:eq", operands.get(2).at("/wrap/match").asText());
+ }
+
+
+ @Test
+ public void testBetweenTokens2 ()
+ throws JsonProcessingException, IOException {
+ query = "[base=der][][][base=Mann]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals(3, operands.size());
+ assertEquals("koral:group", operands.get(1).at("/@type").asText());
+ assertEquals("operation:repetition",
+ operands.get(1).at("/operation").asText());
+ assertEquals("koral:boundary",
+ operands.get(1).at("/boundary/@type").asText());
+ assertEquals(2, operands.get(1).at("/boundary/min").asInt());
+ assertEquals(2, operands.get(1).at("/boundary/max").asInt());
+ operands = Lists
+ .newArrayList(operands.get(1).at("/operands").elements());
+ assertEquals(1, operands.size());
+ assertEquals("koral:token", operands.get(0).at("/@type").asText());
+ assertEquals(true, operands.get(0).at("/wrap/key").isMissingNode());
+
+ }
+
+
+ @Test
+ public void testQuantifierBetweenTokens1 ()
+ throws JsonProcessingException, IOException {
+ query = "[base=der][][]?[base=Mann]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals(3, operands.size());
+ assertEquals("koral:group", operands.get(1).at("/@type").asText());
+ assertEquals("operation:repetition",
+ operands.get(1).at("/operation").asText());
+ assertEquals("koral:boundary",
+ operands.get(1).at("/boundary/@type").asText());
+ assertEquals(1, operands.get(1).at("/boundary/min").asInt());
+ assertEquals(2, operands.get(1).at("/boundary/max").asInt());
+ operands = Lists
+ .newArrayList(operands.get(1).at("/operands").elements());
+ assertEquals(1, operands.size());
+ assertEquals("koral:token", operands.get(0).at("/@type").asText());
+ assertEquals(true, operands.get(0).at("/wrap/key").isMissingNode());
+ }
+
+
+ @Test
+ public void testQuantifierBetweenTokens2 ()
+ throws JsonProcessingException, IOException {
+ query = "[base=der][]+[base=Mann]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals(3, operands.size());
+ assertEquals("koral:group", operands.get(1).at("/@type").asText());
+ assertEquals("operation:repetition",
+ operands.get(1).at("/operation").asText());
+ assertEquals("koral:boundary",
+ operands.get(1).at("/boundary/@type").asText());
+ assertEquals(1, operands.get(1).at("/boundary/min").asInt());
+ assertEquals(true, operands.get(1).at("/boundary/max").isMissingNode());
+ operands = Lists
+ .newArrayList(operands.get(1).at("/operands").elements());
+ assertEquals(1, operands.size());
+ assertEquals("koral:token", operands.get(0).at("/@type").asText());
+ assertEquals(true, operands.get(0).at("/wrap/key").isMissingNode());
+ }
+
+
+ @Test
+ public void testQuantifierBetweenTokens3 ()
+ throws JsonProcessingException, IOException {
+
+ query = "[base=der][]*[base=Mann]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals(3, operands.size());
+ assertEquals("koral:group", operands.get(1).at("/@type").asText());
+ assertEquals("operation:repetition",
+ operands.get(1).at("/operation").asText());
+ assertEquals("koral:boundary",
+ operands.get(1).at("/boundary/@type").asText());
+ assertEquals(0, operands.get(1).at("/boundary/min").asInt());
+ assertEquals(true, operands.get(1).at("/boundary/max").isMissingNode());
+ operands = Lists
+ .newArrayList(operands.get(1).at("/operands").elements());
+ assertEquals(1, operands.size());
+ assertEquals("koral:token", operands.get(0).at("/@type").asText());
+ assertEquals(true, operands.get(0).at("/wrap/key").isMissingNode());
+ }
+
+
+ @Test
+ public void testQuantifierBetweenTokens4 ()
+ throws JsonProcessingException, IOException {
+ query = "[base=der][]{2,5}[base=Mann][]?[][base=Frau]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals(5, operands.size());
+ assertEquals("koral:token", operands.get(0).at("/@type").asText());
+ assertEquals("der", operands.get(0).at("/wrap/key").asText());
+
+ assertEquals("koral:group", operands.get(1).at("/@type").asText());
+ assertEquals("operation:repetition",
+ operands.get(1).at("/operation").asText());
+ assertEquals("koral:boundary",
+ operands.get(1).at("/boundary/@type").asText());
+ assertEquals(2, operands.get(1).at("/boundary/min").asInt());
+ assertEquals(5, operands.get(1).at("/boundary/max").asInt());
+ assertEquals("koral:token",
+ operands.get(1).at("/operands/0/@type").asText());
+ assertEquals(true,
+ operands.get(1).at("/operands/0/wrap/key").isMissingNode());
+
+ assertEquals("koral:token", operands.get(2).at("/@type").asText());
+ assertEquals("Mann", operands.get(2).at("/wrap/key").asText());
+
+ assertEquals("koral:group", operands.get(3).at("/@type").asText());
+ assertEquals("operation:repetition",
+ operands.get(3).at("/operation").asText());
+ assertEquals("koral:boundary",
+ operands.get(3).at("/boundary/@type").asText());
+ assertEquals(1, operands.get(3).at("/boundary/min").asInt());
+ assertEquals(2, operands.get(3).at("/boundary/max").asInt());
+ assertEquals("koral:token",
+ operands.get(3).at("/operands/0/@type").asText());
+ assertEquals(true,
+ operands.get(3).at("/operands/0/wrap/key").isMissingNode());
+
+ assertEquals("koral:token", operands.get(4).at("/@type").asText());
+ assertEquals("Frau", operands.get(4).at("/wrap/key").asText());
+ }
+
+
+ @Test
+ public void testQuantifierBetweenTokens5 ()
+ throws JsonProcessingException, IOException {
+ query = "[base=geht][base=der][]*contains(<s>,<np>)";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ assertEquals(true, res.at("/query/inOrder").isMissingNode());
+ assertEquals(true, res.at("/query/distances").isMissingNode());
+
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals(4, operands.size());
+
+ assertEquals("koral:token", operands.get(0).at("/@type").asText());
+ assertEquals("geht", operands.get(0).at("/wrap/key").asText());
+ assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
+ assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
+
+ assertEquals("koral:token", operands.get(1).at("/@type").asText());
+ assertEquals("der", operands.get(1).at("/wrap/key").asText());
+ assertEquals("lemma", operands.get(1).at("/wrap/layer").asText());
+ assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
+
+ assertEquals("koral:group", operands.get(2).at("/@type").asText());
+ assertEquals("operation:repetition",
+ operands.get(2).at("/operation").asText());
+ assertEquals("koral:token",
+ operands.get(2).at("/operands/0/@type").asText());
+ assertEquals("koral:boundary",
+ operands.get(2).at("/boundary/@type").asText());
+ assertEquals(0, operands.get(2).at("/boundary/min").asInt());
+ assertEquals(true, operands.get(2).at("/boundary/max").isMissingNode());
+
+ assertEquals("koral:group", operands.get(3).at("/@type").asText());
+ assertEquals("operation:position",
+ operands.get(3).at("/operation").asText());
+ assertEquals("frames:isAround",
+ operands.get(3).at("/frames/0").asText());
+ assertEquals("koral:span",
+ operands.get(3).at("/operands/0/@type").asText());
+ assertEquals("s", operands.get(3).at("/operands/0/wrap/key").asText());
+ assertEquals("koral:span",
+ operands.get(3).at("/operands/1/@type").asText());
+ assertEquals("np", operands.get(3).at("/operands/1/wrap/key").asText());
+ }
+
+ @Test
+ public void testPositionInSpans () throws JsonProcessingException, IOException {
+ query = "contains(<s>, [])";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:position", res.at("/query/operation").asText());
+ assertEquals("frames:isAround", res.at("/query/frames/0").asText());
+ assertEquals(true, res.at("/query/frames/1").isMissingNode());
+ assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
+ assertEquals("s", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("koral:token", res.at("/query/operands/1/@type").asText());
+ assertEquals(true, res.at("/query/operands/1/key").isMissingNode());
+
+ query = "contains(<s>, []{3})";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("s", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
+ assertEquals("operation:repetition",
+ res.at("/query/operands/1/operation").asText());
+ assertEquals("koral:token",
+ res.at("/query/operands/1/operands/0/@type").asText());
+ assertEquals(true,
+ res.at("/query/operands/1/operands/0/key").isMissingNode());
+
+ query = "contains(<s>, {1:[]{3}})";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("s", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
+ assertEquals("operation:class",
+ res.at("/query/operands/1/operation").asText());
+ assertEquals("operation:repetition",
+ res.at("/query/operands/1/operands/0/operation").asText());
+ assertEquals("koral:token", res
+ .at("/query/operands/1/operands/0/operands/0/@type").asText());
+ assertEquals(true, res.at("/query/operands/1/operands/0/operands/0/key")
+ .isMissingNode());
+
+ query = "startswith(<s>, [][base=Mann])";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:position", res.at("/query/operation").asText());
+ assertEquals("frames:startsWith", res.at("/query/frames/0").asText());
+ operands = Lists.newArrayList(res.at("/query/operands"));
+ operands = Lists.newArrayList(operands.get(1).at("/operands"));
+ assertEquals("koral:token", operands.get(0).at("/@type").asText());
+ assertEquals(true, operands.get(0).at("/key").isMissingNode());
+ }
+
+ @Test
+ public void testClass1 () throws JsonProcessingException, IOException {
+ query = "[base=der]{[]}[base=Mann]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("koral:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ assertEquals(true, res.at("/query/inOrder").isMissingNode());
+ assertEquals(true, res.at("/query/distances").isMissingNode());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals("der", operands.get(0).at("/wrap/key").asText());
+ assertEquals("Mann", operands.get(2).at("/wrap/key").asText());
+ assertEquals("koral:group", operands.get(1).at("/@type").asText());
+ assertEquals("operation:class",
+ operands.get(1).at("/operation").asText());
+ assertEquals(1, operands.get(1).at("/classOut").asInt());
+ operands = Lists
+ .newArrayList(operands.get(1).at("/operands").elements());
+ assertEquals("koral:token", operands.get(0).at("/@type").asText());
+ assertEquals(true, operands.get(0).at("/wrap").isMissingNode());
+ assertEquals(1, res.at("/meta/highlight/0").asInt());
+ }
+
+
+ @Test
+ public void testClass2 () throws JsonProcessingException, IOException {
+ query = "[base=der]{2:[]}[base=Mann]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals("operation:class",
+ operands.get(1).at("/operation").asText());
+ assertEquals(2, operands.get(1).at("/classOut").asInt());
+ assertEquals(2, res.at("/meta/highlight/0").asInt());
+ }
+
+
+ @Test
+ public void testClass3 () throws JsonProcessingException, IOException {
+ query = "[base=der]{3:{2:[]}}";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals("operation:class",
+ operands.get(1).at("/operation").asText());
+ assertEquals(3, operands.get(1).at("/classOut").asInt());
+ assertEquals(3, res.at("/meta/highlight/0").asInt());
+ assertEquals("operation:class",
+ operands.get(1).at("/operands/0/operation").asText());
+ assertEquals(2, operands.get(1).at("/operands/0/classOut").asInt());
+ assertEquals(3, res.at("/meta/highlight/0").asInt());
+ assertEquals(2, res.at("/meta/highlight/1").asInt());
+
+ }
+
+
+ @Test
+ public void testClass4 () throws JsonProcessingException, IOException {
+ query = "{1:[]}[base=der][base=Mann]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals("operation:class",
+ operands.get(0).at("/operation").asText());
+ assertEquals(1, operands.get(0).at("/classOut").asInt());
+ assertEquals(1, res.at("/meta/highlight/0").asInt());
+
+ query = "{1:{2:der} {3:[]} Mann}";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ operands = Lists.newArrayList(res.at("/query/operands").elements());
+ assertEquals(1, operands.size()); // class operation may only have one operand (the sequence)
+ operands = Lists
+ .newArrayList(operands.get(0).at("/operands").elements());
+ assertEquals(3, operands.size()); // the sequence has three operands ("der", "[]" and "Mann")
+ assertEquals(1, res.at("/meta/highlight/0").asInt());
+ assertEquals(2, res.at("/meta/highlight/1").asInt());
+ assertEquals(3, res.at("/meta/highlight/2").asInt());
+ }
+}
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PoliqarpPlusQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PoliqarpPlusQueryProcessorTest.java
index 167ee0e..6205444 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PoliqarpPlusQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/poliqarpplus/PoliqarpPlusQueryProcessorTest.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.query.serialize;
+package de.ids_mannheim.korap.query.test.poliqarpplus;
import static org.junit.Assert.*;
@@ -391,477 +391,11 @@
}
- @Test
- public void testDistances () throws JsonProcessingException, IOException {
- query = "[base=der][][base=Mann]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("true", res.at("/query/inOrder").asText());
- assertEquals("koral:distance", res.at("/query/distances").elements()
- .next().at("/@type").asText());
- assertEquals("w",
- res.at("/query/distances").elements().next().at("/key")
- .asText());
- assertEquals("koral:boundary", res.at("/query/distances").elements()
- .next().at("/boundary/@type").asText());
- assertEquals(1,
- res.at("/query/distances").elements().next()
- .at("/boundary/min").asInt());
- assertEquals(1,
- res.at("/query/distances").elements().next()
- .at("/boundary/max").asInt());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals("der", operands.get(0).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
- assertEquals("koral:token", operands.get(1).at("/@type").asText());
- assertEquals("Mann", operands.get(1).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(1).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
-
- query = "[base=der][][][base=Mann]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("true", res.at("/query/inOrder").asText());
- assertEquals("koral:distance", res.at("/query/distances").elements()
- .next().at("/@type").asText());
- assertEquals("w",
- res.at("/query/distances").elements().next().at("/key")
- .asText());
- assertEquals("koral:boundary", res.at("/query/distances").elements()
- .next().at("/boundary/@type").asText());
- assertEquals(2,
- res.at("/query/distances").elements().next()
- .at("/boundary/min").asInt());
- assertEquals(2,
- res.at("/query/distances").elements().next()
- .at("/boundary/max").asInt());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals("der", operands.get(0).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
- assertEquals("koral:token", operands.get(1).at("/@type").asText());
- assertEquals("Mann", operands.get(1).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(1).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
-
- query = "[base=der][][]?[base=Mann]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("true", res.at("/query/inOrder").asText());
- assertEquals("koral:distance", res.at("/query/distances").elements()
- .next().at("/@type").asText());
- assertEquals("w",
- res.at("/query/distances").elements().next().at("/key")
- .asText());
- assertEquals("koral:boundary", res.at("/query/distances").elements()
- .next().at("/boundary/@type").asText());
- assertEquals(1,
- res.at("/query/distances").elements().next()
- .at("/boundary/min").asInt());
- assertEquals(2,
- res.at("/query/distances").elements().next()
- .at("/boundary/max").asInt());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals("der", operands.get(0).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
- assertEquals("koral:token", operands.get(1).at("/@type").asText());
- assertEquals("Mann", operands.get(1).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(1).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
-
- query = "[base=der][]+[base=Mann]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("true", res.at("/query/inOrder").asText());
- assertEquals("koral:distance", res.at("/query/distances").elements()
- .next().at("/@type").asText());
- assertEquals("w",
- res.at("/query/distances").elements().next().at("/key")
- .asText());
- assertEquals("koral:boundary", res.at("/query/distances").elements()
- .next().at("/boundary/@type").asText());
- assertEquals(1,
- res.at("/query/distances").elements().next()
- .at("/boundary/min").asInt());
- assertEquals(true,
- res.at("/query/distances").elements().next()
- .at("/boundary/max").isMissingNode());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals("der", operands.get(0).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
- assertEquals("koral:token", operands.get(1).at("/@type").asText());
- assertEquals("Mann", operands.get(1).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(1).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
-
- query = "[base=der][]*[base=Mann]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("true", res.at("/query/inOrder").asText());
- assertEquals("koral:distance", res.at("/query/distances").elements()
- .next().at("/@type").asText());
- assertEquals("w",
- res.at("/query/distances").elements().next().at("/key")
- .asText());
- assertEquals("koral:boundary", res.at("/query/distances").elements()
- .next().at("/boundary/@type").asText());
- assertEquals(0,
- res.at("/query/distances").elements().next()
- .at("/boundary/min").asInt());
- assertEquals(true,
- res.at("/query/distances").elements().next()
- .at("/boundary/max").isMissingNode());
-
- query = "[base=der][]{2,5}[base=Mann][]?[][base=Frau]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals("true", res.at("/query/inOrder").asText());
- assertEquals("koral:distance", res.at("/query/distances").elements()
- .next().at("/@type").asText());
- assertEquals("w",
- res.at("/query/distances").elements().next().at("/key")
- .asText());
- assertEquals("koral:boundary", res.at("/query/distances").elements()
- .next().at("/boundary/@type").asText());
- assertEquals(2,
- res.at("/query/distances").elements().next()
- .at("/boundary/min").asInt());
- assertEquals(5,
- res.at("/query/distances").elements().next()
- .at("/boundary/max").asInt());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals("der", operands.get(0).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
- assertEquals("koral:group", operands.get(1).at("/@type").asText());
- assertEquals("operation:sequence", operands.get(1).at("/operation")
- .asText());
- assertEquals("koral:distance", operands.get(1).get("distances")
- .elements().next().at("/@type").asText());
- assertEquals("w", operands.get(1).get("distances").elements().next()
- .at("/key").asText());
- assertEquals("koral:boundary", operands.get(1).get("distances")
- .elements().next().at("/boundary/@type").asText());
- assertEquals(
- 1,
- operands.get(1).get("distances").elements().next()
- .at("/boundary/min").asInt());
- assertEquals(
- 2,
- operands.get(1).get("distances").elements().next()
- .at("/boundary/max").asInt());
- operands = Lists.newArrayList(operands.get(1).get("operands")
- .elements());
- assertEquals("Mann", operands.get(0).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
- assertEquals("Frau", operands.get(1).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(1).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(1).at("/wrap/match").asText());
-
- query = "[base=geht][base=der][]*contains(<s>,<np>)";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals(true, res.at("/query/inOrder").isMissingNode());
- assertEquals(true, res.at("/query/distances").isMissingNode());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals("geht", operands.get(0).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
- assertEquals("koral:group", operands.get(1).at("/@type").asText());
- assertEquals("operation:sequence", operands.get(1).at("/operation")
- .asText());
- assertEquals("koral:distance", operands.get(1).get("distances")
- .elements().next().at("/@type").asText());
- assertEquals("w", operands.get(1).get("distances").elements().next()
- .at("/key").asText());
- assertEquals("koral:boundary", operands.get(1).get("distances")
- .elements().next().at("/boundary/@type").asText());
- assertEquals(
- 0,
- operands.get(1).get("distances").elements().next()
- .at("/boundary/min").asInt());
- assertEquals(true, operands.get(1).get("distances").elements().next()
- .at("/boundary/max").isMissingNode());
- operands = Lists.newArrayList(operands.get(1).get("operands")
- .elements());
- assertEquals("der", operands.get(0).at("/wrap/key").asText());
- assertEquals("lemma", operands.get(0).at("/wrap/layer").asText());
- assertEquals("match:eq", operands.get(0).at("/wrap/match").asText());
- assertEquals("koral:group", operands.get(1).at("/@type").asText());
- assertEquals("operation:position", operands.get(1).at("/operation")
- .asText());
- }
+
- @Test
- public void testDistancesWithClass () throws JsonProcessingException,
- IOException {
- query = "[base=der]{[]}[base=Mann]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:sequence", res.at("/query/operation").asText());
- assertEquals(true, res.at("/query/inOrder").isMissingNode());
- assertEquals(true, res.at("/query/distances").isMissingNode());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("der", operands.get(0).at("/wrap/key").asText());
- assertEquals("Mann", operands.get(2).at("/wrap/key").asText());
- assertEquals("koral:group", operands.get(1).at("/@type").asText());
- assertEquals("operation:class", operands.get(1).at("/operation")
- .asText());
- assertEquals(1, operands.get(1).at("/classOut").asInt());
- operands = Lists.newArrayList(operands.get(1).at("/operands")
- .elements());
- assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals(true, operands.get(0).at("/wrap").isMissingNode());
- assertEquals(1, res.at("/meta/highlight/0").asInt());
-
- query = "[base=der]{2:[]}[base=Mann]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("operation:class", operands.get(1).at("/operation")
- .asText());
- assertEquals(2, operands.get(1).at("/classOut").asInt());
- assertEquals(2, res.at("/meta/highlight/0").asInt());
-
- query = "[base=der]{3:{2:[]}}";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("operation:class", operands.get(1).at("/operation")
- .asText());
- assertEquals(3, operands.get(1).at("/classOut").asInt());
- assertEquals(3, res.at("/meta/highlight/0").asInt());
- assertEquals("operation:class",
- operands.get(1).at("/operands/0/operation").asText());
- assertEquals(2, operands.get(1).at("/operands/0/classOut").asInt());
- assertEquals(3, res.at("/meta/highlight/0").asInt());
- assertEquals(2, res.at("/meta/highlight/1").asInt());
-
-
- query = "{1:[]}[base=der][base=Mann]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("operation:class", operands.get(0).at("/operation")
- .asText());
- assertEquals(1, operands.get(0).at("/classOut").asInt());
- assertEquals(1, res.at("/meta/highlight/0").asInt());
-
- query = "{1:{2:der} {3:[]} Mann}";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals(1, operands.size()); // class operation may only have one operand (the sequence)
- operands = Lists.newArrayList(operands.get(0).at("/operands")
- .elements());
- assertEquals(3, operands.size()); // the sequence has three operands ("der", "[]" and "Mann")
- assertEquals(1, res.at("/meta/highlight/0").asInt());
- assertEquals(2, res.at("/meta/highlight/1").asInt());
- assertEquals(3, res.at("/meta/highlight/2").asInt());
- }
-
-
- @Test
- public void testEmptyTokens () throws JsonProcessingException, IOException {
- query = "[]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- assertEquals("koral:token", res.at("/query/@type").asText());
- assertEquals(true, res.at("/query/key").isMissingNode());
-
- query = "contains(<s>, [])";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- assertEquals("koral:group", res.at("/query/@type").asText());
- assertEquals("operation:position", res.at("/query/operation").asText());
- assertEquals("frames:isAround", res.at("/query/frames/0").asText());
- assertEquals(true, res.at("/query/frames/1").isMissingNode());
- assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
- assertEquals("s", res.at("/query/operands/0/wrap/key").asText());
- assertEquals("koral:token", res.at("/query/operands/1/@type").asText());
- assertEquals(true, res.at("/query/operands/1/key").isMissingNode());
-
- query = "contains(<s>, []{3})";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- assertEquals("s", res.at("/query/operands/0/wrap/key").asText());
- assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
- assertEquals("operation:repetition",
- res.at("/query/operands/1/operation").asText());
- assertEquals("koral:token", res
- .at("/query/operands/1/operands/0/@type").asText());
- assertEquals(true, res.at("/query/operands/1/operands/0/key")
- .isMissingNode());
-
- query = "contains(<s>, {1:[]{3}})";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- assertEquals("s", res.at("/query/operands/0/wrap/key").asText());
- assertEquals("koral:group", res.at("/query/operands/1/@type").asText());
- assertEquals("operation:class", res.at("/query/operands/1/operation")
- .asText());
- assertEquals("operation:repetition",
- res.at("/query/operands/1/operands/0/operation").asText());
- assertEquals("koral:token",
- res.at("/query/operands/1/operands/0/operands/0/@type")
- .asText());
- assertEquals(true, res
- .at("/query/operands/1/operands/0/operands/0/key")
- .isMissingNode());
-
- }
-
-
- @Test
- public void testEmptyTokenSequence () throws JsonProcessingException, IOException {
- query = "[]{3}";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
-
- assertEquals("koral:group",
- res.at("/query/@type").asText());
- assertEquals("operation:repetition",
- res.at("/query/operation").asText());
- assertEquals("koral:token",
- res.at("/query/operands/0/@type").asText());
- assertEquals("koral:boundary",
- res.at("/query/boundary/@type").asText());
- assertEquals(3,
- res.at("/query/boundary/min").asInt());
- assertEquals(3,
- res.at("/query/boundary/max").asInt());
-
- query = "[]{1,3}";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
-
- assertEquals("koral:group",
- res.at("/query/@type").asText());
- assertEquals("operation:repetition",
- res.at("/query/operation").asText());
- assertEquals("koral:token",
- res.at("/query/operands/0/@type").asText());
- assertEquals("koral:boundary",
- res.at("/query/boundary/@type").asText());
- assertEquals(1,
- res.at("/query/boundary/min").asInt());
- assertEquals(3,
- res.at("/query/boundary/max").asInt());
-
-
- query = "[]{ , 3}";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
-
- assertEquals("koral:group",
- res.at("/query/@type").asText());
- assertEquals("operation:repetition",
- res.at("/query/operation").asText());
- assertEquals("koral:token",
- res.at("/query/operands/0/@type").asText());
- assertEquals("koral:boundary",
- res.at("/query/boundary/@type").asText());
- assertEquals(0,
- res.at("/query/boundary/min").asInt());
- assertEquals(3,
- res.at("/query/boundary/max").asInt());
-
- query = "[]{4,}";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
-
- assertEquals("koral:group",
- res.at("/query/@type").asText());
- assertEquals("operation:repetition",
- res.at("/query/operation").asText());
- assertEquals("koral:token",
- res.at("/query/operands/0/@type").asText());
- assertEquals("koral:boundary",
- res.at("/query/boundary/@type").asText());
- assertEquals(4,
- res.at("/query/boundary/min").asInt());
- assertTrue(res.at("/query/boundary/max").isMissingNode());
- }
-
-
- @Test
- public void testLeadingTrailingEmptyTokens ()
- throws JsonProcessingException, IOException {
- query = "[][base=Mann]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals(true, operands.get(0).at("/key").isMissingNode());
-
- query = "[][][base=Mann]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("koral:group", operands.get(0).at("/@type").asText());
- assertEquals("operation:repetition", operands.get(0).at("/operation")
- .asText());
- assertEquals(2, operands.get(0).at("/boundary/min").asInt());
- assertEquals(2, operands.get(0).at("/boundary/max").asInt());
- operands = Lists.newArrayList(operands.get(0).at("/operands")
- .elements());
- assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals(true, operands.get(0).at("/key").isMissingNode());
-
- query = "[base=Mann][]";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- assertEquals("koral:token", operands.get(1).at("/@type").asText());
- assertEquals(true, operands.get(1).at("/key").isMissingNode());
-
- query = "[base=Mann][]{3}";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- operands = Lists.newArrayList(res.at("/query/operands").elements());
- res = operands.get(1);
- assertEquals("koral:group", res.at("/@type").asText());
- assertEquals(true, res.at("/key").isMissingNode());
- assertEquals("operation:repetition", res.at("/operation").asText());
- assertEquals(3, res.at("/boundary/min").asInt());
- assertEquals(3, res.at("/boundary/max").asInt());
-
- query = "startswith(<s>, [][base=Mann])";
- qs.setQuery(query, "poliqarpplus");
- res = mapper.readTree(qs.toJSON());
- operands = Lists.newArrayList(res.at("/query/operands"));
- operands = Lists.newArrayList(operands.get(1).at("/operands"));
- assertEquals("koral:token", operands.get(0).at("/@type").asText());
- assertEquals(true, operands.get(0).at("/key").isMissingNode());
- }
-
-
+
+
@Test
public void testRepetition () throws JsonProcessingException, IOException {
query = "der{3}";