re-enabled min and max in repetitions, adding deprecation warnings.
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 a5418eb..fe1cae1 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,7 +101,10 @@
protected LinkedHashMap<String, Object> makeRepetition(int min, int max) {
LinkedHashMap<String, Object> group = makeGroup("repetition");
- group.put("repetition", makeBoundary(min, max));
+ group.put("boundary", makeBoundary(min, max));
+ group.put("min", min);
+ group.put("max", max);
+ warningMsgs.add("Deprecated 2014-07-24: 'min' and 'max' to be supported until 6 months from deprecation date.");
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 776009c..0a1db9a 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
@@ -92,8 +92,11 @@
ParseTree quantification = getFirstChildWithCat(node, "repetition");
if (quantification != null) {
LinkedHashMap<String,Object> quantGroup = makeGroup("repetition");
- int[] minmax = parseRepetition(quantification);
- quantGroup.put("repetition", makeBoundary(minmax[0], minmax[1]));
+ Integer[] minmax = parseRepetition(quantification);
+ quantGroup.put("boundary", makeBoundary(minmax[0], minmax[1]));
+ if (minmax[0] != null) quantGroup.put("min", minmax[0]);
+ if (minmax[1] != null) quantGroup.put("max", minmax[1]);
+ warningMsgs.add("Deprecated 2014-07-24: 'min' and 'max' to be supported until 6 months from deprecation date.");
putIntoSuperObject(quantGroup);
objectStack.push(quantGroup);
stackedObjects++;
@@ -352,7 +355,7 @@
* the minimal number of repetitions of the quantified element, and the second
* element representing the maximal number of repetitions
*/
- private int[] parseRepetition(ParseTree node) {
+ private Integer[] parseRepetition(ParseTree node) {
int min = 0, max = 0;
// (repetition) node can be of two types: 'kleene' or 'range'
ParseTree repetitionTypeNode = node.getChild(0);
@@ -379,7 +382,7 @@
else if (hasChild(repetitionTypeNode, ",")) min = 0;
else min = max;
}
- return new int[]{min,max};
+ return new Integer[]{min,max};
}
private String parseFrame(ParseTree node) {
@@ -531,7 +534,7 @@
ParseTree nextSibling = emptySegments.getChild(i + 1);
if (child.toStringTree(parser).equals("(emptyToken [ ])")) {
if (nextSibling != null && getNodeCat(nextSibling).equals("repetition")) {
- int[] minmax = parseRepetition(nextSibling);
+ Integer[] minmax = parseRepetition(nextSibling);
min += minmax[0];
max += minmax[1];
} else {
diff --git a/src/test/java/PoliqarpPlusTreeTest.java b/src/test/java/PoliqarpPlusTreeTest.java
index b7f6796..1319e18 100644
--- a/src/test/java/PoliqarpPlusTreeTest.java
+++ b/src/test/java/PoliqarpPlusTreeTest.java
@@ -423,7 +423,7 @@
"{@type=korap:group, operation=operation:sequence, operands=[" +
"{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token}" +
- "], repetition={@type=korap:boundary, min=2, max=2}}," +
+ "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}," +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
"]}";
ppt = new PoliqarpPlusTree(query);
@@ -435,7 +435,7 @@
"{@type=korap:group, operation=operation:sequence, operands=[" +
"{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token}" +
- "], repetition={@type=korap:boundary, min=1, max=100}}," +
+ "], boundary={@type=korap:boundary, min=1, max=100}, min=1, max=100}," +
"{@type=korap:token, wrap={@type=korap:term, layer=lemma, key=Mann, match=match:eq}}" +
"]}";
ppt = new PoliqarpPlusTree(query);
@@ -447,11 +447,11 @@
"{@type=korap:group, operation=operation:sequence, operands=[" +
"{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token}" +
- "], repetition={@type=korap:boundary, min=1, max=100}}," +
+ "], boundary={@type=korap:boundary, min=1, max=100}, 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}" +
- "], repetition={@type=korap:boundary, min=2, max=2}}" +
+ "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}" +
"]}";
ppt = new PoliqarpPlusTree(query);
map = ppt.getRequestMap().get("query").toString();
@@ -462,14 +462,14 @@
"{@type=korap:group, operation=operation:sequence, operands=[" +
"{@type=korap:group, operation=operation:repetition, operands=[" +
"{@type=korap:token}" +
- "], repetition={@type=korap:boundary, min=1, max=100}}," +
+ "], boundary={@type=korap:boundary, min=1, max=100}, 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}" +
- "], repetition={@type=korap:boundary, min=2, max=2}}" +
+ "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}" +
"]}";
ppt = new PoliqarpPlusTree(query);
map = ppt.getRequestMap().get("query").toString();
@@ -520,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}}" +
- "], repetition={@type=korap:boundary, min=0, max=100}}";
+ "], boundary={@type=korap:boundary, min=0, max=100}, min=0, max=100}";
ppt = new PoliqarpPlusTree("[base=foo]*");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ1.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -530,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}}" +
- "], repetition={@type=korap:boundary, min=0, max=100} }," +
+ "], boundary={@type=korap:boundary, min=0, max=100}, 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]");
@@ -543,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}}" +
- "], repetition={@type=korap:boundary, min=0, max=100} }" +
+ "], boundary={@type=korap:boundary, min=0, max=100}, min=0, max=100 }" +
"]}";
ppt = new PoliqarpPlusTree("[base=bar][base=foo]*");
map = ppt.getRequestMap().get("query").toString();
@@ -556,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}}" +
"]}" +
- "], repetition={@type=korap:boundary, min=0, max=100}}" ;
+ "], boundary={@type=korap:boundary, min=0, max=100}, min=0, max=100}" ;
ppt = new PoliqarpPlusTree("([base=bar][base=foo])*");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ4.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -570,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}}" +
"]}" +
- "], repetition={@type=korap:boundary, min=0, max=100} }" +
+ "], boundary={@type=korap:boundary, min=0, max=100}, min=0, max=100 }" +
"]}" ;
ppt = new PoliqarpPlusTree("<s>([base=bar][base=foo])*");
map = ppt.getRequestMap().get("query").toString();
@@ -586,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}}" +
"]}" +
- "], repetition={@type=korap:boundary, min=0, max=100} }" +
+ "], boundary={@type=korap:boundary, min=0, max=100}, min=0, max=100 }" +
"]}" ;
ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*");
map = ppt.getRequestMap().get("query").toString();
@@ -604,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}}" +
"]}" +
- "], repetition={@type=korap:boundary, min=0, max=100} }," +
+ "], boundary={@type=korap:boundary, min=0, max=100}, 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]");
@@ -619,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}}" +
"]}" +
- "], repetition={@type=korap:boundary, min=0, max=100} }," +
+ "], boundary={@type=korap:boundary, min=0, max=100}, 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]");
@@ -629,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}}" +
- "], repetition={@type=korap:boundary, min=1, max=100}}";
+ "], boundary={@type=korap:boundary, min=1, max=100}, min=1, max=100}";
ppt = new PoliqarpPlusTree("[base=foo]+");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ9.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -637,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}}" +
- "], repetition={@type=korap:boundary, min=0, max=1}}";
+ "], boundary={@type=korap:boundary, min=0, max=1}, min=0, max=1}";
ppt = new PoliqarpPlusTree("[base=foo]?");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ10.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -645,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}}" +
- "], repetition={@type=korap:boundary, min=2, max=5}}";
+ "], boundary={@type=korap:boundary, min=2, max=5}, min=2, max=5}";
ppt = new PoliqarpPlusTree("[base=foo]{2,5}");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ11.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -653,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}}" +
- "], repetition={@type=korap:boundary, min=2, max=2}}";
+ "], boundary={@type=korap:boundary, min=2, max=2}, min=2, max=2}";
ppt = new PoliqarpPlusTree("[base=foo]{2}");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ12.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -661,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}}" +
- "], repetition={@type=korap:boundary, min=2, max=100}}";
+ "], boundary={@type=korap:boundary, min=2, max=100}, min=2, max=100}";
ppt = new PoliqarpPlusTree("[base=foo]{2,}");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ13.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -669,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}}" +
- "], repetition={@type=korap:boundary, min=0, max=2}}";
+ "], boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}";
ppt = new PoliqarpPlusTree("[base=foo]{,2}");
map = ppt.getRequestMap().get("query").toString();
assertEquals(occ14.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -947,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}}" +
- "], repetition={@type=korap:boundary, min=0, max=100}" +
+ "], boundary={@type=korap:boundary, min=0, max=100}, min=0, max=100" +
"}" +
"]}";
ppt = new PoliqarpPlusTree("contains(<s>,[pos=N]*)");
@@ -962,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}}" +
- "], repetition={@type=korap:boundary, min=0, max=100}" +
+ "], boundary={@type=korap:boundary, min=0, max=100}, min=0, max=100" +
"}" +
"]}" +
"]}";