- PQ+ 'within' supported again
- PQ+ 'meta' deactivated in favour of virtual collections
diff --git a/src/main/antlr/poliqarpplus/PoliqarpPlusLexer.g4 b/src/main/antlr/poliqarpplus/PoliqarpPlusLexer.g4
index d34475a..af9b644 100644
--- a/src/main/antlr/poliqarpplus/PoliqarpPlusLexer.g4
+++ b/src/main/antlr/poliqarpplus/PoliqarpPlusLexer.g4
@@ -35,6 +35,7 @@
RELATION_OP : ('dominates' | 'relatesTo');
MATCH_OP : ('focus' | 'shrink' | 'split'); // submatch and shrink are deprecated!
SUBMATCH_OP : 'submatch';
+WITHIN : 'within';
META : 'meta';
/*
diff --git a/src/main/antlr/poliqarpplus/PoliqarpPlusParser.g4 b/src/main/antlr/poliqarpplus/PoliqarpPlusParser.g4
index dc876d9..0d08192 100644
--- a/src/main/antlr/poliqarpplus/PoliqarpPlusParser.g4
+++ b/src/main/antlr/poliqarpplus/PoliqarpPlusParser.g4
@@ -212,6 +212,9 @@
: segment | sequence | disjunction
;
+within
+: WITHIN WORD
+;
/**
=== META section ===
@@ -225,4 +228,4 @@
Entry point for all requests. Linguistic query is obligatory, metadata filtering
is optional.
*/
-request : query meta? EOF;
\ No newline at end of file
+request : query within? meta? EOF;
\ No newline at end of file
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java
index 3ccd297..db161a0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java
@@ -547,25 +547,26 @@
* @param node
*/
private void processMeta(ParseTree node) {
- LinkedHashMap<String, Object> metaFilter = new LinkedHashMap<String, Object>();
- requestMap.put("meta", metaFilter);
- metaFilter.put("@type", "korap:meta");
+ addWarning("You used the 'meta' keyword in a PoliqarpPlus query. This"
+ + " feature is currently not supported. Please use virtual "
+ + "collections to restrict documents by metadata.");
+ for (ParseTree child : getChildren(node)) {
+ visited.add(child);
+ }
}
- /**
- * NB: requires that parent is not 'position'!
- *
- * @param node
- */
private void processWithin(ParseTree node) {
- ParseTree domainNode = node.getChild(2);
+ ParseTree domainNode = node.getChild(1);
String domain = getNodeCat(domainNode);
- LinkedHashMap<String, Object> curObject = (LinkedHashMap<String, Object>) objectStack
- .getFirst();
- curObject.put("within", domain);
+ LinkedHashMap<String, Object> span = CqlfObjectGenerator.makeSpan(domain);
+ LinkedHashMap<String, Object> queryObj = (LinkedHashMap<String, Object>) requestMap.get("query");
+ LinkedHashMap<String, Object> contains = CqlfObjectGenerator.makePosition(new String[]{"frames:contains"}, null);
+ ArrayList<Object> operands = (ArrayList<Object>) contains.get("operands");
+ operands.add(span);
+ operands.add(queryObj);
+ requestMap.put("query", contains);
visited.add(node.getChild(0));
visited.add(node.getChild(1));
- visited.add(domainNode);
}
/**