pqplus bugfix for shrinks
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractSyntaxTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractSyntaxTree.java
index c454f3c..59a248a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractSyntaxTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractSyntaxTree.java
@@ -93,7 +93,7 @@
* @return true iff the node is a container only.
*/
public boolean isContainerOnly(ParseTree node) {
- String[] validNodeNamesArray = "cq_segment sq_segment element empty_segments".split(" ");
+ String[] validNodeNamesArray = "cq_segment sq_segment element empty_segments spanclass".split(" ");
List<String> validNodeNames = Arrays.asList(validNodeNamesArray);
List<ParseTree> children = getChildren(node);
for (ParseTree child : children) {
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 502702a..0682994 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
@@ -213,6 +213,7 @@
cqHasOccChild = false;
// disregard empty segments in simple queries (parsed by ANTLR as empty cq_segments)
ignoreCq_segment = (node.getChildCount() == 1 && (node.getChild(0).toStringTree(parser).equals(" ") || getNodeCat(node.getChild(0)).equals("spanclass") || getNodeCat(node.getChild(0)).equals("position")));
+// ignoreCq_segment = (node.getChildCount() == 1 && (node.getChild(0).toStringTree(parser).equals(" ") || getNodeCat(node.getChild(0)).equals("position")));
// ignore this node if it only serves as an aligned sequence container
if (node.getChildCount() > 1) {
if (getNodeCat(node.getChild(1)).equals("cq_segments") && hasChild(node.getChild(1), "alignment")) {
@@ -222,6 +223,7 @@
ignoreCq_segment = true;
}
}
+ System.err.println("WAAAAAAH"+objectStack);
if (!ignoreCq_segment) {
LinkedHashMap<String, Object> sequence = new LinkedHashMap<String, Object>();
// Step 0: cq_segments has 'occ' child -> introduce group as super group to the sequence/token/group
@@ -330,6 +332,8 @@
}
} else if (!objectStack.isEmpty()) {
// embed in super sequence
+ System.err.println("BBBBUUUHH "+isContainerOnly(node));
+
ArrayList<Object> topSequenceOperands;
if (!isContainerOnly(node)) {
try {
@@ -1002,7 +1006,8 @@
"[base=der][]*[base=Mann]",
"[base=der] within s",
"([orth=der][base=katze])|([orth=eine][base=baum])",
- "[orth=der][base=katze]|[orth=eine][base=baum]"
+ "[orth=der][base=katze]|[orth=eine][base=baum]",
+ "shrink(1:{[base=der]}{1:[pos=ADJA]})"
};
PoliqarpPlusTree.verbose=true;
for (String q : queries) {
diff --git a/src/test/java/PoliqarpPlusTreeTest.java b/src/test/java/PoliqarpPlusTreeTest.java
index 4a45d78..23337db 100644
--- a/src/test/java/PoliqarpPlusTreeTest.java
+++ b/src/test/java/PoliqarpPlusTreeTest.java
@@ -821,6 +821,23 @@
ppt = new PoliqarpPlusTree("split(2|3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
map = ppt.getRequestMap().get("query").toString();
assertEquals(shr7.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+
+ String shr8 =
+ "{@type=korap:group, operation=operation:submatch, classRef=[1], 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=der, layer=lemma, match=match:eq}}" +
+ "]}," +
+ "{@type=korap:group, operation=operation:class, class=1, operands=[" +
+ "{@type=korap:token, wrap={@type=korap:term, key=ADJA, layer=pos, match=match:eq}}" +
+ "]}" +
+ "]}" +
+ "]}";
+ ppt = new PoliqarpPlusTree("shrink(1:{[base=der]}{1:[pos=ADJA]})");
+ map = ppt.getRequestMap().get("query").toString();
+ assertEquals(shr8.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
}