Fixed rare highlighting bug
diff --git a/src/main/java/de/ids_mannheim/korap/KorapCollection.java b/src/main/java/de/ids_mannheim/korap/KorapCollection.java
index 422a97a..446c085 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapCollection.java
@@ -81,7 +81,7 @@
// Todo: Create new KorapSearch Object!
public KorapResult search (SpanQuery query) {
- return this.index.search(this, query, 17, (short) 20, true, (short) 5, true, (short) 5);
+ return this.index.search(this, query, 0, (short) 20, true, (short) 5, true, (short) 5);
};
public FixedBitSet bits (AtomicReaderContext atomic) throws IOException {
diff --git a/src/main/java/de/ids_mannheim/korap/KorapMatch.java b/src/main/java/de/ids_mannheim/korap/KorapMatch.java
index 8d56f83..f1b57cb 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapMatch.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapMatch.java
@@ -546,24 +546,53 @@
LinkedList<int[]> spans = new LinkedList<int[]>();
- spans.add(new int[]{ startPosChar - startOffsetChar, endPosChar - startOffsetChar, -1, 0});
+ // Todo: Simplify
+ int[] intArray = new int[]{ startPosChar - startOffsetChar, endPosChar - startOffsetChar, -1, 0};
+ log.trace("IntArray: {}", intArray);
+ spans.add(intArray);
// highlights
+ // I'm not sure about this.
if (this.highlight != null) {
for (int[] highlight : this.highlight) {
+ /*
+
+ int start = pto.start(ldid, highlight[0]);
+ int end = pto.end(ldid, highlight[1]);
+
+ // Todo: Does this have to be and or or?
+ if (start == -1 || end == -1)
+ continue;
+
+ if (start > startOffsetChar) {
+ start -= startOffsetChar;
+ }
+ else {
+ start = 0;
+ };
+
+ end -= startOffsetChar;
+ */
+
int start = pto.start(ldid, highlight[0]) - startOffsetChar;
int end = pto.end(ldid, highlight[1]) - startOffsetChar;
- if (start == -1 & end == -1)
+ if (start < 0 || end < 0)
continue;
- spans.add(new int[]{
- start,
- end,
- highlight[2],
- 0 // Dummy value for later
- });
+ intArray = new int[]{
+ start,
+ end,
+ highlight[2],
+ 0 // Dummy value for later
+ };
+
+ log.trace("IntArray: {}", intArray);
+ log.trace("PTO-start: {}", pto.start(ldid, highlight[0]));
+ log.trace("PTO-end: {}", pto.end(ldid, highlight[1]));
+
+ spans.add(intArray);
};
};
diff --git a/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java b/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
index 62eb516..5e57185 100644
--- a/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
+++ b/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
@@ -116,6 +116,7 @@
Integer[] pair = this.offsets.get(ptoa);
if (pair == null)
return -1;
+
return pair[1];
};
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
index bf8fd29..a4c83b7 100644
--- a/src/main/resources/log4j.properties
+++ b/src/main/resources/log4j.properties
@@ -1,6 +1,6 @@
## logger file can be used with
-log4j.rootLogger = DEBUG, stdout
+# log4j.rootLogger = DEBUG, stdout
#log4j.logger.de.ids_mannheim.korap.query.spans.ElementSpans = TRACE, stdout
#log4j.logger.de.ids_mannheim.korap.query.spans.WithinSpans = TRACE, stdout