Support anchor spans for relations
Change-Id: I4ab566d99fe3ac80fe75ebafb1b079c659bae90c
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 0c89db2..7b9e09d 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Match.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Match.java
@@ -426,17 +426,33 @@
* @param annotation
* Annotation string.
*/
- public void addRelation (int srcStart, int srcEnd, int targetStart, int targetEnd, String annotation) {
+ public void addRelation (int srcStart,
+ int srcEnd,
+ int targetStart,
+ int targetEnd,
+ String annotation) {
if (DEBUG)
log.trace("Add relation {}: {}-{}->{}-{}",
annotation, srcStart, srcEnd, targetStart, targetEnd);
-
- this.addHighlight(new Highlight(srcStart, srcStart, annotation, targetStart));
+ if (srcEnd == -1) {
+ // Add source token
+ this.addHighlight(new Highlight(srcStart, srcStart, annotation, targetStart));
+ }
+ else {
+ this.addHighlight(new Highlight(srcStart, srcEnd, annotation, targetStart));
+ };
+
int id = identifierNumberCounter--;
identifierNumber.put(id, targetStart);
- this.addHighlight(new Highlight(targetStart, targetStart, id));
+
+ if (targetEnd == -1) {
+ this.addHighlight(new Highlight(targetStart, targetStart, id));
+ }
+ else {
+ this.addHighlight(new Highlight(targetStart, targetEnd, id));
+ };
};