Added class to first operand of OPIN and OPOV.
Change-Id: Id01180ab2445235177a20e0213cefa5ff3f57171
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 7c30e56..abae0f0 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
@@ -534,7 +534,7 @@
@SuppressWarnings("unchecked")
private void processOPIN_OPOV (Tree node) {
String nodeCat = getNodeCat(node);
-
+ wrapOperandInClass(node, 1, 128 + classCounter++);
// Map<String, Object> posgroup =
// makePosition(null);
boolean isExclusion = isExclusion(node);
@@ -1210,7 +1210,7 @@
if (classRefCheck.contains(ClassRefCheck.INCLUDES)) {
- wrapOperandInClass(node, 1, 128 + classCounter++);
+// wrapOperandInClass(node, 1, 128 + classCounter++);
if (classRefCheck.contains(ClassRefCheck.EQUALS)){
classRefCheck.remove(ClassRefCheck.EQUALS);
@@ -1221,7 +1221,7 @@
}
else if (classRefCheck.contains(ClassRefCheck.EQUALS)
|| classRefCheck.contains(ClassRefCheck.UNEQUALS)) {
- wrapOperandInClass(node, 1, 128 + classCounter++);
+// wrapOperandInClass(node, 1, 128 + classCounter++);
wrapOperandInClass(node, 2, 128 + classCounter++);
}
@@ -1253,21 +1253,22 @@
positions.add(KoralFrame.MATCHES);
break;
case "FE":
- classRefCheck.add(ClassRefCheck.EQUALS);
positions.add(KoralFrame.MATCHES);
+ classRefCheck.add(ClassRefCheck.EQUALS);
break;
case "FI":
- classRefCheck.add(ClassRefCheck.UNEQUALS);
positions.add(KoralFrame.MATCHES);
+ classRefCheck.add(ClassRefCheck.UNEQUALS);
break;
case "N":
positions.add(KoralFrame.IS_WITHIN);
break;
default:
+ positions.add(KoralFrame.MATCHES);
positions.add(KoralFrame.ALIGNS_LEFT);
positions.add(KoralFrame.ALIGNS_RIGHT);
positions.add(KoralFrame.IS_WITHIN);
- positions.add(KoralFrame.MATCHES);
+
}
}
@@ -1336,7 +1337,7 @@
posOptions.put("frames", Converter.enumListToStringList(positions));
posOptions.put("classRefCheck", classRefCheck);
if (!classRefCheck.isEmpty()) {
- wrapOperandInClass(node, 1, 128 + classCounter++);
+// wrapOperandInClass(node, 1, 128 + classCounter++);
wrapOperandInClass(node, 2, 128 + classCounter++);
}
// if (exclnode != null) {
diff --git a/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINTest.java b/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINTest.java
index 7b89902..f9efc9c 100644
--- a/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINTest.java
+++ b/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINTest.java
@@ -29,7 +29,7 @@
query = "wegen #IN <s>";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
-
+// System.out.println(res);
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:position", res.at("/query/operation").asText());
assertEquals(4, res.at("/query/frames").size());
@@ -37,9 +37,10 @@
assertEquals("frames:alignsLeft", res.at("/query/frames/1").asText());
assertEquals("frames:alignsRight", res.at("/query/frames/2").asText());
assertEquals("frames:isWithin", res.at("/query/frames/3").asText());
- assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
- // ND: This should fail with a focus requirement on the first operand!
}
@@ -49,12 +50,15 @@
query = "wegen #IN(N) <s>";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
+// System.out.println(res);
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:position", res.at("/query/operation").asText());
assertEquals("frames:isWithin", res.at("/query/frames/0").asText());
- assertEquals("wegen", res.at("/query/operands/0/wrap/key").asText());
+
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("wegen", res.at("/query/operands/0/operands/0/wrap/key").asText());
+
assertEquals("s", res.at("/query/operands/1/wrap/key").asText());
- // ND: This should fail with a focus requirement on the first operand!
}
@@ -68,11 +72,10 @@
assertEquals("operation:position", res.at("/query/operation").asText());
assertEquals(1, res.at("/query/frames").size());
- assertEquals("frames:alignsLeft", res.at("/query/frames/0").asText());
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("wegen", res.at("/query/operands/0/operands/0/wrap/key").asText());
- assertEquals("wegen", res.at("/query/operands/0/wrap/key").asText());
assertEquals("s", res.at("/query/operands/1/wrap/key").asText());
- // ND: This should fail with a focus requirement on the first operand!
}
@@ -88,9 +91,9 @@
assertEquals("frames:alignsRight", res.at("/query/frames/0").asText());
assertEquals(1, res.at("/query/frames").size());
- assertEquals("wegen", res.at("/query/operands/0/wrap/key").asText());
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("wegen", res.at("/query/operands/0/operands/0/wrap/key").asText());
assertEquals("s", res.at("/query/operands/1/wrap/key").asText());
- // ND: This should fail with a focus requirement on the first operand!
}
@@ -100,11 +103,15 @@
query = "wegen #IN(F) <s>";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
+// System.out.println(res);
assertEquals(true,
res.at("/query/operands/0/classRefCheck").isMissingNode());
//EM: should include classRefCheck:include
assertEquals("frames:matches", res.at("/query/frames/0").asText());
assertEquals(true, res.at("/query/frames/1").isMissingNode());
+
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("wegen", res.at("/query/operands/0/operands/0/wrap/key").asText());
}
@@ -184,7 +191,9 @@
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:position", res.at("/query/operation").asText());
assertEquals("frames:isWithin", res.at("/query/frames/0").asText());
- assertEquals("sich", res.at("/query/operands/0/wrap/key").asText());
+
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("sich", res.at("/query/operands/0/operands/0/wrap/key").asText());
assertEquals("gelten",
res.at("/query/operands/1/operands/0/operands/0/wrap/key")
.asText());
@@ -244,6 +253,7 @@
query = "gilt #IN(FE,HIT) (&gelten /w5:10 zurecht)";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
+ System.out.println(res);
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:class", res.at("/query/operation").asText());
diff --git a/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINWithExclusionTest.java b/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINWithExclusionTest.java
index c9a7ab2..0d6e156 100644
--- a/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINWithExclusionTest.java
+++ b/src/test/java/de/ids_mannheim/korap/test/cosmas2/OPINWithExclusionTest.java
@@ -27,7 +27,7 @@
query = "wegen #IN(%) <s>";
qs.setQuery(query, "cosmas2");
res = mapper.readTree(qs.toJSON());
-
+ System.out.println(res);
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:exclusion",
res.at("/query/operation").asText());
@@ -36,7 +36,8 @@
assertEquals("frames:alignsRight", res.at("/query/frames/1").asText());
assertEquals("frames:matches", res.at("/query/frames/3").asText());
assertEquals("frames:isWithin", res.at("/query/frames/2").asText());
- assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
}
@@ -52,7 +53,8 @@
res.at("/query/operation").asText());
assertEquals(1, res.at("/query/frames").size());
assertEquals("frames:isWithin", res.at("/query/frames/0").asText());
- assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
// ND: I think, this requires
@@ -76,7 +78,8 @@
res.at("/query/operation").asText());
assertEquals(1, res.at("/query/frames").size());
assertEquals("frames:alignsLeft", res.at("/query/frames/0").asText());
- assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
// ND: I think, frames:matches is wrong here ...
@@ -222,7 +225,8 @@
res.at("/query/operation").asText());
assertEquals(1, res.at("/query/frames").size());
assertEquals("frames:isWithin", res.at("/query/frames/0").asText());
- assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
}
@@ -236,10 +240,10 @@
assertEquals("koral:group", res.at("/query/@type").asText());
assertEquals("operation:exclusion",
res.at("/query/operation").asText());
- assertEquals(2, res.at("/query/frames").size());
+ assertEquals(1, res.at("/query/frames").size());
assertEquals("frames:alignsLeft", res.at("/query/frames/0").asText());
- assertEquals("frames:matches", res.at("/query/frames/1").asText());
- assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
}
@@ -258,9 +262,8 @@
res.at("/query/operation").asText());
assertEquals(1, res.at("/query/frames").size());
assertEquals("frames:isWithin", res.at("/query/frames/0").asText());
- assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
- assertEquals("koral:span", res.at("/query/operands/1/@type").asText());
- }
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/operands/0/@type").asText()); }
@Test
public void testOPINwithExclusionN_ALL_MAX ()
@@ -274,7 +277,8 @@
res.at("/query/operation").asText());
assertEquals(1, res.at("/query/frames").size());
assertEquals("frames:isWithin", res.at("/query/frames/0").asText());
- assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/operands/0/@type").asText());
}
@Test
@@ -319,17 +323,18 @@
res.at("/query/operation").asText());
assertEquals(1, res.at("/query/frames").size());
assertEquals("frames:isWithin", res.at("/query/frames/0").asText());
- assertEquals("koral:token", res.at("/query/operands/0/@type").asText());
+ assertEquals("operation:class", res.at("/query/operands/0/operation").asText());
+ assertEquals("koral:token", res.at("/query/operands/0/operands/0/@type").asText());
assertEquals("operation:sequence", res.at("/query/operands/1/operation").asText());
JsonNode seqOperand = res.at("/query/operands/1/operands");
assertEquals("operation:class", seqOperand.at("/0/operation").asText());
- assertEquals(129, seqOperand.at("/0/classOut").asInt());
+ assertEquals(130, seqOperand.at("/0/classOut").asInt());
assertEquals("operation:class", seqOperand.at("/1/operation").asText());
- assertEquals(129, seqOperand.at("/1/classOut").asInt());
+ assertEquals(130, seqOperand.at("/1/classOut").asInt());
}
}