- highlighted classes explicit in meta
- PQ+: 'dependency(X,Y)' as shortcut for 'relatesTo(d:X,Y)'
diff --git a/src/main/antlr/annis/AqlLexer.g4 b/src/main/antlr/annis/AqlLexer.g4
index a698a3b..b90d183 100644
--- a/src/main/antlr/annis/AqlLexer.g4
+++ b/src/main/antlr/annis/AqlLexer.g4
@@ -35,6 +35,7 @@
DOMINANCE:'>';
POINTING:'->';
PRECEDENCE:'.';
+NEAR: '^';
TEST:'%';
IDENT_COV:'_=_';
INCLUSION:'_i_';
diff --git a/src/main/antlr/annis/AqlParser.g4 b/src/main/antlr/annis/AqlParser.g4
index dbca2f2..319ad1b 100644
--- a/src/main/antlr/annis/AqlParser.g4
+++ b/src/main/antlr/annis/AqlParser.g4
@@ -118,6 +118,12 @@
: NEQ
;
+near
+: NEAR (layer)? # DirectNear
+| NEAR (layer)? STAR # IndirectNear
+| NEAR (layer COMMA?)? rangeSpec #RangeNear
+;
+
operator
: precedence
| spanrelation
@@ -128,6 +134,7 @@
| identity
| equalvalue
| notequalvalue
+| near
;
foundry
diff --git a/src/main/antlr/poliqarpplus/PoliqarpPlusLexer.g4 b/src/main/antlr/poliqarpplus/PoliqarpPlusLexer.g4
index af9b644..378d45f 100644
--- a/src/main/antlr/poliqarpplus/PoliqarpPlusLexer.g4
+++ b/src/main/antlr/poliqarpplus/PoliqarpPlusLexer.g4
@@ -32,7 +32,7 @@
*/
POSITION_OP : ('contains' | 'startswith' | 'startsWith' | 'endswith' | 'endsWith' | 'matches' | 'overlaps') ;
-RELATION_OP : ('dominates' | 'relatesTo');
+RELATION_OP : ('dominates' | 'dependency' | 'relatesTo');
MATCH_OP : ('focus' | 'shrink' | 'split'); // submatch and shrink are deprecated!
SUBMATCH_OP : 'submatch';
WITHIN : 'within';
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractQueryProcessor.java
index ca09dc7..501c190 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractQueryProcessor.java
@@ -11,85 +11,91 @@
import org.slf4j.Logger;
public abstract class AbstractQueryProcessor {
-
- Logger log;
- /**
- * The query
- */
- String query;
- /**
- * Top-level map representing the whole request.
- */
- LinkedHashMap<String, Object> requestMap = new LinkedHashMap<String, Object>();
- /**
- * Keeps track of open node categories
- */
- LinkedList<String> openNodeCats = new LinkedList<String>();
- /**
- * Keeps track of all visited nodes in a tree
- */
- List<ParseTree> visited = new ArrayList<ParseTree>();
- /**
- * Keeps track of active object.
- */
- LinkedList<LinkedHashMap<String, Object>> objectStack = new LinkedList<LinkedHashMap<String, Object>>();
- /**
- * Keeps track of how many objects there are to pop after every recursion of {@link #processNode(ParseTree)}
- */
- LinkedList<Integer> objectsToPop = new LinkedList<Integer>();
- /**
- * If true, print debug statements
- */
- public static boolean verbose = false;
- ParseTree currentNode = null;
- Integer stackedObjects = 0;
- private ArrayList<List<Object>> errors = new ArrayList<List<Object>>();
- private ArrayList<List<Object>> warnings = new ArrayList<List<Object>>();
- private ArrayList<List<Object>> messages = new ArrayList<List<Object>>();
- LinkedHashMap<String, Object> collection = new LinkedHashMap<String,Object>();
-
- AbstractQueryProcessor() {
- requestMap.put("@context", "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld");
- requestMap.put("errors", errors);
- requestMap.put("warnings", warnings);
- requestMap.put("messages", messages);
- requestMap.put("collection", collection);
- requestMap.put("query", new LinkedHashMap<String, Object>());
- requestMap.put("meta", new LinkedHashMap<String, Object>());
- }
-
- public abstract void process(String query);
-
- public void addWarning(int code, String msg) {
- List<Object> warning = Arrays.asList(new Object[]{code, msg});
- warnings.add(warning);
- }
-
- public void addWarning(String msg) {
- List<Object> warning = Arrays.asList(new Object[]{msg});
- warnings.add(warning);
- }
-
- public void addMessage(int code, String msg) {
- List<Object> message = Arrays.asList(new Object[]{code, msg});
- messages.add(message);
- }
-
- public void addMessage(String msg) {
- List<Object> message = Arrays.asList(new Object[]{msg});
- messages.add(message);
- }
-
- public void addError(int code, String msg) {
- List<Object> error = Arrays.asList(new Object[]{code, msg});
- errors.add(error);
- }
- public void addError(List<Object> fullErrorMsg) {
- errors.add(fullErrorMsg);
- }
-
- public Map<String, Object> getRequestMap() {
- return requestMap;
- }
+ Logger log;
+ /**
+ * The query
+ */
+ String query;
+ /**
+ * Top-level map representing the whole request.
+ */
+ LinkedHashMap<String, Object> requestMap = new LinkedHashMap<String, Object>();
+ /**
+ * Keeps track of open node categories
+ */
+ LinkedList<String> openNodeCats = new LinkedList<String>();
+ /**
+ * Keeps track of all visited nodes in a tree
+ */
+ List<ParseTree> visited = new ArrayList<ParseTree>();
+ /**
+ * Keeps track of active object.
+ */
+ LinkedList<LinkedHashMap<String, Object>> objectStack = new LinkedList<LinkedHashMap<String, Object>>();
+ /**
+ * Keeps track of how many objects there are to pop after every recursion of {@link #processNode(ParseTree)}
+ */
+ LinkedList<Integer> objectsToPop = new LinkedList<Integer>();
+ /**
+ * If true, print debug statements
+ */
+ public static boolean verbose = false;
+ protected Integer stackedObjects = 0;
+ private ArrayList<List<Object>> errors = new ArrayList<List<Object>>();
+ private ArrayList<List<Object>> warnings = new ArrayList<List<Object>>();
+ private ArrayList<List<Object>> messages = new ArrayList<List<Object>>();
+ private LinkedHashMap<String, Object> collection = new LinkedHashMap<String,Object>();
+ private LinkedHashMap<String, Object> meta = new LinkedHashMap<String,Object>();
+ private ArrayList<Integer> highlightClasses = new ArrayList<Integer>();
+
+ AbstractQueryProcessor() {
+ requestMap.put("@context", "http://ids-mannheim.de/ns/KorAP/json-ld/v0.2/context.jsonld");
+ requestMap.put("errors", errors);
+ requestMap.put("warnings", warnings);
+ requestMap.put("messages", messages);
+ requestMap.put("collection", collection);
+ requestMap.put("query", new LinkedHashMap<String, Object>());
+ requestMap.put("meta", meta);
+ }
+
+ public abstract void process(String query);
+
+ public void addWarning(int code, String msg) {
+ List<Object> warning = Arrays.asList(new Object[]{code, msg});
+ warnings.add(warning);
+ }
+
+ public void addWarning(String msg) {
+ List<Object> warning = Arrays.asList(new Object[]{msg});
+ warnings.add(warning);
+ }
+
+ public void addMessage(int code, String msg) {
+ List<Object> message = Arrays.asList(new Object[]{code, msg});
+ messages.add(message);
+ }
+
+ public void addMessage(String msg) {
+ List<Object> message = Arrays.asList(new Object[]{msg});
+ messages.add(message);
+ }
+
+ public void addError(int code, String msg) {
+ List<Object> error = Arrays.asList(new Object[]{code, msg});
+ errors.add(error);
+ }
+
+ public void addError(List<Object> fullErrorMsg) {
+ errors.add(fullErrorMsg);
+ }
+
+ public void addHighlightClass(int classId) {
+ highlightClasses.add(classId);
+ meta.put("highlight", highlightClasses);
+ }
+
+ public Map<String, Object> getRequestMap() {
+ return requestMap;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java
index 2bb45ad..37a32b3 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java
@@ -65,7 +65,7 @@
/**
* Keeps track of operation:class numbers.
*/
- int classCounter = 0;
+ int classCounter = 1;
/**
* Keeps track of numers of relations processed (important when dealing with multiple predications).
*/
@@ -285,13 +285,13 @@
}
}
}
-
- private void processUnary_linguistic_term(ParseTree node) {
- LinkedHashMap<String, Object> unaryOperator = parseUnaryOperator(node);
- String reference = node.getChild(0).toStringTree(parser).substring(1);
- LinkedHashMap<String, Object> object = nodeVariables.get(reference);
- object.putAll(unaryOperator);
- }
+//
+// private void processUnary_linguistic_term(ParseTree node) {
+// LinkedHashMap<String, Object> unaryOperator = parseUnaryOperator(node);
+// String reference = node.getChild(0).toStringTree(parser).substring(1);
+// LinkedHashMap<String, Object> object = nodeVariables.get(reference);
+// object.putAll(unaryOperator);
+// }
private void processExprTop(ParseTree node) {
List<ParseTree> andTopExprs = getChildrenWithCat(node, "andTopExpr");
@@ -398,7 +398,7 @@
try {
operand = KoralObjectGenerator.wrapInReference(operandStack.pop(), refClassMapping.get(ref), true);
} catch (NoSuchElementException e) {
- operand = KoralObjectGenerator.makeReference(refClassMapping.get(ref), true);
+ operand = KoralObjectGenerator.makeReference(refClassMapping.get(ref));
}
}
nodeReferencesProcessed.put(ref, nodeReferencesProcessed.get(ref)+1);
@@ -550,7 +550,7 @@
LinkedHashMap<String,Object> positionGroup = KoralObjectGenerator.makePosition(new String[]{frame}, null);
operand2 = KoralObjectGenerator.wrapInClass(operand2, ++classCounter);
((ArrayList<Object>) positionGroup.get("operands")).add(group);
- ((ArrayList<Object>) positionGroup.get("operands")).add(KoralObjectGenerator.makeReference(classCounter,true));
+ ((ArrayList<Object>) positionGroup.get("operands")).add(KoralObjectGenerator.makeReference(classCounter));
group = positionGroup;
}
@@ -719,6 +719,22 @@
// relation.put("sharedClasses", sharedClasses);
relation = KoralObjectGenerator.makePosition(frames, new String[]{});
relation.put("groupType", "position");
+ }
+ else if (operator.equals("near")) {
+ relation = new LinkedHashMap<String, Object>();
+ relation.put("groupType", "sequence");
+ ParseTree rangeSpec = getFirstChildWithCat(operatorNode, "rangeSpec");
+ ParseTree star = getFirstChildWithCat(operatorNode, "*");
+ ArrayList<Object> distances = new ArrayList<Object>();
+ if (star != null) {
+ distances.add(KoralObjectGenerator.makeDistance("w", 0, null));
+ relation.put("distances", distances);
+ }
+ if (rangeSpec != null) {
+ distances.add(parseDistance(rangeSpec));
+ relation.put("distances", distances);
+ }
+ relation.put("inOrder", false);
}
else if (operator.equals("identity")) {
//TODO since ANNIS v. 3.1.6
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
index cabf32c..d0490b0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
@@ -352,7 +352,7 @@
"TPEND");
LinkedHashMap<String, Object> submatchgroup =
- KoralObjectGenerator.makeReference(128 + classCounter);
+ KoralObjectGenerator.makeReference(classCounter);
ArrayList<Object> submatchOperands = new ArrayList<Object>();
submatchgroup.put("operands", submatchOperands);
putIntoSuperObject(submatchgroup);
@@ -398,7 +398,7 @@
// constraint applies
if (conditionCount > 1) {
LinkedHashMap<String, Object> focus =
- KoralObjectGenerator.makeReference(128 + classCounter - 2);
+ KoralObjectGenerator.makeReference(classCounter - 2);
ArrayList<Object> focusOperands = new ArrayList<Object>();
focus.put("operands", focusOperands);
focusOperands.add(matchesGroup);
@@ -416,15 +416,15 @@
}
private void processOPNHIT(Tree node) {
- Integer[] classRef = new Integer[] { 128 + classCounter + 1,
- 128 + classCounter + 2 };
+ Integer[] classRef = new Integer[] { classCounter + 1,
+ classCounter + 2 };
// classRef.add(classCounter + 1); // yes, do this twice (two
// classes)!
LinkedHashMap<String, Object> group =
- KoralObjectGenerator.makeReference(128 + classCounter);
+ KoralObjectGenerator.makeReference(classCounter);
LinkedHashMap<String, Object> classRefCheck =
KoralObjectGenerator.makeClassRefOp("classRefOp:inversion", classRef,
- classCounter + 128);
+ classCounter);
ArrayList<Object> operands = new ArrayList<Object>();
operands.add(classRefCheck);
group.put("operands", operands);
@@ -485,20 +485,20 @@
ArrayList<String> check =
(ArrayList<String>) positionOptions.get("classRefCheck");
Integer[] classIn =
- new Integer[] { 128 + classCounter - 2, 128 + classCounter - 1 };
+ new Integer[] { classCounter - 2, classCounter - 1 };
LinkedHashMap<String, Object> classRefCheck =
KoralObjectGenerator.makeClassRefCheck(check, classIn,
- 128 + classCounter);
+ classCounter);
((ArrayList<Object>) classRefCheck.get("operands")).add(posgroup);
LinkedHashMap<String, Object> focusGroup = null;
if ((boolean) positionOptions.get("matchall") == true) {
focusGroup = KoralObjectGenerator.makeClassRefOp("classRefOp:delete",
- new Integer[]{128+classCounter++}, 128+classCounter);
+ new Integer[]{classCounter++}, classCounter);
((ArrayList<Object>) focusGroup.get("operands")).add(classRefCheck);
}
else { // match only first argument
focusGroup = KoralObjectGenerator.wrapInReference(classRefCheck,
- 128 + classCounter);
+ classCounter);
}
// wrap in 'merge' operation if grouping option is set
if (positionOptions.containsKey("grouping")) {
@@ -596,7 +596,7 @@
wrapOperandInClass(node, 1, classCounter);
wrapOperandInClass(node, 2, classCounter);
group = KoralObjectGenerator.wrapInReference(group,
- 128 + classCounter++);
+ classCounter++);
}
else if (openNodeCats.get(1).equals("OPNHIT")) {
LinkedHashMap<String, Object> repetition = KoralObjectGenerator
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 00da8d2..4a61c26 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
@@ -23,7 +23,7 @@
private static Logger log = LoggerFactory
.getLogger(PoliqarpPlusQueryProcessor.class);
- private int classCounter = 128;
+ private int classCounter = 1;
/**
* Most centrally, this class maintains a set of nested maps and
@@ -83,8 +83,6 @@
else
visited.add(node);
- currentNode = node;
-
String nodeCat = getNodeCat(node);
openNodeCats.push(nodeCat);
@@ -261,7 +259,8 @@
.toStringTree(parser));
}
LinkedHashMap<String, Object> classGroup =
- KoralObjectGenerator.makeSpanClass(classId, false);
+ KoralObjectGenerator.makeSpanClass(classId);
+ addHighlightClass(classId);
putIntoSuperObject(classGroup);
objectStack.push(classGroup);
stackedObjects++;
@@ -321,7 +320,7 @@
@SuppressWarnings("unchecked")
private void processAlignment(ParseTree node) {
LinkedHashMap<String, Object> alignClass =
- KoralObjectGenerator.makeSpanClass(++classCounter, false);
+ KoralObjectGenerator.makeSpanClass(classCounter);
LinkedHashMap<String, Object> metaMap =
(LinkedHashMap<String, Object>) requestMap.get("meta");
if (metaMap.containsKey("alignment")) {
@@ -338,7 +337,7 @@
else {
metaMap.put("alignment", classCounter);
}
-
+ classCounter++;
putIntoSuperObject(alignClass);
objectStack.push(alignClass);
stackedObjects++;
@@ -413,6 +412,8 @@
relation.put("wrap", term);
if (node.getChild(0).getText().equals("dominates")) {
term.put("layer", "c");
+ } else if (node.getChild(0).getText().equals("dependency")) {
+ term.put("layer", "d");
}
ParseTree relSpec = getFirstChildWithCat(node, "relSpec");
ParseTree repetition = getFirstChildWithCat(node, "repetition");
@@ -452,15 +453,16 @@
addError(StatusCodes.UNDEFINED_CLASS_REFERENCE, msg);
}
// only allow class id up to 127
- if (classId > 127) {
- addWarning("Only class IDs up to 127 are allowed. Your class "
- + classId + " has been set back to 127. "
+ if (classId > 128) {
+ addWarning("Only class IDs up to 128 are allowed. Your class "
+ + classId + " has been set back to 128. "
+ "Check for possible conflict with other classes.");
- classId = 127;
+ classId = 128;
}
}
LinkedHashMap<String, Object> classGroup =
- KoralObjectGenerator.makeSpanClass(classId, false);
+ KoralObjectGenerator.makeSpanClass(classId);
+ addHighlightClass(classId);
putIntoSuperObject(classGroup);
objectStack.push(classGroup);
stackedObjects++;
@@ -481,14 +483,14 @@
else {
try {
int classRef = Integer.parseInt(ref);
- // only allow class id up to 127
- if (classRef > 127) {
- addWarning("Only class references up to 127 are "
+ // only allow class id up to 128
+ if (classRef > 128) {
+ addWarning("Only class references up to 128 are "
+ "allowed. Your reference to class "
- + classRef + " has been set back to 127. "
+ + classRef + " has been set back to 128. "
+ "Check for possible conflict with "
+ "other classes.");
- classRef = 127;
+ classRef = 128;
}
classRefs.add(classRef);
}
@@ -677,6 +679,8 @@
* negated, e.g. through a negation operator preceding
* the related token like "![base=foo]". Global
* negation affects the term's "match" parameter.
+ * @param mode 'token' or 'span' (tokens and spans are treated
+ * differently).
* @return A term or termGroup object, depending on input
*/
@SuppressWarnings("unchecked")
@@ -706,12 +710,17 @@
// process layer: map "base" -> "lemma"
if (layerNode != null) {
String layer = layerNode.getText();
- if (layer.equals("base"))
- layer = "lemma";
- if (mode.equals("span"))
+ if (mode.equals("span")) {
term.put("key", layer);
- else
+ } else if (mode.equals("token")) {
+ if (layer.equals("base")) {
+ layer = "lemma"; }
+ else if (layer.equals("punct")) {
+ layer = "orth";
+ term.put("type", "type:punct");
+ }
term.put("layer", layer);
+ }
}
// process key: 'normal' or regex?
key = keyNode.getText();
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java b/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java
index 804b8f9..befa081 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java
@@ -99,9 +99,10 @@
}
public static LinkedHashMap<String, Object> makeSpanClass(int classCount) {
- return makeSpanClass(classCount, true);
+ return makeSpanClass(classCount, false);
}
+ @Deprecated
public static LinkedHashMap<String, Object> makeSpanClass(int classId,
boolean setBySystem) {
LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
@@ -215,6 +216,7 @@
return makeReference(classRefs, "focus");
}
+ @Deprecated
public static LinkedHashMap<String, Object> makeReference(int classRef,
String operation, boolean setBySystem) {
ArrayList<Integer> classRefs = new ArrayList<Integer>();
@@ -224,6 +226,7 @@
return makeReference(classRefs, operation);
}
+ @Deprecated
public static LinkedHashMap<String, Object> makeReference(int classRef,
boolean setBySystem) {
ArrayList<Integer> classRefs = new ArrayList<Integer>();
@@ -270,7 +273,7 @@
public static LinkedHashMap<String, Object> wrapInReference(
LinkedHashMap<String, Object> group, Integer classId,
boolean setBySystem) {
- LinkedHashMap<String, Object> refGroup = makeReference(classId, setBySystem);
+ LinkedHashMap<String, Object> refGroup = makeReference(classId);
ArrayList<Object> operands = new ArrayList<Object>();
operands.add(group);
refGroup.put("operands", operands);
@@ -280,7 +283,7 @@
@SuppressWarnings("unchecked")
public static LinkedHashMap<String, Object> wrapInClass(
LinkedHashMap<String, Object> group, Integer classId) {
- LinkedHashMap<String, Object> classGroup = makeSpanClass(classId, true);
+ LinkedHashMap<String, Object> classGroup = makeSpanClass(classId);
((ArrayList<Object>) classGroup.get("operands")).add(group);
return classGroup;
}
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java
index b3afe99..f01a38a 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java
@@ -262,12 +262,12 @@
assertEquals("S", res.at("/query/operands/0/operands/0/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/1/classOut").asInt());
assertEquals("korap:span", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("NP", res.at("/query/operands/0/operands/1/operands/0/key").asText());
assertEquals("korap:reference", res.at("/query/operands/1/@type").asText());
assertEquals("operation:focus", res.at("/query/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/1/classRef/0").asInt());
+ assertEquals(2, res.at("/query/operands/1/classRef/0").asInt());
query = "cat=\"S\" & cat=\"NP\" & #1 >@r #2";
qs.setQuery(query, "annis");
@@ -279,12 +279,12 @@
assertEquals("S", res.at("/query/operands/0/operands/0/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/1/classOut").asInt());
assertEquals("korap:span", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("NP", res.at("/query/operands/0/operands/1/operands/0/key").asText());
assertEquals("korap:reference", res.at("/query/operands/1/@type").asText());
assertEquals("operation:focus", res.at("/query/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/1/classRef/0").asInt());
+ assertEquals(2, res.at("/query/operands/1/classRef/0").asInt());
}
@Test
@@ -319,7 +319,7 @@
assertEquals("operation:relation", res.at("/query/operation").asText());
assertEquals("korap:reference", res.at("/query/operands/0/@type").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals(1, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("korap:relation", res.at("/query/operands/0/operands/0/relation/@type").asText());
@@ -329,7 +329,7 @@
assertEquals("CP", res.at("/query/operands/0/operands/0/operands/0/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(128, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("VP", res.at("/query/operands/0/operands/0/operands/1/operands/0/key").asText());
}
// query = "cat=\"CP\" & cat=\"VP\" & cat=\"NP\" & #1 > #2 > #3";
@@ -338,7 +338,7 @@
// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
// "{@type=korap:group, operation=operation:relation, operands=[" +
// "{@type=korap:span, layer=cat, key=CP, match=match:eq}," +
- // "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+ // "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
// "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
// "]}" +
// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
@@ -358,12 +358,12 @@
// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
// "{@type=korap:group, operation=operation:relation, operands=[" +
// "{@type=korap:span, layer=cat, key=CP, match=match:eq}," +
- // "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+ // "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
// "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
// "]}" +
// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
// "]}," +
- // "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
+ // "{@type=korap:group, operation=operation:class, class=2, classOut=2, operands=[" +
// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
// "]}" +
// "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
@@ -400,76 +400,86 @@
// map = aqlt.getRequestMap().get("query").toString();
// assertEquals(dom2.replaceAll(" ", ""), map.replaceAll(" ", ""));
// }
- //
- // @Test
- // public void testSequence() throws Exception {
- // query = "node & node & #1 . #2";
- // String seq1 =
- // "{@type=korap:group, operation=operation:sequence, " +
- // "operands=[" +
- // "{@type=korap:span}," +
- // "{@type=korap:span}" +
- // "], inOrder=true" +
- // "}";
- // aqlt = new AqlTree(query);
- // map = aqlt.getRequestMap().get("query").toString();
- // assertEquals(seq1.replaceAll(" ", ""), map.replaceAll(" ", ""));
- //
- // query = "node & node & #1 .* #2";
- // String seq2 =
- // "{@type=korap:group, operation=operation:sequence, operands=[" +
- // "{@type=korap:span}," +
- // "{@type=korap:span}" +
- // "], distances=[" +
- // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0}, min=0}" +
- // "], inOrder=true" +
- // "}";
- // aqlt = new AqlTree(query);
- // map = aqlt.getRequestMap().get("query").toString();
- // assertEquals(seq2.replaceAll(" ", ""), map.replaceAll(" ", ""));
- //
- // query = "node & node & #1 .2,3 #2";
- // String seq3 =
- // "{@type=korap:group, operation=operation:sequence, operands=[" +
- // "{@type=korap:span}," +
- // "{@type=korap:span}" +
- // "], distances=[" +
- // "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=2, max=3}, min=2, max=3}" +
- // "], inOrder=true" +
- // "}";
- // aqlt = new AqlTree(query);
- // map = aqlt.getRequestMap().get("query").toString();
- // assertEquals(seq3.replaceAll(" ", ""), map.replaceAll(" ", ""));
- //
- // }
- //
+
+ @Test
+ public void testSequence() throws Exception {
+ query = "tok=\"der\" & tok=\"die\" & #1 . #2";
+ qs.setQuery(query, "annis");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("korap:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("die", res.at("/query/operands/1/wrap/key").asText());
+ assertEquals(true, res.at("/query/inOrder").asBoolean());
+ assertEquals(true, res.at("/query/operands/2").isMissingNode());
+
+ query = "tok=\"der\" & tok=\"die\" & #1 .2,3 #2";
+ qs.setQuery(query, "annis");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("korap:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("die", res.at("/query/operands/1/wrap/key").asText());
+ assertEquals(true, res.at("/query/inOrder").asBoolean());
+ assertEquals(true, res.at("/query/operands/2").isMissingNode());
+ assertEquals("korap:distance", res.at("/query/distances/0/@type").asText());
+ assertEquals("korap:boundary", res.at("/query/distances/0/boundary/@type").asText());
+ assertEquals(2, res.at("/query/distances/0/boundary/min").asInt());
+ assertEquals(3, res.at("/query/distances/0/boundary/max").asInt());
+
+ query = "tok=\"der\" & tok=\"die\" & #1 .* #2";
+ qs.setQuery(query, "annis");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("korap:boundary", res.at("/query/distances/0/boundary/@type").asText());
+ assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
+ assertEquals(true, res.at("/query/distances/0/boundary/max").isMissingNode());
+ }
+
+ @Test
+ public void testNear() throws Exception {
+ query = "tok=\"der\" & tok=\"die\" & #1 ^ #2";
+ qs.setQuery(query, "annis");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("korap:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("die", res.at("/query/operands/1/wrap/key").asText());
+ assertEquals(false, res.at("/query/inOrder").asBoolean());
+ assertEquals(true, res.at("/query/operands/2").isMissingNode());
+
+ query = "tok=\"der\" & tok=\"die\" & #1 ^2,3 #2";
+ qs.setQuery(query, "annis");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("korap:group", res.at("/query/@type").asText());
+ assertEquals("operation:sequence", res.at("/query/operation").asText());
+ assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("die", res.at("/query/operands/1/wrap/key").asText());
+ assertEquals(false, res.at("/query/inOrder").asBoolean());
+ assertEquals(true, res.at("/query/operands/2").isMissingNode());
+ assertEquals("korap:distance", res.at("/query/distances/0/@type").asText());
+ assertEquals("korap:boundary", res.at("/query/distances/0/boundary/@type").asText());
+ assertEquals(2, res.at("/query/distances/0/boundary/min").asInt());
+ assertEquals(3, res.at("/query/distances/0/boundary/max").asInt());
+
+ query = "tok=\"der\" & tok=\"die\" & #1 ^* #2";
+ qs.setQuery(query, "annis");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("korap:boundary", res.at("/query/distances/0/boundary/@type").asText());
+ assertEquals(0, res.at("/query/distances/0/boundary/min").asInt());
+ assertEquals(true, res.at("/query/distances/0/boundary/max").isMissingNode());
+ assertEquals(false, res.at("/query/inOrder").asBoolean());
+ }
+
+
@Test
public void testMultipleSequence() throws Exception {
query = "tok=\"a\" & tok=\"b\" & tok=\"c\" & #1 . #2 & #2 . #3";
- String seq4 =
- "{@type=korap:group, operation=operation:sequence," +
- "operands=[" +
- "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
- "{@type=korap:group, operation=operation:sequence, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
- "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
- "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
- "]}" +
- "], distances=[" +
- "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
- "], inOrder=true}" +
- "]}," +
- "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
- "],distances=[" +
- "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=4}, min=0, max=4}" +
- "], inOrder=true" +
- "}";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("korap:group", res.at("/query/@type").asText());
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("korap:reference", res.at("/query/operands/0/@type").asText());
- assertEquals(128, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals(1, res.at("/query/operands/0/classRef/0").asInt());
assertEquals(res.at("/query/operands/0/classRef/0").asInt(),
res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
}
@@ -482,7 +492,7 @@
// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
// "{@type=korap:group, operation=operation:sequence, operands=[" +
// "{@type=korap:span}," +
- // "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+ // "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
// "{@type=korap:span}" +
// "]} "+
// "], inOrder=true}" +
@@ -504,14 +514,14 @@
// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
// "{@type=korap:group, operation=operation:sequence, operands=[" +
// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sonne, match=match:eq}}," +
- // "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+ // "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Mond, match=match:eq}}" +
// "]}" +
// "], distances=[" +
// "{@type=korap:distance, key=w, boundary={@type=korap:boundary, min=0, max=2}, min=0, max=2}" +
// "], inOrder=true}" +
// "]}," +
- // "{@type=korap:group, operation=operation:class, class=129, classOut=129, operands=[" +
+ // "{@type=korap:group, operation=operation:class, class=2, classOut=2, operands=[" +
// "{@type=korap:token, wrap={@type=korap:term, layer=orth, key=Sterne, match=match:eq}}" +
// "]}" +
// "],distances=[" +
@@ -593,14 +603,14 @@
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("korap:reference", res.at("/query/operands/0/@type").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals(1, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(128, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("Mond", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("Sterne", res.at("/query/operands/1/wrap/key").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
@@ -614,14 +624,14 @@
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("korap:reference", res.at("/query/operands/0/@type").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals(1, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(128, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("Mond", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("Sterne", res.at("/query/operands/1/wrap/key").asText());
assertEquals("w", res.at("/query/distances/0/key").asText());
@@ -635,21 +645,21 @@
assertEquals("operation:relation", res.at("/query/operation").asText());
assertEquals("korap:reference", res.at("/query/operands/0/@type").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
- assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals(2, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("korap:reference", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/operands/0/operands/0/classRef/0").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/0/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
assertEquals("operation:relation", res.at("/query/operands/0/operands/0/operands/0/operands/0/operation").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/classOut").asInt());
assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/@type").asText());
assertEquals("NP", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("VP", res.at("/query/operands/0/operands/0/operands/1/operands/0/key").asText());
assertEquals("PP", res.at("/query/operands/1/key").asText());
@@ -662,21 +672,21 @@
assertEquals("korap:group", res.at("/query/@type").asText());
assertEquals("operation:position", res.at("/query/operation").asText());
assertEquals("frames:startswith", res.at("/query/frames/0").asText());
- assertEquals("korap:reference", res.at("/query/operands/0/@type").asText());
- assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals("korap:reference", res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
+ assertEquals(1, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:relation", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
assertEquals("NP", res.at("/query/operands/0/operands/0/operands/0/operands/0/key").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("VP", res.at("/query/operands/0/operands/0/operands/1/operands/0/key").asText());
assertEquals("korap:reference", res.at("/query/operands/1/@type").asText());
assertEquals("operation:focus", res.at("/query/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/1/classRef/0").asInt());
+ assertEquals(2, res.at("/query/operands/1/classRef/0").asInt());
}
@Test
@@ -732,12 +742,12 @@
res = mapper.readTree(qs.toJSON());
assertEquals("frames:startswith", res.at("/query/frames/0").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals(1, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("frames:endswith", res.at("/query/operands/0/operands/0/frames/0").asText());
assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(128, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("VP", res.at("/query/operands/0/operands/0/operands/1/operands/0/key").asText());
assertEquals("NP", res.at("/query/operands/1/key").asText());
@@ -775,14 +785,14 @@
res = mapper.readTree(qs.toJSON());
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals(1, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("p", res.at("/query/operands/0/operands/0/operands/0/wrap/layer").asText());
assertEquals("N", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(128, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("V", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("P", res.at("/query/operands/1/wrap/key").asText());
@@ -791,14 +801,14 @@
res = mapper.readTree(qs.toJSON());
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals(1, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("p", res.at("/query/operands/0/operands/0/operands/0/wrap/layer").asText());
assertEquals("N", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(128, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("V", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("P", res.at("/query/operands/1/wrap/key").asText());
@@ -807,10 +817,10 @@
res = mapper.readTree(qs.toJSON());
assertEquals("operation:relation", res.at("/query/operation").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals(1, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("operation:relation", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
assertEquals("N", res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("V", res.at("/query/operands/0/operands/0/operands/1/wrap/key").asText());
assertEquals("P", res.at("/query/operands/1/wrap/key").asText());
@@ -820,20 +830,20 @@
res = mapper.readTree(qs.toJSON());
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
- assertEquals(129, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals(2, res.at("/query/operands/0/classRef/0").asInt());
assertEquals("operation:relation", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/operands/0/operands/0/classRef/0").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/0/classRef/0").asInt());
assertEquals("operation:relation", res.at("/query/operands/0/operands/0/operands/0/operands/0/operation").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operation").asText());
- assertEquals(128, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/classOut").asInt());
assertEquals("NP", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/key").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("V", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
- assertEquals(130, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(3, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("P", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("operation:focus", res.at("/query/operands/1/operation").asText());
- assertEquals(130, res.at("/query/operands/1/classRef/0").asInt());
+ assertEquals(3, res.at("/query/operands/1/classRef/0").asInt());
assertEquals(true, res.at("/query/operands/1/operands").isMissingNode());
}
@@ -847,7 +857,7 @@
assertEquals("korap:boundary", res.at("/query/attr/tokenarity/@type").asText());
assertEquals(2, res.at("/query/attr/tokenarity/min").asInt());
assertEquals(2, res.at("/query/attr/tokenarity/max").asInt());
-
+
query = "cnx/cat=\"NP\" & #1:tokenarity=2";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
@@ -859,13 +869,13 @@
assertEquals("korap:boundary", res.at("/query/attr/tokenarity/@type").asText());
assertEquals(2, res.at("/query/attr/tokenarity/min").asInt());
assertEquals(2, res.at("/query/attr/tokenarity/max").asInt());
-
+
query = "cnx/cat=\"NP\" & #1:tokenarity=2,5";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals(2, res.at("/query/attr/tokenarity/min").asInt());
assertEquals(5, res.at("/query/attr/tokenarity/max").asInt());
-
+
query = "cnx/cat=\"NP\" & #1:root";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
@@ -875,7 +885,7 @@
assertEquals("NP", res.at("/query/key").asText());
assertEquals("korap:term", res.at("/query/attr/@type").asText());
assertEquals(true, res.at("/query/attr/root").asBoolean());
-
+
query = "cnx/cat=\"NP\" & node & #1>#2 & #1:tokenarity=2";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
@@ -890,28 +900,44 @@
assertEquals(2, res.at("/query/operands/0/attr/tokenarity/min").asInt());
assertEquals(2, res.at("/query/operands/0/attr/tokenarity/max").asInt());
assertEquals("korap:span", res.at("/query/operands/1/@type").asText());
-
+
}
- // @Test
- // public void testCommonParent() throws Exception {
- // query = "cat=\"NP\" & cat=\"VP\" & #1 $ #2";
- // String cp1 =
- // "{@type=korap:group, operation=operation:relation, operands=[" +
- // "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
- // "{@type=korap:group, operation=operation:relation, operands=[" +
- // "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
- // "{@type=korap:span}" +
- // "]}," +
- // "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
- // "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
- // "]}," +
- // "{@type=korap:span, layer=cat, key=VP, match=match:eq}" +
- // "], relation={@type=korap:relation, wrap={@type=korap:term, layer=c}}}" +
- // "";
- // aqlt = new AqlTree(query);
- // map = aqlt.getRequestMap().get("query").toString();
- // assertEquals(cp1.replaceAll(" ", ""), map.replaceAll(" ", ""));
+ @Test
+ public void testCommonParent() throws Exception {
+ query = "cat=\"NP\" & cat=\"VP\" & #1 $ #2";
+ qs.setQuery(query, "annis");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("korap:group", res.at("/query/@type").asText());
+ assertEquals("operation:relation", res.at("/query/operation").asText());
+ assertEquals("korap:reference", res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
+ assertEquals(1, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("operation:relation", res.at("/query/operands/0/operands/0/operation").asText());
+ assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
+ assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
+ assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
+ assertEquals(true, res.at("/query/operands/0/operands/0/operands/0/operands/0/key").isMissingNode());
+ assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
+ assertEquals("NP", res.at("/query/operands/0/operands/0/operands/1/key").asText());
+ assertEquals("c", res.at("/query/operands/0/operands/0/operands/1/layer").asText());
+ assertEquals("korap:span", res.at("/query/operands/1/@type").asText());
+ assertEquals("VP", res.at("/query/operands/1/key").asText());
+ assertEquals("c", res.at("/query/operands/1/layer").asText());
+
+ query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & #1 $ #2 $ #3";
+ qs.setQuery(query, "annis");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("korap:group", res.at("/query/@type").asText());
+ assertEquals("operation:relation", res.at("/query/operation").asText());
+ assertEquals("korap:reference", res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:focus", res.at("/query/operands/0/operation").asText());
+ assertEquals(1, res.at("/query/operands/0/classRef/0").asInt());
+ assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
+ assertEquals("operation:relation", res.at("/query/operands/0/operands/0/operation").asText());
+ }
//
// query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & #1 $ #2 $ #3";
// String cp2 =
@@ -920,7 +946,7 @@
// "{@type=korap:group, operation=operation:relation, operands=[" +
// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
// "{@type=korap:group, operation=operation:relation, operands=[" +
- // "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+ // "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
// "{@type=korap:span}" +
// "]}," +
// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
@@ -946,7 +972,7 @@
// "{@type=korap:group, operation=operation:relation, operands=[" +
// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
// "{@type=korap:group, operation=operation:relation, operands=[" +
- // "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+ // "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
// "{@type=korap:span}" +
// "]}," +
// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
@@ -971,7 +997,7 @@
// "{@type=korap:group, operation=operation:relation, operands=[" +
// "{@type=korap:reference, operation=operation:focus, classRef=[0], operands=[" +
// "{@type=korap:group, operation=operation:relation, operands=[" +
- // "{@type=korap:group, operation=operation:class, class=128, classOut=128, operands=[" +
+ // "{@type=korap:group, operation=operation:class, class=1, classOut=1, operands=[" +
// "{@type=korap:span}" +
// "]}," +
// "{@type=korap:span, layer=cat, key=NP, match=match:eq}" +
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java
index df30e6d..92f6a16 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java
@@ -400,7 +400,7 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
@@ -410,8 +410,8 @@
assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/1/classOut").asInt());
assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
@@ -421,7 +421,7 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
@@ -436,8 +436,8 @@
assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/1/classOut").asInt());
assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
@@ -479,7 +479,7 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
@@ -489,19 +489,19 @@
assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/classOut").asInt());
assertEquals("Sonne", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/1/classOut").asInt());
assertEquals("korap:reference", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
- assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/classRef/0").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/1/operands/0/classRef/0").asInt());
assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operands/0/operation").asText());
assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText());
assertEquals("w", res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/key").asText());
assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/min").asInt());
assertEquals(7, res.at("/query/operands/0/operands/1/operands/0/operands/0/distances/0/boundary/max").asInt());
- assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/classOut").asInt());
assertEquals("Mond", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
- assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("Sterne", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
query = "Sonne /+w1:4 Mond /-w1:7 Sterne";
@@ -516,7 +516,7 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
@@ -526,19 +526,19 @@
assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/1/classOut").asInt());
assertEquals("Sonne", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/classOut").asInt());
assertEquals("korap:reference", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
- assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/classRef/0").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/0/operands/0/classRef/0").asInt());
assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/0/operands/0/operation").asText());
assertEquals("w", res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/key").asText());
assertEquals(0, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/min").asInt());
assertEquals(2, res.at("/query/operands/0/operands/0/operands/0/operands/0/distances/0/boundary/max").asInt());
- assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/classOut").asInt());
assertEquals("Mond", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
- assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("Sterne", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
}
@@ -550,24 +550,24 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(131, res.at("/query/classRef/0").asInt());
+ assertEquals(3, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
assertEquals("classRefCheck:includes", res.at("/query/operands/0/classRefCheck/0").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals(true, res.at("/query/operands/0/operands/0/frames/0").isMissingNode());
- assertEquals(129, res.at("/query/operands/0/classIn/0").asInt());
- assertEquals(130, res.at("/query/operands/0/classIn/1").asInt());
- assertEquals(131, res.at("/query/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/classIn/0").asInt());
+ assertEquals(2, res.at("/query/operands/0/classIn/1").asInt());
+ assertEquals(3, res.at("/query/operands/0/classOut").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/operands/0/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(130, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/1/operands/0/@type").asText());
assertEquals("wegen", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
@@ -620,7 +620,7 @@
res = mapper.readTree(qs.toJSON());
assertEquals("operation:class", res.at("/query/operation").asText());
assertEquals("classRefOp:delete", res.at("/query/classRefOp").asText());
- assertEquals(131, res.at("/query/classIn/0").asInt());
+ assertEquals(3, res.at("/query/classIn/0").asInt());
assertEquals("classRefCheck:equals", res.at("/query/operands/0/classRefCheck/0").asText());
assertEquals("frames:matches", res.at("/query/operands/0/operands/0/frames/0").asText());
assertEquals(true, res.at("/query/operands/0/operands/0/exclude").asBoolean());
@@ -631,7 +631,7 @@
assertEquals("operation:merge", res.at("/query/operation").asText());
assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
assertEquals("classRefOp:delete", res.at("/query/operands/0/classRefOp").asText());
- assertEquals(131, res.at("/query/operands/0/classIn/0").asInt());
+ assertEquals(3, res.at("/query/operands/0/classIn/0").asInt());
assertEquals("classRefCheck:equals", res.at("/query/operands/0/operands/0/classRefCheck/0").asText());
assertEquals("frames:matches", res.at("/query/operands/0/operands/0/operands/0/frames/0").asText());
assertEquals(true, res.at("/query/operands/0/operands/0/operands/0/exclude").asBoolean());
@@ -644,25 +644,25 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(131, res.at("/query/classRef/0").asInt());
+ assertEquals(3, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
assertEquals("classRefCheck:intersects", res.at("/query/operands/0/classRefCheck/0").asText());
// assertEquals("classRefOp:merge", res.at("/query/operands/0/classRefOp").asText());
- assertEquals(131, res.at("/query/operands/0/classOut").asInt());
- assertEquals(129, res.at("/query/operands/0/classIn/0").asInt());
- assertEquals(130, res.at("/query/operands/0/classIn/1").asInt());
+ assertEquals(3, res.at("/query/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/classIn/0").asInt());
+ assertEquals(2, res.at("/query/operands/0/classIn/1").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:position", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals(true, res.at("/query/operands/0/operands/0/frames/0").isMissingNode());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
assertEquals("korap:span", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/operands/0/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(130, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/1/operands/0/@type").asText());
assertEquals("wegen", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
@@ -719,7 +719,7 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
@@ -729,7 +729,7 @@
assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/classOut").asInt());
assertEquals("korap:reference", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
assertEquals(0, res.at("/query/operands/0/operands/0/operands/0/spanRef/0").asInt());
@@ -745,7 +745,7 @@
assertEquals("der", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("Mann", res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/wrap/key").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/1/classOut").asInt());
assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("kommt", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
@@ -754,7 +754,7 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
assertEquals("korap:distance", res.at("/query/operands/0/distances/0/@type").asText());
@@ -764,7 +764,7 @@
assertEquals(true, res.at("/query/operands/0/inOrder").asBoolean());
assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/1/classOut").asInt());
assertEquals("korap:reference", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operands/0/operation").asText());
assertEquals(0, res.at("/query/operands/0/operands/1/operands/0/spanRef/0").asInt());
@@ -780,7 +780,7 @@
assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("Mann", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/wrap/key").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/classOut").asInt());
assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("kommt", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
@@ -916,13 +916,13 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
assertEquals("classRefOp:inversion",res.at("/query/operands/0/classRefOp").asText());
- assertEquals(130, res.at("/query/operands/0/classIn/0").asInt());
- assertEquals(131, res.at("/query/operands/0/classIn/1").asInt());
- assertEquals(129, res.at("/query/operands/0/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/classIn/0").asInt());
+ assertEquals(3, res.at("/query/operands/0/classIn/1").asInt());
+ assertEquals(1, res.at("/query/operands/0/classOut").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("korap:distance", res.at("/query/operands/0/operands/0/distances/0/@type").asText());
@@ -931,8 +931,8 @@
assertEquals(10, res.at("/query/operands/0/operands/0/distances/0/boundary/max").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
- assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
- assertEquals(131, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
+ assertEquals(3, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("korap:token", res.at("/query/operands/0/operands/0/operands/0/operands/0/@type").asText());
assertEquals("gehen", res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("voran", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
@@ -942,13 +942,13 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
assertEquals("classRefOp:inversion",res.at("/query/operands/0/classRefOp").asText());
- assertEquals(130, res.at("/query/operands/0/classIn/0").asInt());
- assertEquals(131, res.at("/query/operands/0/classIn/1").asInt());
- assertEquals(129, res.at("/query/operands/0/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/classIn/0").asInt());
+ assertEquals(3, res.at("/query/operands/0/classIn/1").asInt());
+ assertEquals(1, res.at("/query/operands/0/classOut").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("korap:distance", res.at("/query/operands/0/operands/0/distances/0/@type").asText());
@@ -957,15 +957,15 @@
assertEquals(10, res.at("/query/operands/0/operands/0/distances/0/boundary/max").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/0/operation").asText());
- assertEquals(130, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
- assertEquals(131, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
+ assertEquals(3, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("gehen", res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operands/0/operands/1/operands/0/operation").asText());
- assertEquals(132, res.at("/query/operands/0/operands/0/operands/1/operands/0/classRef/0").asInt());
+ assertEquals(4, res.at("/query/operands/0/operands/0/operands/1/operands/0/classRef/0").asInt());
assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operation").asText());
- assertEquals(132, res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/0/classOut").asInt());
+ assertEquals(4, res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/0/classOut").asInt());
assertEquals("voran", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
- assertEquals(132, res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(4, res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("Beispiel", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
}
@@ -977,13 +977,13 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:position", res.at("/query/operands/0/operation").asText());
assertEquals("frames:startswith", res.at("/query/operands/0/frames/0").asText());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/1/classOut").asInt());
assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("korap:span", res.at("/query/operands/0/operands/0/@type").asText());
@@ -994,7 +994,7 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:position", res.at("/query/operands/0/operation").asText());
assertEquals("frames:matches", res.at("/query/operands/0/frames/0").asText());
@@ -1010,7 +1010,7 @@
assertEquals(1, res.at("/query/operands/0/operands/1/spanRef/1").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/0/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/1/operands/0/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/classOut").asInt());
assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText());
assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("Mann", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/wrap/key").asText());
@@ -1020,7 +1020,7 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:position", res.at("/query/operands/0/operation").asText());
assertEquals("frames:matches", res.at("/query/operands/0/frames/0").asText());
@@ -1032,7 +1032,7 @@
assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("operation:sequence", res.at("/query/operands/0/operands/0/operands/1/operands/0/operation").asText());
assertEquals("der", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/wrap/key").asText());
assertEquals("Mann", res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/1/wrap/key").asText());
@@ -1045,7 +1045,7 @@
assertEquals("p", res.at("/query/operands/0/operands/1/operands/0/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/1/operation").asText());
- assertEquals(130, res.at("/query/operands/0/operands/1/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/1/operands/1/classOut").asInt());
assertEquals("operation:sequence", res.at("/query/operands/0/operands/1/operands/1/operands/0/operation").asText());
assertEquals("der", res.at("/query/operands/0/operands/1/operands/1/operands/0/operands/0/wrap/key").asText());
assertEquals("Mann", res.at("/query/operands/0/operands/1/operands/1/operands/0/operands/1/wrap/key").asText());
@@ -1059,13 +1059,13 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:position", res.at("/query/operands/0/operation").asText());
assertEquals("frames:startswith", res.at("/query/operands/0/frames/0").asText());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/1/classOut").asInt());
assertEquals("korap:token", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("korap:span", res.at("/query/operands/0/operands/0/@type").asText());
@@ -1076,7 +1076,7 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:position", res.at("/query/operands/0/operation").asText());
assertEquals("frames:matches", res.at("/query/operands/0/frames/0").asText());
@@ -1087,7 +1087,7 @@
assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("der", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:position", res.at("/query/operands/0/operands/1/operation").asText());
@@ -1097,7 +1097,7 @@
assertEquals("p", res.at("/query/operands/0/operands/1/operands/0/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/1/operation").asText());
- assertEquals(130, res.at("/query/operands/0/operands/1/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/1/operands/1/classOut").asInt());
assertEquals("der", res.at("/query/operands/0/operands/1/operands/1/operands/0/wrap/key").asText());
query = "der:sa,-pa,+te";
@@ -1105,7 +1105,7 @@
res = mapper.readTree(qs.toJSON());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:focus", res.at("/query/operation").asText());
- assertEquals(129, res.at("/query/classRef/0").asInt());
+ assertEquals(1, res.at("/query/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/@type").asText());
assertEquals("operation:position", res.at("/query/operands/0/operation").asText());
assertEquals("frames:matches", res.at("/query/operands/0/frames/0").asText());
@@ -1116,11 +1116,11 @@
assertEquals("s", res.at("/query/operands/0/operands/0/operands/0/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("der", res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("korap:reference", res.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:focus", res.at("/query/operands/0/operands/1/operation").asText());
- assertEquals(130, res.at("/query/operands/0/operands/1/classRef/0").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/1/classRef/0").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/@type").asText());
assertEquals("operation:position", res.at("/query/operands/0/operands/1/operands/0/operation").asText());
assertEquals("frames:matches", res.at("/query/operands/0/operands/1/operands/0/frames/0").asText());
@@ -1132,7 +1132,7 @@
assertEquals("p", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operation").asText());
- assertEquals(130, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt());
+ assertEquals(2, res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/classOut").asInt());
assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/1/@type").asText());
assertEquals("operation:position", res.at("/query/operands/0/operands/1/operands/0/operands/1/operation").asText());
@@ -1149,7 +1149,7 @@
assertEquals(1, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/spanRef/1").asInt());
assertEquals("korap:group", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/@type").asText());
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/operation").asText());
- assertEquals(131, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/classOut").asInt());
+ assertEquals(3, res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/classOut").asInt());
assertEquals("der", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/1/operands/0/operands/0/wrap/key").asText());
}
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessorTest.java
index 44519ec..c0b91f7 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessorTest.java
@@ -136,10 +136,22 @@
assertEquals("type:regex", res.at("/query/wrap/type").asText());
assertEquals("orth", res.at("/query/wrap/layer").asText());
assertEquals("match:eq", res.at("/query/wrap/match").asText());
-
}
@Test
+ public void testPunct() throws JsonProcessingException, IOException {
+ query = "[punct=.]";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("korap:token", res.at("/query/@type").asText());
+ assertEquals("korap:term", res.at("/query/wrap/@type").asText());
+ assertEquals(".", res.at("/query/wrap/key").asText());
+ assertEquals("type:punct", res.at("/query/wrap/type").asText());
+ assertEquals("orth", res.at("/query/wrap/layer").asText());
+ assertEquals("match:eq", res.at("/query/wrap/match").asText());
+ }
+
+ @Test
public void testCaseSensitivityFlag() throws JsonProcessingException, IOException {
query = "[orth=deutscher/i]";
qs.setQuery(query, "poliqarpplus");
@@ -456,13 +468,15 @@
operands = Lists.newArrayList(operands.get(1).at("/operands").elements());
assertEquals("korap:token", operands.get(0).at("/@type").asText());
assertEquals(true, operands.get(0).at("/wrap").isMissingNode());
-
+ assertEquals(1, res.at("/meta/highlight/0").asInt());
+
query = "[base=der]{2:[]}[base=Mann]";
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
operands = Lists.newArrayList(res.at("/query/operands").elements());
assertEquals("operation:class", operands.get(1).at("/operation").asText());
assertEquals(2, operands.get(1).at("/classOut").asInt());
+ assertEquals(2, res.at("/meta/highlight/0").asInt());
query = "{1:[]}[base=der][base=Mann]";
qs.setQuery(query, "poliqarpplus");
@@ -470,6 +484,7 @@
operands = Lists.newArrayList(res.at("/query/operands").elements());
assertEquals("operation:class", operands.get(0).at("/operation").asText());
assertEquals(1, operands.get(0).at("/classOut").asInt());
+ assertEquals(1, res.at("/meta/highlight/0").asInt());
query = "{1:{2:der} {3:[]} Mann}";
qs.setQuery(query, "poliqarpplus");
@@ -478,7 +493,9 @@
assertEquals(1, operands.size()); // class operation may only have one operand (the sequence)
operands = Lists.newArrayList(operands.get(0).at("/operands").elements());
assertEquals(3, operands.size()); // the sequence has three operands ("der", "[]" and "Mann")
-
+ assertEquals(1, res.at("/meta/highlight/0").asInt());
+ assertEquals(2, res.at("/meta/highlight/1").asInt());
+ assertEquals(3, res.at("/meta/highlight/2").asInt());
}
@Test
@@ -900,7 +917,8 @@
assertEquals(true, res.at("/query/operands/0/classIn").isMissingNode());
assertEquals("Mann", res.at("/query/operands/0/operands/0/operands/0/wrap/key").asText());
assertEquals("Frau", res.at("/query/operands/0/operands/0/operands/1/wrap/key").asText());
-
+ assertEquals(1, res.at("/meta/highlight/0").asInt());
+
query = "{2:{1:[tt/p=ADJA]}[mate/p=NN]}";
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
@@ -909,6 +927,8 @@
assertEquals("operation:sequence", res.at("/query/operands/0/operation").asText());
assertEquals(2, res.at("/query/classOut").asInt());
assertEquals(1, res.at("/query/operands/0/operands/0/classOut").asInt());
+ assertEquals(2, res.at("/meta/highlight/0").asInt());
+ assertEquals(1, res.at("/meta/highlight/1").asInt());
}
@Test
@@ -923,7 +943,8 @@
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
assertEquals(1, res.at("/query/operands/0/operands/1/classOut").asInt());
assertEquals("Mann", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
-
+ assertEquals(1, res.at("/meta/highlight/0").asInt());
+
query = "focus([orth=Der]{[orth=Mann][orth=geht]})";
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
@@ -936,7 +957,8 @@
res = mapper.readTree(qs.toJSON());
assertEquals(2, res.at("/query/classRef/0").asInt());
assertEquals(2, res.at("/query/operands/0/operands/1/classOut").asInt());
-
+ assertEquals(2, res.at("/meta/highlight/0").asInt());
+
query = "focus(3:startswith(<s>,{3:<np>}))";
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
@@ -947,12 +969,14 @@
assertEquals("operation:class", res.at("/query/operands/0/operands/1/operation").asText());
assertEquals(3, res.at("/query/operands/0/operands/1/classOut").asInt());
assertEquals("frames:startswith", res.at("/query/operands/0/frames/0").asText());
-
+ assertEquals(3, res.at("/meta/highlight/0").asInt());
+
query = "focus(1000:startswith(<s>,{1000:<np>}))";
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
- assertEquals(127, res.at("/query/classRef/0").asInt());
- assertEquals(127, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(128, res.at("/query/classRef/0").asInt());
+ assertEquals(128, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(128, res.at("/meta/highlight/0").asInt());
query = "focus(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}}))";
qs.setQuery(query, "poliqarpplus");
@@ -987,6 +1011,9 @@
assertEquals("classRefOp:intersection", res.at("/query/classRefOp").asText());
assertEquals("korap:reference", res.at("/query/@type").asText());
assertEquals("operation:split", res.at("/query/operation").asText());
+ assertEquals(3, res.at("/meta/highlight/0").asInt());
+ assertEquals(1, res.at("/meta/highlight/1").asInt());
+ assertEquals(2, res.at("/meta/highlight/2").asInt());
query = "focus(1:{[base=der]}{1:[pos=ADJA]})";
qs.setQuery(query, "poliqarpplus");
@@ -1063,6 +1090,16 @@
assertEquals("d", res.at("/query/relation/wrap/layer").asText());
assertEquals("HEAD", res.at("/query/relation/wrap/key").asText());
+ query = "dependency([base=fällen],[base=Baum])";
+ qs.setQuery(query, "poliqarpplus");
+ res = mapper.readTree(qs.toJSON());
+ assertEquals("lemma", res.at("/query/operands/0/wrap/layer").asText());
+ assertEquals("fällen", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("lemma", res.at("/query/operands/1/wrap/layer").asText());
+ assertEquals("Baum", res.at("/query/operands/1/wrap/key").asText());
+ assertEquals("korap:relation", res.at("/query/relation/@type").asText());
+ assertEquals("d", res.at("/query/relation/wrap/layer").asText());
+
query = "dominates(Baum,<np>)";
qs.setQuery(query, "poliqarpplus");
res = mapper.readTree(qs.toJSON());
@@ -1112,8 +1149,8 @@
assertEquals("operation:sequence", res.at("/query/operation").asText());
assertEquals("der", res.at("/query/operands/0/wrap/key").asText());
assertEquals("operation:class", res.at("/query/operands/1/operation").asText());
- assertEquals(129, res.at("/query/operands/1/classOut").asInt());
- assertEquals(129, res.at("/meta/alignment").asInt());
+ assertEquals(1, res.at("/query/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/meta/alignment").asInt());
query = "[orth=der]^[orth=große][orth=Mann]";
qs.setQuery(query, "poliqarpplus");
@@ -1123,8 +1160,8 @@
assertEquals("operation:sequence", res.at("/query/operands/1/operands/0/operation").asText());
assertEquals("große", res.at("/query/operands/1/operands/0/operands/0/wrap/key").asText());
assertEquals("Mann", res.at("/query/operands/1/operands/0/operands/1/wrap/key").asText());
- assertEquals(129, res.at("/query/operands/1/classOut").asInt());
- assertEquals(129, res.at("/meta/alignment").asInt());
+ assertEquals(1, res.at("/query/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/meta/alignment").asInt());
query = "([base=a]^[base=b])|[base=c]";
qs.setQuery(query, "poliqarpplus");
@@ -1135,8 +1172,8 @@
assertEquals("a", res.at("/query/operands/0/operands/0/wrap/key").asText());
assertEquals("b", res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("c", res.at("/query/operands/1/wrap/key").asText());
- assertEquals(129, res.at("/query/operands/0/operands/1/classOut").asInt());
- assertEquals(129, res.at("/meta/alignment").asInt());
+ assertEquals(1, res.at("/query/operands/0/operands/1/classOut").asInt());
+ assertEquals(1, res.at("/meta/alignment").asInt());
query = "([base=a]^[base=b][base=c])|[base=d]";
qs.setQuery(query, "poliqarpplus");
@@ -1153,8 +1190,8 @@
assertEquals("b", res.at("/query/operands/0/operands/1/operands/0/operands/0/wrap/key").asText());
assertEquals("c", res.at("/query/operands/0/operands/1/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("d", res.at("/query/operands/1/wrap/key").asText());
- assertEquals(129, res.at("/meta/alignment/0").asInt());
- assertEquals(130, res.at("/meta/alignment/1").asInt());
+ assertEquals(1, res.at("/meta/alignment/0").asInt());
+ assertEquals(2, res.at("/meta/alignment/1").asInt());
}
@Test