repetitions: boundary objects instead of min, max
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java
index feeb503..a5418eb 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java
@@ -101,8 +101,7 @@
protected LinkedHashMap<String, Object> makeRepetition(int min, int max) {
LinkedHashMap<String, Object> group = makeGroup("repetition");
- group.put("min", min);
- group.put("max", max);
+ group.put("repetition", makeBoundary(min, max));
return group;
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
index 046f625..776009c 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
@@ -93,8 +93,7 @@
if (quantification != null) {
LinkedHashMap<String,Object> quantGroup = makeGroup("repetition");
int[] minmax = parseRepetition(quantification);
- quantGroup.put("min", minmax[0]);
- quantGroup.put("max", minmax[1]);
+ quantGroup.put("repetition", makeBoundary(minmax[0], minmax[1]));
putIntoSuperObject(quantGroup);
objectStack.push(quantGroup);
stackedObjects++;
diff --git a/src/test/java/PoliqarpPlusTreeTest.java b/src/test/java/PoliqarpPlusTreeTest.java
index 43da3a1..b7f6796 100644
--- a/src/test/java/PoliqarpPlusTreeTest.java
+++ b/src/test/java/PoliqarpPlusTreeTest.java
@@ -222,6 +222,18 @@
ppt = new PoliqarpPlusTree(query);
map = ppt.getRequestMap().get("query").toString();
assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+ query = "<cnx/c!=vp (foundry/class=header&id=7)>";
+ expected =
+ "{@type=korap:span, foundry=cnx, layer=c, key=vp, match=match:ne, attr=" +
+ "{@type=korap:termGroup, relation=relation:and, operands=[" +
+ "{@type=korap:term, foundry=foundry, key=class, value=header, match=match:eq}," +
+ "{@type=korap:term, key=id, value=7, match=match:eq}" +
+ "]}" +
+ "}";
+ ppt = new PoliqarpPlusTree(query);
+ map = ppt.getRequestMap().get("query").toString();
+ assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
}
@Test
@@ -411,7 +423,7 @@
"{@type=korap:group, operation=operation:sequence, operands=[" +
"{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token}" +
- "], min=2, max=2}," +
+ "], repetition={@type=korap:boundary, min=2, max=2}}," +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
"]}";
ppt = new PoliqarpPlusTree(query);
@@ -423,7 +435,7 @@
"{@type=korap:group, operation=operation:sequence, operands=[" +
"{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token}" +
- "], min=1, max=100}," +
+ "], repetition={@type=korap:boundary, min=1, max=100}}," +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
"]}";
ppt = new PoliqarpPlusTree(query);
@@ -435,11 +447,11 @@
"{@type=korap:group, operation=operation:sequence, operands=[" +
"{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token}" +
- "], min=1, max=100}," +
+ "], repetition={@type=korap:boundary, min=1, max=100}}," +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}," +
"{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token}" +
- "], min=2, max=2}" +
+ "], repetition={@type=korap:boundary, min=2, max=2}}" +
"]}";
ppt = new PoliqarpPlusTree(query);
map = ppt.getRequestMap().get("query").toString();
@@ -450,14 +462,14 @@
"{@type=korap:group, operation=operation:sequence, operands=[" +
"{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token}" +
- "], min=1, max=100}," +
+ "], repetition={@type=korap:boundary, min=1, max=100}}," +
"{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
"{@type=korap:span, key=s}," +
"{@type=korap:span, key=np}" +
"]}," +
"{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token}" +
- "], min=2, max=2}" +
+ "], repetition={@type=korap:boundary, min=2, max=2}}" +
"]}";
ppt = new PoliqarpPlusTree(query);
map = ppt.getRequestMap().get("query").toString();
@@ -508,7 +520,7 @@
// [base=foo]*
String occ1 = "{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
- "], min=0, max=100}";
+ "], repetition={@type=korap:boundary, min=0, max=100}}";
ppt = new PoliqarpPlusTree("[base=foo]*");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ1.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -518,7 +530,7 @@
"{@type=korap:group, operation=operation:sequence, operands=[" +
"{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
- "], min=0, max=100 }," +
+ "], repetition={@type=korap:boundary, min=0, max=100} }," +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}" +
"]}";
ppt = new PoliqarpPlusTree("[base=foo]*[base=bar]");
@@ -531,7 +543,7 @@
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
"{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
- "], min=0, max=100 }" +
+ "], repetition={@type=korap:boundary, min=0, max=100} }" +
"]}";
ppt = new PoliqarpPlusTree("[base=bar][base=foo]*");
map = ppt.getRequestMap().get("query").toString();
@@ -544,7 +556,7 @@
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
"]}" +
- "], min=0, max=100}" ;
+ "], repetition={@type=korap:boundary, min=0, max=100}}" ;
ppt = new PoliqarpPlusTree("([base=bar][base=foo])*");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ4.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -558,7 +570,7 @@
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
"]}" +
- "], min=0, max=100 }" +
+ "], repetition={@type=korap:boundary, min=0, max=100} }" +
"]}" ;
ppt = new PoliqarpPlusTree("<s>([base=bar][base=foo])*");
map = ppt.getRequestMap().get("query").toString();
@@ -574,7 +586,7 @@
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
"]}" +
- "], min=0, max=100 }" +
+ "], repetition={@type=korap:boundary, min=0, max=100} }" +
"]}" ;
ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*");
map = ppt.getRequestMap().get("query").toString();
@@ -592,7 +604,7 @@
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
"]}" +
- "], min=0, max=100 }," +
+ "], repetition={@type=korap:boundary, min=0, max=100} }," +
"{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" +
"]}" ;
ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*[p=NN]");
@@ -607,7 +619,7 @@
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=bar, match=match:eq}}," +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
"]}" +
- "], min=0, max=100 }," +
+ "], repetition={@type=korap:boundary, min=0, max=100} }," +
"{@type=korap:token, wrap={@type=korap:term, layer=p, key=NN, match=match:eq}}" +
"]}" ;
ppt = new PoliqarpPlusTree("([base=bar][base=foo])*[p=NN]");
@@ -617,7 +629,7 @@
// [base=foo]+
String occ9 = "{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
- "], min=1, max=100}";
+ "], repetition={@type=korap:boundary, min=1, max=100}}";
ppt = new PoliqarpPlusTree("[base=foo]+");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ9.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -625,7 +637,7 @@
// [base=foo]?
String occ10 = "{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
- "], min=0, max=1}";
+ "], repetition={@type=korap:boundary, min=0, max=1}}";
ppt = new PoliqarpPlusTree("[base=foo]?");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ10.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -633,7 +645,7 @@
// [base=foo]{2,5}
String occ11 = "{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
- "], min=2, max=5}";
+ "], repetition={@type=korap:boundary, min=2, max=5}}";
ppt = new PoliqarpPlusTree("[base=foo]{2,5}");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ11.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -641,7 +653,7 @@
// [base=foo]{2}
String occ12 = "{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
- "], min=2, max=2}";
+ "], repetition={@type=korap:boundary, min=2, max=2}}";
ppt = new PoliqarpPlusTree("[base=foo]{2}");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ12.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -649,7 +661,7 @@
// [base=foo]{2}
String occ13 = "{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
- "], min=2, max=100}";
+ "], repetition={@type=korap:boundary, min=2, max=100}}";
ppt = new PoliqarpPlusTree("[base=foo]{2,}");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ13.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -657,7 +669,7 @@
// [base=foo]{2}
String occ14 = "{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=foo, match=match:eq}}" +
- "], min=0, max=2}";
+ "], repetition={@type=korap:boundary, min=0, max=2}}";
ppt = new PoliqarpPlusTree("[base=foo]{,2}");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ14.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -935,7 +947,7 @@
"{@type=korap:span, key=s}," +
"{@type=korap:group, operation=operation:repetition, " +
"operands=[{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}" +
- "], min=0, max=100" +
+ "], repetition={@type=korap:boundary, min=0, max=100}" +
"}" +
"]}";
ppt = new PoliqarpPlusTree("contains(<s>,[pos=N]*)");
@@ -950,7 +962,7 @@
"{@type=korap:span, key=s}," +
"{@type=korap:group, operation=operation:repetition, " +
"operands=[{@type=korap:token, wrap={@type=korap:term, layer=pos, key=N, match=match:eq}}" +
- "], min=0, max=100" +
+ "], repetition={@type=korap:boundary, min=0, max=100}" +
"}" +
"]}" +
"]}";