Removed problematic serialization of empty tags
Change-Id: Icf531208f0ac46725bd8135e1bbcb01692edcfc7
diff --git a/Changes b/Changes
index 44958ab..66f24ea 100644
--- a/Changes
+++ b/Changes
@@ -1,7 +1,13 @@
-0.56.2 2018-02-09
+0.56.2 2018-02-19
- [feature] Introduce meta field retrieval method (diewald)
- [cleanup] Rename KrillQuery's "_"-method to "nr" to improve
compatibility with future versions of Java (diewald)
+ - [bugfix] Fixed expansion to respect character boundaries
+ (diewald)
+ - [bugfix] Fixed wrong behaviour of textual non-contexts in
+ snippet generation (diewald)
+ - [bugfix] Removed problematic serialization of empty
+ annotations (diewald)
0.56.1 2018-01-31
- [bugfix] Changed relation serialization in snippet to work
diff --git a/src/main/java/de/ids_mannheim/korap/KrillIndex.java b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
index bbeb953..b545cad 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
@@ -1213,11 +1213,18 @@
t.getStartChar(), t.getStartPos(),
t.getEndChar(), t.getEndPos());
+ // Ignore empty types for the moment
if (t.getType() == "term" || t.getType() == "span") {
match.addAnnotation(t.getStartPos(), t.getEndPos(),
t.getAnnotation());
}
- else if (t.getType() == "relSrc") {
+
+ // TODO:
+ // else if (t.getType() == "empty") {
+ // }
+
+ // Use relSrc for annotation views
+ else if (t.getType() == "relSrc") {
// This only respects relSrc!
// May require more information for bidirectional relations
match.addRelation(
diff --git a/src/main/java/de/ids_mannheim/korap/index/TermInfo.java b/src/main/java/de/ids_mannheim/korap/index/TermInfo.java
index bf84cc9..60b177d 100644
--- a/src/main/java/de/ids_mannheim/korap/index/TermInfo.java
+++ b/src/main/java/de/ids_mannheim/korap/index/TermInfo.java
@@ -142,6 +142,8 @@
if (ttype == 2) {
this.startChar = this.payload.getInt();
this.endChar = this.payload.getInt();
+ if (this.startChar == this.endChar)
+ this.type = "empty";
};
// for spans, relations and attributes
diff --git a/src/main/java/de/ids_mannheim/korap/response/Match.java b/src/main/java/de/ids_mannheim/korap/response/Match.java
index 9a752e5..009e18b 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Match.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Match.java
@@ -419,6 +419,10 @@
* Annotation string.
*/
public void addAnnotation (int start, int end, String annotation) {
+
+ if (DEBUG && start > end)
+ log.warn("Annotation span is negative: {}, {} for {}", start, end, annotation);
+
this.addHighlight(new Highlight(start, end, annotation));
};
@@ -1681,6 +1685,13 @@
log.trace("There are highlights!");
for (Highlight highlight : this.highlight) {
+ if (DEBUG && highlight.start > highlight.end) {
+ log.warn("Start position is before end position {}-{}!",
+ highlight.start,
+ highlight.end);
+ };
+
+
int start = -1;
int end = -1;
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
index f4bbc45..6f35916 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
@@ -412,6 +412,7 @@
Match km;
String snippet;
+
km = ki.getMatchInfo("match-WPD17/H81/63495-p88-91", "tokens",
"xyz", "s", false, false, false);
km.setContext(new SearchContext(true, (short) 2, true, (short) 2));
@@ -432,22 +433,47 @@
snippet
);
+ // Expansion - no context
km = ki.getMatchInfo("match-WPD17/H81/63495-p88-91", "tokens",
"xyz", "s", true, true, true);
- //km.setContext(new SearchContext(true, (short) 2, true, (short) 2));
snippet = km.getSnippetHTML();
assertEquals(
"<span class=\"context-left\">"+
"</span>"+
"<span class=\"match\">"+
"<mark>Der alte Baum</mark>"+
- " war eine Sommerlinde (Tilia platyphyllos) , der neue ist eine Winterlinde (Tilia cordata)."+
+ " war eine Sommerlinde (Tilia platyphyllos) , "+
+ "der neue ist eine Winterlinde (Tilia cordata)."+
"</span>"+
"<span class=\"context-right\">"+
"</span>",
snippet
);
+ // Addition context
+ /*
+ TODO: Support context nonetheless
+ km = ki.getMatchInfo("match-WPD17/H81/63495-p88-91", "tokens",
+ "xyz", "s", true, true, true);
+ km.setContext(new SearchContext(true, (short) 2, true, (short) 2));
+
+ snippet = km.getSnippetHTML();
+ assertEquals(
+ "<span class=\"context-left\">"+
+ "xyz"+
+ "</span>"+
+ "<span class=\"match\">"+
+ "<mark>Der alte Baum</mark>"+
+ " war eine Sommerlinde (Tilia platyphyllos) , "+
+ "der neue ist eine Winterlinde (Tilia cordata)."+
+ "</span>"+
+ "<span class=\"context-right\">"+
+ "xyz"+
+ "</span>",
+ snippet
+ );
+ */
+
km = ki.getMatchInfo("match-WPD17/H81/63495-p88-91", "tokens",
null, null, false, true, true);
snippet = km.getSnippetHTML();
@@ -529,39 +555,28 @@
"</span>",
snippet
);
-/*
-
- Match km = ki.getMatchInfo("match-WPD17/H81/63495-p88-91", "tokens",
+ km = ki.getMatchInfo("match-WPD17/H81/63495-p88-91", "tokens",
"dereko", "s", true, true, true);
- String snippet = km.getSnippetHTML();
+ snippet = km.getSnippetHTML();
assertEquals(
"<span class=\"context-left\"></span>"+
- "<span class=\"match\">"+
- "<span title=\"dereko/s:s\">"+
- "<mark>"+
- "Der alte Baum"+
- "</mark>"+
+ "<span class=\"match\">"+
+ "<span title=\"dereko/s:s\">"+
+ "<mark>Der alte Baum</mark>"+
" war eine "+
"<span title=\"dereko/s:ref\">Sommerlinde</span>"+
" ("+
"<span title=\"dereko/s:hi\">Tilia platyphyllos</span>"+
- "</span>"+
- "</span>"+
- "<span title=\"dereko/s:s\">"+
- ") , "+
- "<span title=\"dereko/s:ptr\">"+
- "der neue ist eine "+
- "<span title=\"dereko/s:ref\">Winterlinde</span>"+
- " ("+
+ ") , der neue ist eine "+
+ "<span title=\"dereko/s:ref\">Winterlinde</span> ("+
"<span title=\"dereko/s:hi\">Tilia cordata</span>"+
"</span>"+
+ ")."+
"</span>"+
- "<span title=\"dereko/s:ptr\"></span>"+
"<span class=\"context-right\"></span>",
snippet
);
- */
};