Fix wrong optimization of %+w1:1
Change-Id: I3eee8373776dadc1812c18a7882c3b8a96ebbfb9
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
index a8673fc..02fa921 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
@@ -567,7 +567,7 @@
if (this.constraints.size() == 1) {
DistanceConstraint dc = this.constraints.get(0);
if (dc.getUnit().equals("w") && dc.getMinDistance() == 1
- && dc.getMaxDistance() == 1 && this.isInOrder) {
+ && dc.getMaxDistance() == 1 && !dc.isExclusion() && this.isInOrder) {
return false;
};
};
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
index 6c5adda..9627308 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
@@ -356,6 +356,17 @@
"focus(1: spanEndsWith(<tokens:s />, {1: tokens:p:V}),sorting)");
};
+ @Test
+ public void queryJSONcosmas21 () throws QueryException {
+ SpanQueryWrapper sqwi = getJsonQuery(
+ getClass().getResource("/queries/cosmas21.json").getFile());
+
+ // die %+w1:1 Gegenwart
+ assertEquals(sqwi.toQuery().toString(),
+ "spanDistance({129: tokens:s:die}, {129: tokens:s:Gegenwart}, [(w[1:1], ordered, excluded)])");
+ };
+
+
@Test
public void queryJSONrepetition () throws QueryException {
diff --git a/src/test/resources/queries/cosmas21.json b/src/test/resources/queries/cosmas21.json
new file mode 100644
index 0000000..8a6262c
--- /dev/null
+++ b/src/test/resources/queries/cosmas21.json
@@ -0,0 +1,72 @@
+{
+ "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query" : {
+ "@type": "koral:group",
+ "distances": [
+ {
+ "@type": "cosmas:distance",
+ "boundary": {
+ "@type": "koral:boundary",
+ "max": 1,
+ "min": 1
+ },
+ "exclude": true,
+ "key": "w"
+ }
+ ],
+ "inOrder": true,
+ "operands": [
+ {
+ "@type": "koral:group",
+ "classOut": 129,
+ "operands": [
+ {
+ "@type": "koral:token",
+ "wrap": {
+ "@type": "koral:term",
+ "foundry": "opennlp",
+ "key": "die",
+ "layer": "orth",
+ "match": "match:eq",
+ "rewrites": [
+ {
+ "@type": "koral:rewrite",
+ "operation": "operation:injection",
+ "scope": "foundry",
+ "src": "Kustvakt"
+ }
+ ]
+ }
+ }
+ ],
+ "operation": "operation:class"
+ },
+ {
+ "@type": "koral:group",
+ "classOut": 129,
+ "operands": [
+ {
+ "@type": "koral:token",
+ "wrap": {
+ "@type": "koral:term",
+ "foundry": "opennlp",
+ "key": "Gegenwart",
+ "layer": "orth",
+ "match": "match:eq",
+ "rewrites": [
+ {
+ "@type": "koral:rewrite",
+ "operation": "operation:injection",
+ "scope": "foundry",
+ "src": "Kustvakt"
+ }
+ ]
+ }
+ }
+ ],
+ "operation": "operation:class"
+ }
+ ],
+ "operation": "operation:sequence"
+ }
+}