Bugfix for big class highlights
diff --git a/src/main/java/de/ids_mannheim/korap/KorapQuery.java b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
index f517c4a..b49e2f6 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
@@ -49,6 +49,8 @@
// This advices the java compiler to ignore all loggings
public static final boolean DEBUG = false;
+ private String warning;
+
public static final byte
OVERLAP = SpanWithinQuery.OVERLAP,
REAL_OVERLAP = SpanWithinQuery.REAL_OVERLAP,
@@ -356,8 +358,21 @@
return sseqqw;
case "operation:class":
+ number = 0;
- if (json.has("class")) {
+
+ if (json.has("classOut")) {
+ number = json.get("classOut").asInt(0);
+ }
+ // Legacy classes
+ else if (json.has("class")) {
+ number = json.get("class").asInt(0);
+ };
+
+ if (json.has("classRefCheck"))
+ this.addWarning("classRefCheck is not yet supported. Results may not be correct");
+
+ if (number > 0) {
if (operands.size() != 1)
throw new QueryException(
612,
@@ -569,7 +584,6 @@
};
-
private SpanQueryWrapper _termFromJSON (JsonNode json) throws QueryException {
if (!json.has("key") || json.get("key").asText().length() < 1)
throw new QueryException(612, "Terms and spans have to provide key attributes");
@@ -641,6 +655,27 @@
return this.tag(value.toString());
};
+ public boolean hasWarning () {
+ if (this.warning != null)
+ return true;
+ return true;
+ };
+
+ public String getWarning () {
+ return this.warning;
+ };
+
+ public void addWarning (String warning) {
+ if (this.warning == null)
+ this.warning = warning;
+ else
+ this.warning += "; " + warning;
+ };
+
+ public void setWarning (String warning) {
+ this.warning = warning;
+ };
+
// SpanRegexQueryWrapper
/**
diff --git a/src/main/java/de/ids_mannheim/korap/KorapSearch.java b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
index 059bb97..935635a 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapSearch.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
@@ -57,18 +57,22 @@
// "query" value
if (this.request.has("query")) {
try {
- SpanQueryWrapper qw = new KorapQuery("tokens").fromJSON(this.request.get("query"));
+ KorapQuery kq = new KorapQuery("tokens");
+ SpanQueryWrapper qw = kq.fromJSON(this.request.get("query"));
if (qw.isEmpty()) {
this.error = "This query matches everywhere";
}
else {
-
this.query = qw.toQuery();
if (qw.isOptional())
this.addWarning("Optionality of query is ignored");
if (qw.isNegative())
this.addWarning("Exclusivity of query is ignored");
+
+ // Set query deserialization warning
+ if (kq.hasWarning())
+ this.addWarning(kq.getWarning());
};
}
catch (QueryException q) {
@@ -79,6 +83,7 @@
this.error = "No query defined";
};
+ // Report warning coming from the request
if (this.request.has("warning"))
this.addWarning(this.request.get("warning").asText());