Added wrap to koral:span.
Change-Id: Ife8e2b7a84c435d9f5e233e67c25f26d02d7fe19
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 ee56fac..6c930ab 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
@@ -26,6 +26,7 @@
import de.ids_mannheim.korap.query.object.KoralMatchOperator;
import de.ids_mannheim.korap.query.object.KoralOperation;
import de.ids_mannheim.korap.query.object.KoralTermGroupRelation;
+import de.ids_mannheim.korap.query.object.KoralType;
import de.ids_mannheim.korap.query.parse.annis.AqlLexer;
import de.ids_mannheim.korap.query.parse.annis.AqlParser;
import de.ids_mannheim.korap.query.serialize.util.Antlr4DescriptiveErrorListener;
@@ -437,8 +438,21 @@
term.putAll(qNameParse);
}
else {
+
object = KoralObjectGenerator.makeSpan();
- object.putAll(qNameParse);
+ if (node.getChildCount() == 3) {
+ Map<String, Object> term = KoralObjectGenerator.makeTerm();
+ term.putAll(parseTextSpec(node.getChild(2)));
+ term.putAll(qNameParse);
+ object.put("wrap", term);
+ }
+ // EM: koral:span without key but layer and foundry should generally
+ // not be allowed except as relation type
+ else{
+ addError(StatusCodes.MALFORMED_QUERY,
+ "Malformed query.");
+ }
+
}
}
else if (firstChildNodeCat.equals("textSpec")) {
@@ -448,20 +462,14 @@
term.put("layer", "orth");
term.putAll(parseTextSpec(node.getChild(0)));
}
- if (node.getChildCount() == 3) {
- // (foundry/)?layer=key specification
- if (object.get("@type").equals("koral:token")) {
- HashMap<String, Object> term = (HashMap<String, Object>) object
- .get("wrap");
- term.putAll(parseTextSpec(node.getChild(2)));
- term.put("match", parseMatchOperator(
- getFirstChildWithCat(node, "eqOperator")));
- }
- else {
- object.putAll(parseTextSpec(node.getChild(2)));
- object.put("match", parseMatchOperator(
- getFirstChildWithCat(node, "eqOperator")));
- }
+ // (foundry/)?layer=key specification
+ if (object.get("@type").equals("koral:token")
+ && node.getChildCount() == 3) {
+ HashMap<String, Object> term = (HashMap<String, Object>) object
+ .get("wrap");
+ term.putAll(parseTextSpec(node.getChild(2)));
+ term.put("match", parseMatchOperator(
+ getFirstChildWithCat(node, "eqOperator")));
}
// Check if there's a unary relation defined for this node
@@ -718,8 +726,13 @@
if (operatorGroup.containsKey("edgeValue")) {
String edgeValue = (String) operatorGroup
.get("edgeValue");
- attribute = inheritFoundryAndLayer(edgeValue, operand1,
- operand2);
+ attribute = KoralObjectGenerator.makeTerm();
+ attribute.put("key", edgeValue);
+ attribute.put("match",
+ KoralMatchOperator.EQUALS.toString());
+ if (!inheritFoundryAndLayer(attribute, operand1)){
+ inheritFoundryAndLayer(attribute, operand2);
+ }
}
if (operatorGroup.containsKey("edgeType") && !operatorGroup
@@ -898,10 +911,11 @@
private String searchMap (Map<String, Object> operand, String key) {
String type = (String) operand.get("@type");
- if (type.equals("koral:token") && operand.containsKey("wrap")) {
+ if (type.equals(KoralType.TOKEN.toString())
+ && operand.containsKey("wrap")) {
return searchMap((Map<String, Object>) operand.get("wrap"), key);
}
- else if (type.equals("koral:span")) {
+ else if (type.equals(KoralType.SPAN.toString())) {
// EM: legacy, should be deprecated later
if (operand.containsKey(key)) {
return (String) operand.get(key);
@@ -911,7 +925,7 @@
key);
}
}
- else if (type.equals("koral:term")) {
+ else if (type.equals(KoralType.TERM.toString())) {
if (operand.containsKey(key)) {
return (String) operand.get(key);
}
@@ -926,32 +940,25 @@
}
- private Map<String, Object> inheritFoundryAndLayer (String edgeValue,
- Map<String, Object> operand1, Map<String, Object> operand2) {
+ private boolean inheritFoundryAndLayer (
+ Map<String, Object> attribute, Map<String, Object> operand) {
- Map<String, Object> attribute = KoralObjectGenerator.makeTerm();
- attribute.put("key", edgeValue);
- attribute.put("match", KoralMatchOperator.EQUALS.toString());
-
- if (operand1.containsKey("layer")) {
- attribute.put("layer", operand1.get("layer"));
- if (operand1.containsKey("foundry")) {
- attribute.put("foundry", operand1.get("foundry"));
+ if (operand.containsKey("wrap")) {
+ operand = (Map<String, Object>) operand.get("wrap");
+ if (operand.containsKey("layer")) {
+ attribute.put("layer", operand.get("layer"));
+ if (operand.containsKey("foundry")) {
+ attribute.put("foundry", operand.get("foundry"));
+ }
+ return true;
}
- }
- else if (operand2.containsKey("layer")) {
- attribute.put("layer", operand2.get("layer"));
- if (operand2.containsKey("foundry")) {
- attribute.put("foundry", operand2.get("foundry"));
+ else if (operand.containsKey("foundry")) {
+ attribute.put("foundry", operand.get("foundry"));
+ return true;
}
+
}
- else if (operand1.containsKey("foundry")) {
- attribute.put("foundry", operand1.get("foundry"));
- }
- else if (operand2.containsKey("foundry")) {
- attribute.put("foundry", operand2.get("foundry"));
- }
- return attribute;
+ return false;
}
@@ -1005,7 +1012,7 @@
if (edgeSpecNode != null) {
Map<String, Object> edgeSpec = parseEdgeSpec(edgeSpecNode);
- relation.put("edgeValue", edgeSpec.get("value"));
+ relation.put("edgeValue", edgeSpec.get("key"));
}
if (star != null)
relation.put("boundary",
@@ -1144,24 +1151,25 @@
private Map<String, Object> parseEdgeAnno (ParseTree edgeAnnoSpec) {
Map<String, Object> edgeAnno = KoralObjectGenerator.makeTerm();
ParseTree textSpecNode = getFirstChildWithCat(edgeAnnoSpec, "textSpec");
-// ignored
-// ParseTree keyNode = getFirstChildWithCat(edgeAnnoSpec, "key");
-// ParseTree layerNode = getFirstChildWithCat(edgeAnnoSpec, "layer");
-// ParseTree foundryNode = getFirstChildWithCat(edgeAnnoSpec, "foundry");
+ // ignored
+ // ParseTree keyNode = getFirstChildWithCat(edgeAnnoSpec, "key");
+ // ParseTree layerNode = getFirstChildWithCat(edgeAnnoSpec, "layer");
+ // ParseTree foundryNode = getFirstChildWithCat(edgeAnnoSpec, "foundry");
ParseTree matchOperatorNode = getFirstChildWithCat(edgeAnnoSpec,
"eqOperator");
-// if (foundryNode != null)
-// edgeAnno.put("foundry",
-// foundryNode.getChild(0).toStringTree(parser));
-// if (layerNode != null)
-// edgeAnno.put("layer", layerNode.getChild(0).toStringTree(parser));
-// if (keyNode != null)
-// edgeAnno.put("key", keyNode.getChild(0).toStringTree(parser));
+ // if (foundryNode != null)
+ // edgeAnno.put("foundry",
+ // foundryNode.getChild(0).toStringTree(parser));
+ // if (layerNode != null)
+ // edgeAnno.put("layer", layerNode.getChild(0).toStringTree(parser));
+ // if (keyNode != null)
+ // edgeAnno.put("key", keyNode.getChild(0).toStringTree(parser));
edgeAnno.putAll(parseTextSpec(textSpecNode, "key"));
edgeAnno.put("match", parseMatchOperator(matchOperatorNode));
return edgeAnno;
}
+
private Map<String, Object> boundaryFromRangeSpec (ParseTree rangeSpec) {
return boundaryFromRangeSpec(rangeSpec, true);
}
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/annis/AnnisQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/test/annis/AnnisQueryProcessorTest.java
index effe058..58a1ea5 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/annis/AnnisQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/annis/AnnisQueryProcessorTest.java
@@ -62,11 +62,12 @@
res = mapper.readTree(qs.toJSON());
assertEquals("koral:token", res.at("/query/@type").asText());
+ // EM: this query should not be allowed
query = "Mann"; // no special keyword -> defaults to layer name
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:span", res.at("/query/@type").asText());
- assertEquals("Mann", res.at("/query/layer").asText());
+ assertEquals(StatusCodes.MALFORMED_QUERY, res.at("/errors/0/0").asInt());
}
@@ -81,15 +82,15 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:span", res.at("/query/@type").asText());
- assertEquals("np", res.at("/query/key").asText());
- assertEquals("c", res.at("/query/layer").asText());
+ assertEquals("np", res.at("/query/wrap/key").asText());
+ assertEquals("c", res.at("/query/wrap/layer").asText());
query = "cat=\"NP\"";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:span", res.at("/query/@type").asText());
- assertEquals("NP", res.at("/query/key").asText());
- assertEquals("c", res.at("/query/layer").asText());
+ assertEquals("NP", res.at("/query/wrap/key").asText());
+ assertEquals("c", res.at("/query/wrap/layer").asText());
}
@@ -120,16 +121,16 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:span", res.at("/query/@type").asText());
- assertEquals("np", res.at("/query/key").asText());
- assertEquals("c", res.at("/query/layer").asText());
+ assertEquals("np", res.at("/query/wrap/key").asText());
+ assertEquals("c", res.at("/query/wrap/layer").asText());
query = "cnx/c=\"np\"";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:span", res.at("/query/@type").asText());
- assertEquals("np", res.at("/query/key").asText());
- assertEquals("c", res.at("/query/layer").asText());
- assertEquals("cnx", res.at("/query/foundry").asText());
+ assertEquals("np", res.at("/query/wrap/key").asText());
+ assertEquals("c", res.at("/query/wrap/layer").asText());
+ assertEquals("cnx", res.at("/query/wrap/foundry").asText());
query = "tt/pos=\"np\"";
qs.setQuery(query, "annis");
@@ -154,7 +155,7 @@
assertEquals("frames:startsWith", res.at("/query/frames/0").asText());
assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type")
.asText());
- assertEquals("S", res.at("/query/operands/0/operands/0/key").asText());
+ assertEquals("S", res.at("/query/operands/0/operands/0/wrap/key").asText());
assertEquals("koral:group", res
.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
@@ -165,7 +166,7 @@
res.at("/query/operands/0/operands/1/operands/0/@type")
.asText());
assertEquals("NP", res
- .at("/query/operands/0/operands/1/operands/0/key").asText());
+ .at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("koral:reference", res.at("/query/operands/1/@type")
.asText());
assertEquals("operation:focus", res.at("/query/operands/1/operation")
@@ -185,7 +186,7 @@
assertEquals("frames:endsWith", res.at("/query/frames/0").asText());
assertEquals("koral:span", res.at("/query/operands/0/operands/0/@type")
.asText());
- assertEquals("S", res.at("/query/operands/0/operands/0/key").asText());
+ assertEquals("S", res.at("/query/operands/0/operands/0/wrap/key").asText());
assertEquals("koral:group", res
.at("/query/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
@@ -196,7 +197,7 @@
res.at("/query/operands/0/operands/1/operands/0/@type")
.asText());
assertEquals("NP", res
- .at("/query/operands/0/operands/1/operands/0/key").asText());
+ .at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
assertEquals("koral:reference", res.at("/query/operands/1/@type")
.asText());
assertEquals("operation:focus", res.at("/query/operands/1/operation")
@@ -414,17 +415,17 @@
.asText());
assertEquals(
"A",
- res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/key")
.asText());
assertEquals(
"B",
- res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/key")
+ res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/wrap/key")
.asText());
assertEquals(
"C",
- res.at("/query/operands/0/operands/0/operands/1/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
- assertEquals("D", res.at("/query/operands/1/key").asText());
+ assertEquals("D", res.at("/query/operands/1/wrap/key").asText());
query = "cat=\"A\" & cat=\"B\" & cat=\"C\" & cat=\"D\" & cat=\"E\" & cat=\"F\" & #1 . #2 & #3 . #4 & #5 . #6 & #1 > #3 & #3 > #5";
// the resulting query should be equivalent to PQ+: focus(3:dominates(focus(2:dominates(focus(1:{1:<A>}<B>),{2:<C>}))<D>,{3:<E>}))<F>
@@ -460,25 +461,25 @@
.asText());
assertEquals(
"A",
- res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/key")
.asText());
assertEquals(
"B",
- res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/1/key")
+ res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/1/wrap/key")
.asText());
assertEquals(
"C",
- res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/1/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
assertEquals(
"D",
- res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/key")
+ res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/wrap/key")
.asText());
assertEquals(
"E",
- res.at("/query/operands/0/operands/0/operands/1/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
- assertEquals("F", res.at("/query/operands/1/key").asText());
+ assertEquals("F", res.at("/query/operands/1/wrap/key").asText());
query = "cat=\"A\" & cat=\"B\" & cat=\"C\" & cat=\"D\" & #1 . #2 & #3 . #4";
// the resulting query should be equivalent to PQ+: focus(2:dominates(focus(1:{1:<A>}<B>),{2:<C>}))<D>
@@ -613,7 +614,7 @@
.asText());
assertEquals(
"NP",
- res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/key")
+ res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/wrap/key")
.asText());
assertEquals("koral:group",
res.at("/query/operands/0/operands/0/operands/1/@type")
@@ -626,9 +627,9 @@
.asInt());
assertEquals(
"VP",
- res.at("/query/operands/0/operands/0/operands/1/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
- assertEquals("PP", res.at("/query/operands/1/key").asText());
+ assertEquals("PP", res.at("/query/operands/1/wrap/key").asText());
}
@@ -662,7 +663,7 @@
.asText());
assertEquals(
"NP",
- res.at("/query/operands/0/operands/0/operands/0/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key")
.asText());
assertEquals("operation:class",
res.at("/query/operands/0/operands/0/operands/1/operation")
@@ -672,7 +673,7 @@
.asInt());
assertEquals(
"VP",
- res.at("/query/operands/0/operands/0/operands/1/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
assertEquals("koral:reference", res.at("/query/operands/1/@type")
.asText());
@@ -756,9 +757,9 @@
.asInt());
assertEquals(
"VP",
- res.at("/query/operands/0/operands/0/operands/1/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
- assertEquals("NP", res.at("/query/operands/1/key").asText());
+ assertEquals("NP", res.at("/query/operands/1/wrap/key").asText());
query = "node & \"Mann\" & #2 _o_ #1";
qs.setQuery(query, "annis");
@@ -909,7 +910,7 @@
.asInt());
assertEquals(
"NP",
- res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/key")
.asText());
assertEquals(
130,
@@ -950,9 +951,9 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:span", res.at("/query/@type").asText());
- assertEquals("cnx", res.at("/query/foundry").asText());
- assertEquals("c", res.at("/query/layer").asText());
- assertEquals("NP", res.at("/query/key").asText());
+ assertEquals("cnx", res.at("/query/wrap/foundry").asText());
+ assertEquals("c", res.at("/query/wrap/layer").asText());
+ assertEquals("NP", res.at("/query/wrap/key").asText());
assertEquals("koral:term", res.at("/query/attr/@type").asText());
assertEquals("koral:boundary", res.at("/query/attr/tokenarity/@type")
.asText());
@@ -969,10 +970,10 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:span", res.at("/query/@type").asText());
- assertEquals("cnx", res.at("/query/foundry").asText());
- assertEquals("c", res.at("/query/layer").asText());
- assertEquals("NP", res.at("/query/key").asText());
- assertEquals("match:eq", res.at("/query/match").asText());
+ assertEquals("cnx", res.at("/query/wrap/foundry").asText());
+ assertEquals("c", res.at("/query/wrap/layer").asText());
+ assertEquals("NP", res.at("/query/wrap/key").asText());
+ assertEquals("match:eq", res.at("/query/wrap/match").asText());
assertEquals("koral:term", res.at("/query/attr/@type").asText());
assertEquals(true, res.at("/query/attr/root").asBoolean());
@@ -980,9 +981,9 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("koral:span", res.at("/query/@type").asText());
- assertEquals("cnx", res.at("/query/foundry").asText());
- assertEquals("c", res.at("/query/layer").asText());
- assertEquals("NP", res.at("/query/key").asText());
+ assertEquals("cnx", res.at("/query/wrap/foundry").asText());
+ assertEquals("c", res.at("/query/wrap/layer").asText());
+ assertEquals("NP", res.at("/query/wrap/key").asText());
assertEquals("koral:termGroup", res.at("/query/attr/@type").asText());
assertEquals("koral:term", res.at("/query/attr/operands/0/@type")
.asText());
@@ -1000,9 +1001,9 @@
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:hierarchy", res.at("/query/operation").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
- assertEquals("cnx", res.at("/query/operands/0/foundry").asText());
- assertEquals("c", res.at("/query/operands/0/layer").asText());
- assertEquals("NP", res.at("/query/operands/0/key").asText());
+ assertEquals("cnx", res.at("/query/operands/0/wrap/foundry").asText());
+ assertEquals("c", res.at("/query/operands/0/wrap/layer").asText());
+ assertEquals("NP", res.at("/query/operands/0/wrap/key").asText());
assertEquals("koral:term", res.at("/query/operands/0/attr/@type")
.asText());
assertEquals("koral:boundary",
@@ -1051,13 +1052,13 @@
res.at("/query/operands/0/operands/0/operands/1/@type")
.asText());
assertEquals("NP", res
- .at("/query/operands/0/operands/0/operands/1/key").asText());
+ .at("/query/operands/0/operands/0/operands/1/wrap/key").asText());
assertEquals("c",
- res.at("/query/operands/0/operands/0/operands/1/layer")
+ res.at("/query/operands/0/operands/0/operands/1/wrap/layer")
.asText());
assertEquals("koral: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());
+ assertEquals("VP", res.at("/query/operands/1/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/1/wrap/layer").asText());
query = "cat=\"NP\" & cat=\"VP\" & cat=\"PP\" & #1 $ #2 $ #3";
qs.setQuery(query, "annis");
@@ -1085,11 +1086,11 @@
assertEquals("operation:disjunction", res.at("/query/operation")
.asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
- assertEquals("NP", res.at("/query/operands/0/key").asText());
- assertEquals("c", res.at("/query/operands/0/layer").asText());
+ assertEquals("NP", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/0/wrap/layer").asText());
assertEquals("koral: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());
+ assertEquals("VP", res.at("/query/operands/1/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/1/wrap/layer").asText());
}
//
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/annis/DominanceTests.java b/src/test/java/de/ids_mannheim/korap/query/test/annis/DominanceTests.java
index 6993424..659522d 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/annis/DominanceTests.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/annis/DominanceTests.java
@@ -82,9 +82,9 @@
res.at("/query/operation").asText());
assertEquals("edgetype", res.at("/query/edgeType").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
- assertEquals("np", res.at("/query/operands/0/key").asText());
- assertEquals("c", res.at("/query/operands/0/layer").asText());
- assertEquals("cnx", res.at("/query/operands/0/foundry").asText());
+ assertEquals("np", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/0/wrap/layer").asText());
+ assertEquals("cnx", res.at("/query/operands/0/wrap/foundry").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
}
@@ -101,9 +101,9 @@
assertEquals("edgetype", res.at("/query/edgeType").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
- assertEquals("np", res.at("/query/operands/1/key").asText());
- assertEquals("c", res.at("/query/operands/1/layer").asText());
- assertEquals("cnx", res.at("/query/operands/1/foundry").asText());
+ assertEquals("np", res.at("/query/operands/1/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/1/wrap/layer").asText());
+ assertEquals("cnx", res.at("/query/operands/1/wrap/foundry").asText());
}
@@ -119,11 +119,11 @@
res.at("/query/operation").asText());
assertEquals("edgetype", res.at("/query/edgeType").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
- assertEquals("PP", res.at("/query/operands/0/key").asText());
- assertEquals("c", res.at("/query/operands/0/layer").asText());
+ assertEquals("PP", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/0/wrap/layer").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
- assertEquals("NP", res.at("/query/operands/1/key").asText());
- assertEquals("c", res.at("/query/operands/1/layer").asText());
+ assertEquals("NP", res.at("/query/operands/1/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/1/wrap/layer").asText());
}
@@ -138,8 +138,8 @@
res.at("/query/operation").asText());
assertEquals("edgetype", res.at("/query/edgeType").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
- assertEquals("NP", res.at("/query/operands/0/key").asText());
- assertEquals("c", res.at("/query/operands/0/layer").asText());
+ assertEquals("NP", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/0/wrap/layer").asText());
assertEquals("koral:token", res.at("/query/operands/1/@type").asText());
assertEquals("ADJ", res.at("/query/operands/1/wrap/key").asText());
assertEquals("p", res.at("/query/operands/1/wrap/layer").asText());
@@ -173,13 +173,13 @@
res.at("/query/operation").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
- assertEquals("vp", res.at("/query/operands/0/key").asText());
- assertEquals("c", res.at("/query/operands/0/layer").asText());
- assertEquals("cnx", res.at("/query/operands/0/foundry").asText());
+ assertEquals("vp", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/0/wrap/layer").asText());
+ assertEquals("cnx", res.at("/query/operands/0/wrap/foundry").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
- assertEquals("np", res.at("/query/operands/1/key").asText());
- assertEquals("c", res.at("/query/operands/1/layer").asText());
- assertEquals("cnx", res.at("/query/operands/1/foundry").asText());
+ assertEquals("np", res.at("/query/operands/1/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/1/wrap/layer").asText());
+ assertEquals("cnx", res.at("/query/operands/1/wrap/foundry").asText());
}
@@ -210,8 +210,8 @@
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
- assertEquals("c", res.at("/query/operands/0/layer").asText());
- assertEquals("c", res.at("/query/operands/1/layer").asText());
+ assertEquals("c", res.at("/query/operands/0/wrap/layer").asText());
+ assertEquals("c", res.at("/query/operands/1/wrap/layer").asText());
assertEquals(2, res.at("/query/boundary/min").asInt());
assertEquals(4, res.at("/query/boundary/max").asInt());
assertTrue(res.at("/errors").isMissingNode());
@@ -234,8 +234,8 @@
assertEquals("operation:hierarchy",
res.at("/query/operation").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
- assertEquals("NP", res.at("/query/operands/0/key").asText());
- assertEquals("c", res.at("/query/operands/0/layer").asText());
+ assertEquals("NP", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/0/wrap/layer").asText());
assertEquals("koral:token", res.at("/query/operands/1/@type").asText());
assertEquals("ADJ", res.at("/query/operands/1/wrap/key").asText());
assertEquals("p", res.at("/query/operands/1/wrap/layer").asText());
@@ -259,11 +259,11 @@
assertEquals("operation:hierarchy",
res.at("/query/operation").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
- assertEquals("NP", res.at("/query/operands/0/key").asText());
- assertEquals("c", res.at("/query/operands/0/layer").asText());
+ assertEquals("NP", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/0/wrap/layer").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
- assertEquals("PP", res.at("/query/operands/1/key").asText());
- assertEquals("c", res.at("/query/operands/1/layer").asText());
+ assertEquals("PP", res.at("/query/operands/1/wrap/key").asText());
+ assertEquals("c", res.at("/query/operands/1/wrap/layer").asText());
}
@@ -307,10 +307,8 @@
assertEquals("match:eq",
res.at("/query/operands/0/attr/match").asText());
assertEquals("SBJ", res.at("/query/operands/0/attr/key").asText());
- assertTrue("SBJ",
- res.at("/query/operands/0/attr/layer").isMissingNode());
- assertTrue("SBJ",
- res.at("/query/operands/0/attr/value").isMissingNode());
+ assertEquals("orth", res.at("/query/operands/0/attr/layer").asText());
+ assertTrue(res.at("/query/operands/0/attr/value").isMissingNode());
}
@@ -318,7 +316,6 @@
public void testDominanceWithEdgetypeAndLabel ()
throws JsonProcessingException, IOException {
query = "node & node & #2 >edgetype[func=\"SBJ\"] #1";
- //coordinates the func=SB term and requires a "c"-layer term (consituency relation/dominance)
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("operation:hierarchy",
@@ -337,16 +334,15 @@
@Test
public void testDominanceWithTypeAndLabel ()
throws JsonProcessingException, IOException {
- query = "rst & rst & #2 >rst[rst:name=\"evidence\"] #1";
- //coordinates the func=SB term and requires a "c"-layer term (consituency relation/dominance)
+ query = "rst=\"segment\" & rst=\"segment\" & #2 >rst[rst:name=\"evidence\"] #1";
qs.setQuery(query, "annis");
res = mapper.readTree(qs.toJSON());
assertEquals("operation:relation", res.at("/query/operation").asText());
assertEquals("rst", res.at("/query/edgeType").asText());
assertEquals("koral:span", res.at("/query/operands/0/@type").asText());
- assertEquals("rst", res.at("/query/operands/0/layer").asText());
+ assertEquals("rst", res.at("/query/operands/0/wrap/layer").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
- assertEquals("rst", res.at("/query/operands/1/layer").asText());
+ assertEquals("rst", res.at("/query/operands/1/wrap/layer").asText());
assertEquals("koral:term",
res.at("/query/relType/wrap/@type").asText());
@@ -388,10 +384,12 @@
res.at("/query/operands/0/operands/0/operation").asText());
assertEquals("koral:span", res
.at("/query/operands/0/operands/0/operands/0/@type").asText());
- assertEquals("c", res
- .at("/query/operands/0/operands/0/operands/0/layer").asText());
+ assertEquals("c",
+ res.at("/query/operands/0/operands/0/operands/0/wrap/layer")
+ .asText());
assertEquals("CP",
- res.at("/query/operands/0/operands/0/operands/0/key").asText());
+ res.at("/query/operands/0/operands/0/operands/0/wrap/key")
+ .asText());
assertEquals("koral:group", res
.at("/query/operands/0/operands/0/operands/1/@type").asText());
assertEquals("operation:class",
@@ -401,7 +399,7 @@
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")
+ res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
}
@@ -423,8 +421,8 @@
res.at("/query/operands/0/operation").asText());
assertEquals(130, res.at("/query/operands/0/classRef/0").asInt());
- assertEquals("c", res.at("/query/operands/1/layer").asText());
- assertEquals("DP", res.at("/query/operands/1/key").asText());
+ assertEquals("c", res.at("/query/operands/1/wrap/layer").asText());
+ assertEquals("DP", res.at("/query/operands/1/wrap/key").asText());
assertEquals("koral:group",
res.at("/query/operands/0/operands/0/@type").asText());
@@ -443,14 +441,14 @@
res.at("/query/operands/0/operands/0/operands/1/classOut")
.asInt());
assertEquals("NP",
- res.at("/query/operands/0/operands/0/operands/1/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
assertEquals("c",
- res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/layer")
+ res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/layer")
.asText());
assertEquals("CP",
- res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/0/wrap/key")
.asText());
assertEquals("koral:group",
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/@type")
@@ -462,7 +460,7 @@
res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/classOut")
.asInt());
assertEquals("VP",
- res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/operands/0/key")
+ res.at("/query/operands/0/operands/0/operands/0/operands/0/operands/1/operands/0/wrap/key")
.asText());
}