fixed quantified sequences embedded in sequences
diff --git a/src/test/java/MetaQuerySerializationTest.java b/src/test/java/MetaQuerySerializationTest.java
index f0a5392..fc389b8 100644
--- a/src/test/java/MetaQuerySerializationTest.java
+++ b/src/test/java/MetaQuerySerializationTest.java
@@ -50,7 +50,7 @@
b.append("author:Goethe");
MetaQuery query = new MetaQuery().addMetaFilter(b.toString());
// System.out.println("value until/since : " + query.stringify());
- Assert.assertEquals("[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:group\",\"relation\":\"and\",\"operands\":[{\"@type\":\"korap:term\",\"@field\":\"korap:field#author\",\"@value\":\"Goethe\"},{\"@type\":\"korap:group\",\"@field\":\"korap:field#pubDate\",\"relation\":\"between\",\"operands\":[{\"@type\":\"korap:date\",\"@value\":\"2013-12-09\"},{\"@type\":\"korap:date\",\"@value\":\"2013-12-09\"}]}]}}]", query.stringify());
+ Assert.assertEquals("[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:group\",\"relation\":\"and\",\"operands\":[{\"@type\":\"korap:term\",\"@field\":\"korap:field#author\",\"@value\":\"Goethe\"},{\"@type\":\"korap:group\",\"@field\":\"korap:field#pubDate\",\"relation\":\"between\",\"operands\":[{\"@type\":\"korap:date\",\"@value\":\"2013-12-10\"},{\"@type\":\"korap:date\",\"@value\":\"2013-12-10\"}]}]}}]", query.stringify());
// System.out.println();
}
@@ -62,7 +62,7 @@
b.append("author:Hesse");
MetaQuery query = new MetaQuery().addMetaFilter(b.toString());
System.out.println("Running date check (until) with additional attribute author");
- Assert.assertEquals("[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:group\",\"relation\":\"and\",\"operands\":[{\"@type\":\"korap:term\",\"@field\":\"korap:field#author\",\"@value\":\"Hesse\"},{\"@type\":\"korap:group\",\"@field\":\"korap:field#pubDate\",\"relation\":\"until\",\"operands\":[{\"@type\":\"korap:date\",\"@value\":\"2013-12-09\"}]}]}}]", query.stringify());
+ Assert.assertEquals("[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:group\",\"relation\":\"and\",\"operands\":[{\"@type\":\"korap:term\",\"@field\":\"korap:field#author\",\"@value\":\"Hesse\"},{\"@type\":\"korap:group\",\"@field\":\"korap:field#pubDate\",\"relation\":\"until\",\"operands\":[{\"@type\":\"korap:date\",\"@value\":\"2013-12-10\"}]}]}}]", query.stringify());
// System.out.println("value until : " + query.stringify());
// System.out.println();
}
@@ -77,7 +77,7 @@
// System.out.println("value since : " + query.stringify());
// System.out.println();
System.out.println("Running date check (since) with additional attribute author");
- Assert.assertEquals("[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:group\",\"relation\":\"and\",\"operands\":[{\"@type\":\"korap:term\",\"@field\":\"korap:field#author\",\"@value\":\"Kafka\"},{\"@type\":\"korap:group\",\"@field\":\"korap:field#pubDate\",\"relation\":\"since\",\"operands\":[{\"@type\":\"korap:date\",\"@value\":\"2013-12-09\"}]}]}}]", query.stringify());
+ Assert.assertEquals("[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:group\",\"relation\":\"and\",\"operands\":[{\"@type\":\"korap:term\",\"@field\":\"korap:field#author\",\"@value\":\"Kafka\"},{\"@type\":\"korap:group\",\"@field\":\"korap:field#pubDate\",\"relation\":\"since\",\"operands\":[{\"@type\":\"korap:date\",\"@value\":\"2013-12-10\"}]}]}}]", query.stringify());
}
@Test
diff --git a/src/test/java/PoliqarpPlusTreeTest.java b/src/test/java/PoliqarpPlusTreeTest.java
index d865490..e596fda 100644
--- a/src/test/java/PoliqarpPlusTreeTest.java
+++ b/src/test/java/PoliqarpPlusTreeTest.java
@@ -139,14 +139,10 @@
assertEquals(occ5.replaceAll(" ", ""), map.replaceAll(" ", ""));
// <s><np>([base=bar][base=foo])*
- // comment: embedded sequence shouldn't really be here, but does not really hurt, either. (?)
- // really hard to get this behaviour out of the PQPlus grammar...
String occ6 =
"{@type=korap:sequence, operands=[" +
- "{@type=korap:sequence, operands=[" +
- "{@type=korap:element, @value=s}," +
- "{@type=korap:element, @value=np}" +
- "]}," +
+ "{@type=korap:element, @value=s}," +
+ "{@type=korap:element, @value=np}," +
"{@type=korap:group, operands=[" +
"{@type=korap:sequence, operands=[" +
"{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
@@ -163,10 +159,8 @@
// really hard to get this behaviour out of the PQPlus grammar...
String occ7 =
"{@type=korap:sequence, operands=[" +
- "{@type=korap:sequence, operands=[" +
- "{@type=korap:element, @value=s}," +
- "{@type=korap:element, @value=np}" +
- "]}," +
+ "{@type=korap:element, @value=s}," +
+ "{@type=korap:element, @value=np}," +
"{@type=korap:group, operands=[" +
"{@type=korap:sequence, operands=[" +
"{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
@@ -180,8 +174,6 @@
assertEquals(occ7.replaceAll(" ", ""), map.replaceAll(" ", ""));
// ([base=bar][base=foo])*[p=NN]
- // comment: embedded sequence shouldn't really be here, but does not really hurt, either. (?)
- // really hard to get this behaviour out of the PQPlus grammar...
String occ8 =
"{@type=korap:sequence, operands=[" +
"{@type=korap:group, operands=[" +
@@ -216,6 +208,35 @@
}
@Test
+ public void testDisjSegments() {
+ // ([base=der]|[base=das])[base=Schild]
+ String disj1 =
+ "{@type=korap:sequence, operands=[" +
+ "{@type=korap:group, relation=or, operands=[" +
+ "{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," +
+ "{@type=korap:token, @value={@type=korap:term, @value=base:das, relation==}}" +
+ "]}," +
+ "{@type=korap:token, @value={@type=korap:term, @value=base:Schild, relation==}}" +
+ "]}";
+ ppt = new PoliqarpPlusTree("([base=der]|[base=das])[base=Schild]");
+ map = ppt.getRequestMap().get("query").toString();
+ assertEquals(disj1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+ // [base=Schild]([base=der]|[base=das])
+ String disj2 =
+ "{@type=korap:sequence, operands=[" +
+ "{@type=korap:token, @value={@type=korap:term, @value=base:Schild, relation==}}," +
+ "{@type=korap:group, relation=or, operands=[" +
+ "{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," +
+ "{@type=korap:token, @value={@type=korap:term, @value=base:das, relation==}}" +
+ "]}" +
+ "]}";
+ ppt = new PoliqarpPlusTree("[base=Schild]([base=der]|[base=das])");
+ map = ppt.getRequestMap().get("query").toString();
+ assertEquals(disj2.replaceAll(" ", ""), map.replaceAll(" ", ""));
+ }
+
+ @Test
public void testTokenElemSequence() {
// [base=Mann]<vp>
String seq1 = "{@type=korap:sequence, operands=[" +