Restored KorapQuery and SpanSequenceQueryWrapper.
diff --git a/src/main/java/de/ids_mannheim/korap/KorapQuery.java b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
index 71f9338..a64ff13 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
@@ -607,8 +607,8 @@
SpanQueryWrapper sqw = this.fromJson(operands.get(0));
// Problematic
- // if (sqw.maybeExtension())
- // return sqw.setClassNumber(number);
+ if (sqw.maybeExtension())
+ return sqw.setClassNumber(number);
return new SpanClassQueryWrapper(sqw, number);
};
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java
index a434abb..3265e15 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java
@@ -169,6 +169,7 @@
this.with(seg);
this.isNull = false;
};
+ isNegative = true;
return this;
};
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 d7f03f5..817e6c0 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
@@ -189,11 +189,11 @@
// The wrapper is null - ignore this in the sequence
if (ssq.isNull())
return this;
- if (ssq.isEmpty) {
- this.isEmpty = true;
- this.min = ssq.min;
- this.max = ssq.max;
- }
+ // if (ssq.isEmpty) {
+ // this.isEmpty = true;
+ // this.min = ssq.min;
+ // this.max = ssq.max;
+ // }
// As the spanQueryWrapper is not null,
// the sequence can't be null as well
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java
index b137353..b1cb207 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java
@@ -56,13 +56,19 @@
subquery.setMax(max);
startOffset = max + startOffset;
} else {
- subquery.setMax(startOffset + length);
+ int endOffset = startOffset + length;
+ if (subquery.getMax() > endOffset) {
+ subquery.setMax(startOffset + length);
+ }
}
subquery.setMin(startOffset);
subquery.isOptional = false;
- setMax(subquery.max);
- setMin(subquery.min);
+ // setMax(subquery.max);
+ // setMin(subquery.min);
+ max = subquery.max - subquery.min;
+ min = max;
+
}
private void handleEmptySubquery() {
@@ -110,7 +116,12 @@
if (sq == null)
return null;
if (sq instanceof SpanTermQuery) {
- if (subquery.isNegative()) return sq;
+ if (subquery.isNegative()) {
+ // set expansion min max
+ // max = length;
+ // min = length;
+ return sq;
+ }
else if ((startOffset == 0 || startOffset == -1)
&&
(length == 1 || length == 0)) {
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java
index 1732e63..000fe41 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java
@@ -78,27 +78,21 @@
@Test
public void testEmptyMinusStartOffset() throws QueryException {
- // subspan(spanExpansion(tokens:s:der, []{1, 8}, right),-1,4)
- // need a spanExpansionQueryWrapper to adjust min, max
String filepath = getClass().getResource(
"/queries/submatch/empty-minusStart.jsonld").getFile();
SpanQueryWrapper sqwi = getJSONQuery(filepath);
SpanQuery sq = sqwi.toQuery();
- // subspan(spanExpansion(tokens:s:der, []{7, 8}, right),7,1)
assertEquals(
- "subspan(spanExpansion(tokens:s:der, []{1, 8}, right), 7, 1)",
+ "subspan(spanExpansion(tokens:s:der, []{1, 8}, right), -1, 4)",
sq.toString());
}
@Test
public void testEmptyMax() throws QueryException {
- // need a spanExpansionQueryWrapper to adjust min, max
String filepath = getClass().getResource(
"/queries/submatch/empty-max.jsonld").getFile();
SpanQueryWrapper sqwi = getJSONQuery(filepath);
SpanQuery sq = sqwi.toQuery();
- assertEquals(3, sqwi.getMax());
- // subspan(spanExpansion(tokens:s:der, []{1, 3}, right),1,2)
assertEquals(
"subspan(spanExpansion(tokens:s:der, []{1, 8}, right), 1, 2)",
sq.toString());
@@ -179,7 +173,7 @@
SpanQueryWrapper sqwi = getJSONQuery(filepath);
SpanQuery sq = sqwi.toQuery();
assertEquals(
- "spanExpansion(tokens:s:das, !{1: tokens:l:Baum}{1, 1}, right, class:1)",
+ "spanExpansion(tokens:s:das, !tokens:l:Baum{1, 1}, right, class:1)",
sq.toString());
}
@@ -217,7 +211,6 @@
.getFile();
SpanQueryWrapper sqwi = getJSONQuery(filepath);
SpanQuery sq = sqwi.toQuery();
- // 1,1 expansion is enough
assertEquals(
"subspan(spanExpansion(tokens:s:das, !tokens:l:Baum{1, 3}, right), 1, 1)",
sq.toString());
@@ -225,9 +218,7 @@
@Test
public void testNegativeRepetition() throws QueryException {
- // das submatch(1,2:[base != Baum]{1,3})
- // need a spanExpansionQueryWrapper to handle a null notquery and
- // a repetition of a negative query
+ // das submatch(1,4:[base != Baum]{1,3})
String filepath = getClass().getResource(
"/queries/submatch/negative-repetition.jsonld")
.getFile();
diff --git a/src/test/resources/queries/submatch/negative-repetition.jsonld b/src/test/resources/queries/submatch/negative-repetition.jsonld
index d919167..b869ba2 100644
--- a/src/test/resources/queries/submatch/negative-repetition.jsonld
+++ b/src/test/resources/queries/submatch/negative-repetition.jsonld
@@ -40,7 +40,7 @@
}],
"spanRef": [
1,
- 2
+ 4
]
}
]