deactivated treatment of zero-word distances as overlaps
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
index 702f007..0953e5c 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
@@ -329,16 +329,12 @@
term.put("match", "match:" + match);
if (node.getChildCount() == elname + 1) {
termGroupOperands.add(term);
- System.err.println("taga");
} else {
subTermGroupOperands.add(term);
- System.err.println(layer);
}
}
if (node.getChildCount() > elname + 1) {
- System.err.println(termGroupOperands);
termGroupOperands.add(subTermGroup);
- System.err.println(termGroupOperands);
}
}
if (getNodeCat(attrNode).equals("NOTEQ")) negate = true;
@@ -425,10 +421,15 @@
int max = Integer.parseInt(maxStr);
// If zero word-distance, wrap this sequence in a disjunction along with an overlap position
// between the two operands
+ /*
+ XXX: This is currently deactivated. Uncomment to activate treatment of zero-word distances as overlap-alternatives
+ (see google doc on special distances serialization)
+
if (meas.equals("w") && min == 0) {
min = 1;
putIntoOverlapDisjunction = true;
}
+ */
if (!meas.equals("w") && min == 0 ) {
processSpanDistance(meas,min,max);
}
@@ -468,7 +469,9 @@
ArrayList<Object> overlapsOperands = (ArrayList<Object>) overlapsGroup.get("operands");
// this ensures identity of the operands lists and thereby a distribution of the operands for both created objects
sequence.put("operands", overlapsOperands);
- if (invertedOperands) invertedOperandsLists.push(overlapsOperands);
+ if (invertedOperands) {
+ invertedOperandsLists.push(overlapsOperands);
+ }
disjOperands.add(overlapsGroup);
disjOperands.add(wrapInReference(sequence, 0));
// Step II: decide where to put
@@ -476,6 +479,10 @@
objectStack.push(sequence);
}
else {
+ if (invertedOperands) {
+ ArrayList<Object> operands = (ArrayList<Object>) embeddedSequence.get("operands");
+ invertedOperandsLists.push(operands);
+ }
// Step II: decide where to put
putIntoSuperObject(group, 0);
objectStack.push(embeddedSequence);
@@ -508,7 +515,7 @@
// Wrap the argument of an #IN operator in a previously defined container
if (nodeCat.equals("ARG1") || nodeCat.equals("ARG2")) {
Tree parent = node.getParent();
- String child = getNodeCat(node.getChild(0));
+// String child = getNodeCat(node.getChild(0));
// if (child.equals("OPWF") | child.equals("OPLEM") | child.equals("OPELEM") | child.equals("OPMOPRH") | child.equals("OPLABEL")) {
if (operandWrap.containsRow(parent)) {
// Step I: create group
@@ -689,8 +696,7 @@
}
private void processSpanDistance(String meas, int min, int max) {
- // TODO Auto-generated method stub
-
+ // TODO Do stuff here in case we'll decide one day to treat span distances in a special way.
}
/**
@@ -978,6 +984,7 @@
ArrayList<Object> topObjectOperands = (ArrayList<Object>) objectStack.get(objStackPosition).get("operands");
if (!invertedOperandsLists.contains(topObjectOperands)) {
topObjectOperands.add(object);
+ System.out.println(objectStack.get(objStackPosition));
} else {
topObjectOperands.add(0, object);
}
@@ -1059,7 +1066,8 @@
// "#NHIT(gehen /w1:10 voran)"
// "MORPH(V PRES IND)",
// "wegen #OV(F) <s>"
- "Sonne /s0 Mond"
+// "Sonne /s0 Mond",
+ "Sonne /+w1:4 Mond /-w1:7 Sterne"
};
CosmasTree.verbose=true;
for (String q : queries) {
diff --git a/src/test/java/CosmasTreeTest.java b/src/test/java/CosmasTreeTest.java
index 7bd6d2c..0089727 100644
--- a/src/test/java/CosmasTreeTest.java
+++ b/src/test/java/CosmasTreeTest.java
@@ -277,15 +277,6 @@
query="Sonne /+w4 Mond";
String prox4 =
- "{@type=korap:group, operation=operation:or, operands=[" +
- "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
- "]}," +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
- "]}" +
- "], frame=overlaps}," +
"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
"{@type=korap:group, operation=operation:sequence, " +
"operands=[" +
@@ -297,26 +288,43 @@
"]}" +
"], inOrder=true, " +
"distances=[" +
- "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
+ "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
"]" +
"}" +
- "]}" +
- "]}";
+ "]}";
+// "{@type=korap:group, operation=operation:or, operands=[" +
+// "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
+// "]}," +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
+// "]}" +
+// "], frame=overlaps}," +
+// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+// "{@type=korap:group, operation=operation:sequence, " +
+// "operands=[" +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
+// "]}," +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
+// "]}" +
+// "], inOrder=true, " +
+// "distances=[" +
+// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
+// "]" +
+// "}" +
+// "]}" +
+// "]}";
+
+
ct = new CosmasTree(query);
map = ct.getRequestMap().get("query").toString();
assertEquals(prox4.replaceAll(" ", ""), map.replaceAll(" ", ""));
query="Sonne /-w4 Mond";
String prox5 =
- "{@type=korap:group, operation=operation:or, operands=[" +
- "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
- "]}," +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
- "]}" +
- "], frame=overlaps}," +
"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
"{@type=korap:group, operation=operation:sequence, " +
"operands=[" +
@@ -328,26 +336,41 @@
"]}" +
"], inOrder=true, " +
"distances=[" +
- "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
+ "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
"]" +
"}" +
- "]}" +
- "]}";
+ "]}";
+// "{@type=korap:group, operation=operation:or, operands=[" +
+// "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
+// "]}," +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
+// "]}" +
+// "], frame=overlaps}," +
+// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+// "{@type=korap:group, operation=operation:sequence, " +
+// "operands=[" +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
+// "]}," +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
+// "]}" +
+// "], inOrder=true, " +
+// "distances=[" +
+// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
+// "]" +
+// "}" +
+// "]}" +
+// "]}";
ct = new CosmasTree(query);
map = ct.getRequestMap().get("query").toString();
assertEquals(prox5.replaceAll(" ", ""), map.replaceAll(" ", ""));
query="Sonne /w4 Mond";
String prox6 =
- "{@type=korap:group, operation=operation:or, operands=[" +
- "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
- "]}," +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
- "]}" +
- "], frame=overlaps}," +
"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
"{@type=korap:group, operation=operation:sequence, " +
"operands=[" +
@@ -359,11 +382,35 @@
"]}" +
"], inOrder=false, " +
"distances=[" +
- "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
+ "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
"]" +
"}" +
- "]}" +
- "]}";
+ "]}";
+// "{@type=korap:group, operation=operation:or, operands=[" +
+// "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
+// "]}," +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
+// "]}" +
+// "], frame=overlaps}," +
+// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+// "{@type=korap:group, operation=operation:sequence, " +
+// "operands=[" +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
+// "]}," +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
+// "]}" +
+// "], inOrder=false, " +
+// "distances=[" +
+// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
+// "]" +
+// "}" +
+// "]}" +
+// "]}";
ct = new CosmasTree(query);
map = ct.getRequestMap().get("query").toString();
assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -384,10 +431,10 @@
"{@type=korap:group, operation=operation:sequence, " +
"operands=[" +
"{@type=korap:group, operation=operation:class, class=0, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
+ "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
"]}," +
"{@type=korap:group, operation=operation:class, class=0, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
+ "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
"]}" +
"], inOrder=true, " +
"distances=[" +
@@ -453,31 +500,62 @@
String prox6 =
- "{@type=korap:group, operation=operation:or, operands=[" +
- "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- mondsterneAllClasses +
- "]}," +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
- "]}" +
- "], frame=overlaps}," +
"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
- "{@type=korap:group, operation=operation:sequence, " +
- "operands=[" +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- mondsterneAllClasses +
- "]}," +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
- "]}" +
- "], inOrder=true, " +
- "distances=[" +
- "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
- "]" +
- "}" +
- "]}" +
- "]}";
+ "{@type=korap:group, operation=operation:sequence, " +
+ "operands=[" +
+
+ "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+ "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+ "{@type=korap:group, operation=operation:sequence, " +
+ "operands=[" +
+ "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+ "{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
+ "]}," +
+ "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+ "{@type=korap:token, wrap={@type=korap:term, key=Sterne, layer=orth, match=match:eq}}" +
+ "]}" +
+ "], inOrder=true, " +
+ "distances=[" +
+ "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
+ "]" +
+ "}" +
+ "]}" +
+ "]}," +
+ "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+ "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
+ "]}" +
+ "], inOrder=true, " +
+ "distances=[" +
+ "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
+ "]" +
+ "}" +
+ "]}" +
+ "" ;
+// "{@type=korap:group, operation=operation:or, operands=[" +
+// "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// mondsterneAllClasses +
+// "]}," +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
+// "]}" +
+// "], frame=overlaps}," +
+// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+// "{@type=korap:group, operation=operation:sequence, " +
+// "operands=[" +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// mondsterneAllClasses +
+// "]}," +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}" +
+// "]}" +
+// "], inOrder=true, " +
+// "distances=[" +
+// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=4}, min=1, max=4}" +
+// "]" +
+// "}" +
+// "]}" +
+// "]}";
ct = new CosmasTree(query);
map = ct.getRequestMap().get("query").toString();
assertEquals(prox6.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -726,15 +804,29 @@
query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group
String beg2 =
- "{@type=korap:group, operation=operation:or, operands=[" +
- "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- beg1 +
- "]}" + "," +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- kommt +
- "]}" +
- "], frame=overlaps}," +
+// "{@type=korap:group, operation=operation:or, operands=[" +
+// "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// beg1 +
+// "]}" + "," +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// kommt +
+// "]}" +
+// "], frame=overlaps}," +
+// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+// "{@type=korap:group, operation=operation:sequence, operands=[" +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// beg1 +
+// "]}," +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// kommt +
+// "]}" +
+// "], inOrder=true, distances=[" +
+// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
+// "]}" +
+// "]}" +
+// "]}";
+//
"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
"{@type=korap:group, operation=operation:sequence, operands=[" +
"{@type=korap:group, operation=operation:class, class=0, operands=[" +
@@ -744,26 +836,39 @@
kommt +
"]}" +
"], inOrder=true, distances=[" +
- "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
+ "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" +
"]}" +
- "]}" +
- "]}";
+ "]}";
ct = new CosmasTree(query);
map = ct.getRequestMap().get("query").toString();
assertEquals(beg2.replaceAll(" ", ""), map.replaceAll(" ", ""));
query="kommt /+w10 #BEG(der /w3:5 Mann)";
String beg3 =
- "{@type=korap:group, operation=operation:or, operands=[" +
- "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- kommt +
-// "," +
- "]}," +
- "{@type=korap:group, operation=operation:class, class=0, operands=[" +
- beg1+
- "]}" +
- "], frame=overlaps}," +
+// "{@type=korap:group, operation=operation:or, operands=[" +
+// "{@type=korap:group, operation=operation:position, frames=[], sharedClasses=[intersects], operands=[" +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// kommt +
+//// "," +
+// "]}," +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// beg1+
+// "]}" +
+// "], frame=overlaps}," +
+// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
+// "{@type=korap:group, operation=operation:sequence, operands=[" +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// kommt +
+// "]}," +
+// "{@type=korap:group, operation=operation:class, class=0, operands=[" +
+// beg1+
+// "]}" +
+// "], inOrder=true, distances=[" +
+// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
+// "]}" +
+// "]}" +
+// "]}";
+
"{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
"{@type=korap:group, operation=operation:sequence, operands=[" +
"{@type=korap:group, operation=operation:class, class=0, operands=[" +
@@ -773,10 +878,9 @@
beg1+
"]}" +
"], inOrder=true, distances=[" +
- "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=1, max=10}, min=1, max=10}" +
+ "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=10}, min=0, max=10}" +
"]}" +
- "]}" +
- "]}";
+ "]}";
ct = new CosmasTree(query);
map = ct.getRequestMap().get("query").toString();
assertEquals(beg3.replaceAll(" ", ""), map.replaceAll(" ", ""));