Updated serialization (2 tests broken)
diff --git a/src/main/java/de/ids_mannheim/korap/KorapIndex.java b/src/main/java/de/ids_mannheim/korap/KorapIndex.java
index def2e5b..edbeb5c 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapIndex.java
@@ -573,7 +573,7 @@
// Do not load all of this, in case the doc is the same!
Document doc = lreader.document(localDocID, fieldsToLoadLocal);
- KorapMatch match = kr.addMatch(); // new KorapMatch();
+ KorapMatch match = kr.addMatch(pto); // new KorapMatch();
match.startPos = spans.start();
match.endPos = spans.end();
@@ -715,10 +715,6 @@
break;
i++;
};
-
- for (KorapMatch km : atomicMatches) {
- km.processHighlight(pto);
- };
atomicMatches.clear();
};
diff --git a/src/main/java/de/ids_mannheim/korap/KorapMatch.java b/src/main/java/de/ids_mannheim/korap/KorapMatch.java
index f1b57cb..2e892bc 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapMatch.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapMatch.java
@@ -44,9 +44,17 @@
private Collection<byte[]> payload;
private ArrayList<int[]> highlight;
+ public PositionsToOffset positionsToOffset;
+
+ private boolean processed = false;
+
// Logger
private final static Logger log = LoggerFactory.getLogger(KorapMatch.class);
+ public KorapMatch (PositionsToOffset pto) {
+ this.positionsToOffset = pto;
+ };
+
/**
* Insert a highlight for the snippet view by means of positional
* offsets and an optional class number.
@@ -64,7 +72,7 @@
};
public void addHighlight (int start, int end) {
- this.addHighlight(start, end, (int) 1);
+ this.addHighlight(start, end, (int) 0);
};
public void addHighlight (int start, int end, int number) {
@@ -115,16 +123,15 @@
* @see #snippetBrackets()
* @see PositionsToOffset
*/
- public void processHighlight (PositionsToOffset pto) {
+ public void processHighlight () {
+
+ if (processed)
+ return;
log.trace("Start highlight processing ...");
// Get the list of spans for matches and highlighting
- LinkedList<int[]> spans = this._processHighlightSpans(
- pto,
- leftTokenContext,
- rightTokenContext
- );
+ LinkedList<int[]> spans = this._processHighlightSpans(leftTokenContext,rightTokenContext);
for (int[] s : spans) {
log.trace(" >> [Spans] Start: {}, End: {}, Class: {}, Dummy: {}", s[0], s[1], s[2], s[3]);
@@ -136,12 +143,15 @@
log.trace(" >> [Stack] Start: {}, End: {}, Class: {}, Dummy: {}", s[0], s[1], s[2], s[3]);
};
-
- if (this.tempSnippet == null)
+ if (this.tempSnippet == null) {
+ processed = true;
return;
+ };
this._processHighlightSnippet(this.tempSnippet, stack);
+ processed = true;
+
/*
Collection.sort(openList);
@@ -194,23 +204,31 @@
this.characters = characters;
};
- public String toHTML () {
+ public String toHTML (byte[] level) {
if (this.type == 1) {
StringBuilder sb = new StringBuilder();
- sb.append("<span class=\"");
if (this.number == -1) {
- sb.append("korap-match\"");
+ sb.append("<span class=\"match\">");
}
else {
- sb.append("korap-highlight korap-class-")
- .append(this.number)
- .append('"');
+ byte actLevel = level[255];
+ if (level[this.number] == '\0') {
+ level[this.number] = actLevel;
+ level[255]++;
+ };
+ sb.append("<em class=\"class-")
+ .append(this.number)
+ .append(" level-")
+ .append(actLevel)
+ .append("\">");
};
- sb.append('>');
return sb.toString();
}
else if (this.type == 2) {
- return "</span>";
+ if (this.number == -1)
+ return "</span>";
+ // level[]
+ return "</em>";
};
return encodeHTML(this.characters);
};
@@ -229,9 +247,8 @@
return sb.toString();
}
else if (this.type == 2) {
- if (this.number == -1) {
+ if (this.number == -1)
return "]";
- }
return "}";
};
return this.characters;
@@ -353,51 +370,51 @@
@JsonProperty("snippet")
public String getSnippetHTML () {
+
+ this.processHighlight();
+
if (this.snippetHTML != null)
return this.snippetHTML;
StringBuilder sb = new StringBuilder();
short start = (short) 0;
- short end = this.snippetStack.size();
+ short end = this.snippetStack.size();
+ byte[] level = new byte[256];
+ level[255] = 0;
HighlightCombinatorElement elem = this.snippetStack.getFirst();
- // Create context, if there is any
- if ((elem.type == 0) || startMore) {
- sb.append("<span class=\"korap-context-left\">");
- if (startMore)
- sb.append("<span class=\"korap-more\"></span>");
- if (elem.type == 0) {
- sb.append(elem.toHTML());
- start++;
- };
- sb.append("</span>");
+ // Create context
+ sb.append("<span class=\"context-left\">");
+ if (startMore)
+ sb.append("<span class=\"more\"></span>");
+
+ if (elem.type == 0) {
+ sb.append(elem.toHTML(level));
+ start++;
};
+ sb.append("</span>");
elem = this.snippetStack.getLast();
StringBuilder rightContext = new StringBuilder();
// Create context, if trhere is any
- if (endMore || (elem != null && elem.type == 0)) {
- rightContext.append("<span class=\"korap-context-right\">");
- if (elem != null && elem.type == 0) {
- rightContext.append(elem.toHTML());
- end--;
- };
- if (endMore)
- rightContext.append("<span class=\"korap-more\"></span>");
- rightContext.append("</span>");
+ rightContext.append("<span class=\"context-right\">");
+ if (elem != null && elem.type == 0) {
+ rightContext.append(elem.toHTML(level));
+ end--;
};
+ if (endMore)
+ rightContext.append("<span class=\"more\"></span>");
+ rightContext.append("</span>");
for (short i = start; i < end; i++) {
- sb.append(this.snippetStack.get(i).toHTML());
+ sb.append(this.snippetStack.get(i).toHTML(level));
};
- if (rightContext != null) {
- sb.append(rightContext);
- };
+ sb.append(rightContext);
return (this.snippetHTML = sb.toString());
};
@@ -409,6 +426,9 @@
@JsonIgnore
public String getSnippetBrackets () {
+
+ this.processHighlight();
+
if (this.snippetBrackets != null)
return this.snippetBrackets;
@@ -428,7 +448,9 @@
};
- // Todo: Not very fast - just a direct translation of the perl script
+ // This sorts all highlight and match spans to make them nesting correctly,
+ // even in case they overlap
+ // TODO: Not very fast - improve!
private ArrayList<int[]> _processHighlightStack (LinkedList<int[]> spans) {
log.trace("Create Stack");
@@ -445,6 +467,7 @@
ArrayList<int[]> stack = new ArrayList<>(openList.size() * 2);
+ // Create stack unless both lists are empty
while (!openList.isEmpty() || !closeList.isEmpty()) {
if (openList.isEmpty()) {
@@ -465,8 +488,7 @@
};
- private LinkedList<int[]> _processHighlightSpans (PositionsToOffset pto,
- boolean leftTokenContext,
+ private LinkedList<int[]> _processHighlightSpans (boolean leftTokenContext,
boolean rightTokenContext) {
int startOffsetChar,
endOffsetChar,
@@ -478,14 +500,14 @@
int ldid = this.localDocID;
// Match position
- startPosChar = pto.start(ldid, this.startPos);
+ startPosChar = this.positionsToOffset.start(ldid, this.startPos);
// Check potential differing start characters
// e.g. from element spans
if (potentialStartPosChar != -1 && startPosChar > potentialStartPosChar)
startPosChar = potentialStartPosChar;
- endPosChar = pto.end(ldid, this.endPos - 1);
+ endPosChar = this.positionsToOffset.end(ldid, this.endPos - 1);
if (endPosChar < potentialEndPosChar)
endPosChar = potentialEndPosChar;
@@ -494,7 +516,7 @@
// left context
if (leftTokenContext) {
- startOffsetChar = pto.start(ldid, startPos - this.leftContext);
+ startOffsetChar = this.positionsToOffset.start(ldid, startPos - this.leftContext);
}
else {
startOffsetChar = startPosChar - this.leftContext;
@@ -502,7 +524,7 @@
// right context
if (rightTokenContext) {
- endOffsetChar = pto.end(ldid, this.endPos + this.rightContext - 1);
+ endOffsetChar = this.positionsToOffset.end(ldid, this.endPos + this.rightContext - 1);
log.trace("For endOffset {} ({}+{}-1) pto returns {}", (this.endPos + this.rightContext - 1), this.endPos, this.rightContext, endOffsetChar);
}
else {
@@ -552,7 +574,7 @@
spans.add(intArray);
// highlights
- // I'm not sure about this.
+ // -- I'm not sure about this.
if (this.highlight != null) {
for (int[] highlight : this.highlight) {
@@ -575,8 +597,8 @@
end -= startOffsetChar;
*/
- int start = pto.start(ldid, highlight[0]) - startOffsetChar;
- int end = pto.end(ldid, highlight[1]) - startOffsetChar;
+ int start = this.positionsToOffset.start(ldid, highlight[0]) - startOffsetChar;
+ int end = this.positionsToOffset.end(ldid, highlight[1]) - startOffsetChar;
if (start < 0 || end < 0)
continue;
@@ -589,8 +611,8 @@
};
log.trace("IntArray: {}", intArray);
- log.trace("PTO-start: {}", pto.start(ldid, highlight[0]));
- log.trace("PTO-end: {}", pto.end(ldid, highlight[1]));
+ log.trace("PTO-start: {}", start + startOffsetChar);
+ log.trace("PTO-end: {}", end + startOffsetChar);
spans.add(intArray);
};
diff --git a/src/main/java/de/ids_mannheim/korap/KorapResult.java b/src/main/java/de/ids_mannheim/korap/KorapResult.java
index 3abb51d..c24ce3b 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapResult.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapResult.java
@@ -2,6 +2,7 @@
import java.util.*;
import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.index.PositionsToOffset;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,13 +66,14 @@
this.matches.add(km);
};
- public KorapMatch addMatch () {
- KorapMatch km = new KorapMatch();
+ public KorapMatch addMatch (PositionsToOffset pto) {
+ KorapMatch km = new KorapMatch(pto);
// Temporary:
km.leftContext = this.leftContextOffset;
km.leftTokenContext = this.leftTokenContext;
km.rightContext = this.rightContextOffset;
km.rightTokenContext = this.rightTokenContext;
+ km.positionsToOffset = pto;
this.add(km);
return km;
};
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 5e57185..c893d53 100644
--- a/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
+++ b/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
@@ -204,7 +204,7 @@
};
}
catch (IOException e) {
- // log.warn(e.getLocalizedMessage());
+ log.warn(e.getLocalizedMessage());
};
processed = true;
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanClassQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanClassQuery.java
index 5ce4e70..a045e5f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanClassQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanClassQuery.java
@@ -29,7 +29,11 @@
public SpanClassQuery (SpanQuery highlight, byte number) {
this.field = highlight.getField();
this.highlight = highlight;
- this.number = number;
+ if (number <= 15) {
+ this.number = number;
+ } else{
+ this.number = (byte) 0;
+ };
};
public SpanClassQuery (SpanQuery highlight) {
diff --git a/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java b/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
index bfc6c33..65eba5b 100644
--- a/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
+++ b/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
@@ -1,32 +1,13 @@
import java.util.*;
import java.io.IOException;
-// import org.apache.lucene.search.postingshighlight.PostingsHighlighter;
+import org.apache.lucene.search.spans.SpanQuery;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.RAMDirectory;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexReaderContext;
-import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.index.DirectoryReader;
-
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
-
-import org.apache.lucene.search.IndexSearcher;
-
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-
-import org.apache.lucene.util.Version;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.TextField;
+import de.ids_mannheim.korap.KorapIndex;
+import de.ids_mannheim.korap.KorapQuery;
+import de.ids_mannheim.korap.KorapResult;
+import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.index.FieldDocument;
import static de.ids_mannheim.korap.Test.*;
@@ -39,65 +20,39 @@
@RunWith(JUnit4.class)
public class TestHighlight { // extends LuceneTestCase {
- // Create index in RAM
- private Directory index = new RAMDirectory();
-
- StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_43);
-
- IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_43, analyzer);
-
-
@Test
public void checkHighlights () throws IOException {
- // Check directory
- IndexWriter w = new IndexWriter(index, config);
+ KorapIndex ki = new KorapIndex();
+ String json = new String(
+"{" +
+" \"fields\" : [" +
+" { "+
+" \"primaryData\" : \"abc\"" +
+" }," +
+" {" +
+" \"name\" : \"tokens\"," +
+" \"data\" : [" +
+" [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"]," +
+" [ \"s:b\", \"i:b\", \"_1#1-2\" ]," +
+" [ \"s:c\", \"i:c\", \"_2#2-3\" ]" +
+" ]" +
+" }" +
+" ]" +
+"}");
- Document doc = new Document();
- FieldType textFieldWithTermVectors = new FieldType(TextField.TYPE_STORED);
- textFieldWithTermVectors.setStoreTermVectors(true);
- textFieldWithTermVectors.setStoreTermVectorOffsets(true);
- textFieldWithTermVectors.setStoreTermVectorPositions(true);
+ FieldDocument fd = ki.addDoc(json);
+ ki.commit();
- Field textFieldAnalyzed = new Field(
- "text",
- "Er wagte nicht, sich zu ruehren. Er war starr vor Angst.",
- textFieldWithTermVectors
- );
-
- MultiTermTokenStream ts = getTermVector(
- "Er#0-2|PPER|er|c:nom;n:sg;g:masc;p:3|s:<$0-32 " +
- "wagte#3-8|VVFIN|wagen|p:3;n:sg;t:past;m:ind| " +
- "nicht#9-14|PTKNEG|nicht|| " +
- ",#14-15|$,|,|| " +
- "sich#16-20|PRF|sich|c:acc;p:3;n:sg| " +
- "zu#21-23|PTKZU|zu|| " +
- "ruehren#24-31|VVFIN|ruehren|| " +
- ".#31-32|$.|.||s:>$0-32 " +
- "Er#33-35|PPER|er|c:nom;p:3;n:sg;g:masc|s:<$33-56 " +
- "war#36-39|VAFIN|sein|p:3;n:sg;t:past;m:ind| " +
- "starr#40-45|ADJD|starr|comp:pos| " +
- "vor#46-49|APPR|vor|| " +
- "Angst#50-55|NN|angst|c:dat;n:sg;g:fem| " +
- ".#55-56|$.|.||s:>$33-56"
- );
- textFieldAnalyzed.setTokenStream( ts );
+ KorapQuery kq = new KorapQuery("tokens");
+ KorapResult kr = ki.search((SpanQuery) kq.seq(kq._(1, kq.seg("s:b"))).toQuery());
+ KorapMatch km = kr.getMatch(0);
+ assertEquals("<span class=\"context-left\">a</span><span class=\"match\"><em class=\"class-1 level-0\">b</em></span><span class=\"context-right\">c</span>", km.getSnippetHTML());
- doc.add(textFieldAnalyzed);
-
- // Add document to writer
- w.addDocument(doc);
-
- assertEquals(1, w.numDocs());
-
- w.close();
-
- DirectoryReader reader = DirectoryReader.open( index );
-
- // Check searcher
- IndexSearcher searcher = new IndexSearcher( reader );
-
+ kr = ki.search((SpanQuery) kq.seq(kq._(1, kq.seg("s:b"))).append(kq._(2, kq.seg("s:c"))).toQuery());
+ km = kr.getMatch(0);
+ assertEquals("<span class=\"context-left\">a</span><span class=\"match\"><em class=\"class-1 level-0\">b</em><em class=\"class-2 level-0\">c</em></span><span class=\"context-right\"></span>", km.getSnippetHTML());
};
};
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
index 4762828..a99ce8a 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
@@ -65,7 +65,7 @@
assertEquals("StartPos (0)", 7, kr.match(0).startPos);
assertEquals("EndPos (0)", 9, kr.match(0).endPos);
assertEquals("SnippetBrackets (0)", "... bcabca[ba]c", kr.match(0).snippetBrackets());
- assertEquals("SnippetHTML (0)", "<span class=\"korap-context-left\"><span class=\"korap-more\"></span>bcabca</span><span class=\"korap-match\">ba</span><span class=\"korap-context-right\">c</span>", kr.match(0).snippetHTML());
+ assertEquals("SnippetHTML (0)", "<span class=\"context-left\"><span class=\"more\"></span>bcabca</span><span class=\"match\">ba</span><span class=\"context-right\">c</span>", kr.match(0).snippetHTML());
sq = new SpanTermQuery(new Term("base", "s:b"));
kr = ki.search(sq, (short) 10);
@@ -76,7 +76,7 @@
assertEquals("SnippetBrackets (0)", "a[b]cabcab ...", kr.match(0).snippetBrackets());
- assertEquals("SnippetHTML (0)", "<span class=\"korap-context-left\">a</span><span class=\"korap-match\">b</span><span class=\"korap-context-right\">cabcab<span class=\"korap-more\"></span></span>", kr.match(0).snippetHTML());
+ assertEquals("SnippetHTML (0)", "<span class=\"context-left\">a</span><span class=\"match\">b</span><span class=\"context-right\">cabcab<span class=\"more\"></span></span>", kr.match(0).snippetHTML());
assertEquals("StartPos (1)", 4, kr.match(1).startPos);
assertEquals("EndPos (1)", 5, kr.match(1).endPos);
@@ -92,7 +92,7 @@
assertEquals("StartPos (0)", 1, kr.match(0).startPos);
assertEquals("EndPos (0)", 2, kr.match(0).endPos);
assertEquals("snippetBrackets (0)", "a[{b}]cabcab ...", kr.match(0).snippetBrackets());
- assertEquals("snippetHTML (0)", "<span class=\"korap-context-left\">a</span><span class=\"korap-match\"><span class=\"korap-highlight korap-class-0\">b</span></span><span class=\"korap-context-right\">cabcab<span class=\"korap-more\"></span></span>", kr.match(0).snippetHTML());
+ assertEquals("snippetHTML (0)", "<span class=\"context-left\">a</span><span class=\"match\"><em class=\"class-0 level-0\">b</em></span><span class=\"context-right\">cabcab<span class=\"more\"></span></span>", kr.match(0).snippetHTML());
assertEquals("StartPos (1)", 4, kr.match(1).startPos);
assertEquals("EndPos (1)", 5, kr.match(1).endPos);
@@ -114,7 +114,7 @@
assertEquals("EndPos (0)", 2, kr.match(0).endPos);
assertEquals("SnippetBrackets (0)", "[a{1:b}]cabcab ...", kr.match(0).snippetBrackets());
- assertEquals("SnippetHTML (0)", "<span class=\"korap-match\">a<span class=\"korap-highlight korap-class-1\">b</span></span><span class=\"korap-context-right\">cabcab<span class=\"korap-more\"></span></span>", kr.match(0).snippetHTML());
+ assertEquals("SnippetHTML (0)", "<span class=\"context-left\"></span><span class=\"match\">a<em class=\"class-1 level-0\">b</em></span><span class=\"context-right\">cabcab<span class=\"more\"></span></span>", kr.match(0).snippetHTML());
assertEquals("StartPos (1)", 3, kr.match(1).startPos);
assertEquals("EndPos (1)", 5, kr.match(1).endPos);
@@ -159,19 +159,19 @@
assertEquals("totalResults", 1, kr.totalResults());
assertEquals("SnippetBrackets (0)", "abcabc[a{2:b{a}}]c", kr.match(0).snippetBrackets());
- assertEquals("SnippetHTML (0)", "<span class=\"korap-context-left\">abcabc</span><span class=\"korap-match\">a<span class=\"korap-highlight korap-class-2\">b<span class=\"korap-highlight korap-class-0\">a</span></span></span><span class=\"korap-context-right\">c</span>", kr.match(0).snippetHTML());
+ assertEquals("SnippetHTML (0)", "<span class=\"context-left\">abcabc</span><span class=\"match\">a<em class=\"class-2 level-0\">b<em class=\"class-0 level-1\">a</em></em></span><span class=\"context-right\">c</span>", kr.match(0).snippetHTML());
// Offset tokens
kr = ki.search(sq, 0, (short) 10, true, (short) 2, true, (short) 2);
assertEquals("totalResults", 1, kr.totalResults());
assertEquals("SnippetBrackets (0)", "... bc[a{2:b{a}}]c", kr.match(0).snippetBrackets());
- assertEquals("SnippetHTML (0)", "<span class=\"korap-context-left\"><span class=\"korap-more\"></span>bc</span><span class=\"korap-match\">a<span class=\"korap-highlight korap-class-2\">b<span class=\"korap-highlight korap-class-0\">a</span></span></span><span class=\"korap-context-right\">c</span>", kr.match(0).snippetHTML());
+ assertEquals("SnippetHTML (0)", "<span class=\"context-left\"><span class=\"more\"></span>bc</span><span class=\"match\">a<em class=\"class-2 level-0\">b<em class=\"class-0 level-1\">a</em></em></span><span class=\"context-right\">c</span>", kr.match(0).snippetHTML());
// Offset Characters
kr = ki.search(sq, 0, (short) 10, false, (short) 2, false, (short) 2);
assertEquals("totalResults", 1, kr.totalResults());
assertEquals("SnippetBrackets (0)", "... bc[a{2:b{a}}]c", kr.match(0).snippetBrackets());
- assertEquals("SnippetHTML (0)", "<span class=\"korap-context-left\"><span class=\"korap-more\"></span>bc</span><span class=\"korap-match\">a<span class=\"korap-highlight korap-class-2\">b<span class=\"korap-highlight korap-class-0\">a</span></span></span><span class=\"korap-context-right\">c</span>", kr.match(0).snippetHTML());
+ assertEquals("SnippetHTML (0)", "<span class=\"context-left\"><span class=\"more\"></span>bc</span><span class=\"match\">a<em class=\"class-2 level-0\">b<em class=\"class-0 level-1\">a</em></em></span><span class=\"context-right\">c</span>", kr.match(0).snippetHTML());
// System.err.println(kr.toJSON());
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
index 2472b2a..1b79347 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
@@ -129,8 +129,6 @@
KorapMatch km = kr.getMatch(0);
- System.err.println("----");
-
assertEquals(km.getPrimaryData(),"abc");
assertEquals(km.getCorpusID(),"WPD");
assertEquals(km.getID(),"WPD-AAA-00001");
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
index f2fe7aa..3576fc5 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
@@ -70,7 +70,7 @@
assertEquals("EndPos (0)", 9, kr.match(0).endPos);
assertEquals("SnippetBrackets (0)", "... bcabca[b{a}]c", kr.match(0).snippetBrackets());
- assertEquals("Test no 'more' context", "<span class=\"korap-context-left\"><span class=\"korap-more\"></span>bcabca</span><span class=\"korap-match\">b<span class=\"korap-highlight korap-class-0\">a</span></span><span class=\"korap-context-right\">c</span>", kr.match(0).snippetHTML());
+ assertEquals("Test no 'more' context", "<span class=\"context-left\"><span class=\"more\"></span>bcabca</span><span class=\"match\">b<em class=\"class-0 level-0\">a</em></span><span class=\"context-right\">c</span>", kr.match(0).snippetHTML());
sq = new SpanMatchModifyQuery(
new SpanNextQuery(
@@ -101,13 +101,13 @@
assertEquals("EndPos (0)", 2, kr.match(0).endPos);
assertEquals("SnippetBrackets (0)", "a[b]cabcab ...", kr.match(0).snippetBrackets());
- assertEquals("<span class=\"korap-context-left\">a</span><span class=\"korap-match\">b</span><span class=\"korap-context-right\">cabcab<span class=\"korap-more\"></span></span>", kr.match(0).snippetHTML());
+ assertEquals("<span class=\"context-left\">a</span><span class=\"match\">b</span><span class=\"context-right\">cabcab<span class=\"more\"></span></span>", kr.match(0).snippetHTML());
assertEquals("StartPos (1)", 4, kr.match(1).startPos);
assertEquals("EndPos (1)", 5, kr.match(1).endPos);
assertEquals("SnippetBrackets (1)", "abca[b]cabac", kr.match(1).snippetBrackets());
- assertEquals("<span class=\"korap-context-left\">abca</span><span class=\"korap-match\">b</span><span class=\"korap-context-right\">cabac</span>", kr.match(1).snippetHTML());
+ assertEquals("<span class=\"context-left\">abca</span><span class=\"match\">b</span><span class=\"context-right\">cabac</span>", kr.match(1).snippetHTML());
assertEquals("StartPos (2)", 7, kr.match(2).startPos);
assertEquals("EndPos (2)", 8, kr.match(2).endPos);
@@ -133,7 +133,7 @@
assertEquals("totalResults", 1, kr.totalResults());
assertEquals("SnippetBrackets (0)", "... bcabca[b{a}]c", kr.match(0).snippetBrackets());
- assertEquals("SnippetHTML (0) 1", "<span class=\"korap-context-left\"><span class=\"korap-more\"></span>bcabca</span><span class=\"korap-match\">b<span class=\"korap-highlight korap-class-0\">a</span></span><span class=\"korap-context-right\">c</span>", kr.match(0).snippetHTML());
+ assertEquals("SnippetHTML (0) 1", "<span class=\"context-left\"><span class=\"more\"></span>bcabca</span><span class=\"match\">b<em class=\"class-0 level-0\">a</em></span><span class=\"context-right\">c</span>", kr.match(0).snippetHTML());
// Offset tokens
kr = ki.search(sq, 0, (short) 10, true, (short) 2, true, (short) 2);
@@ -147,7 +147,7 @@
assertEquals("totalResults", 1, kr.totalResults());
assertEquals("SnippetBrackets (0)", "... a[b{a}] ...", kr.match(0).snippetBrackets());
- assertEquals("SnippetHTML (0) 2", "<span class=\"korap-context-left\"><span class=\"korap-more\"></span>a</span><span class=\"korap-match\">b<span class=\"korap-highlight korap-class-0\">a</span></span><span class=\"korap-context-right\"><span class=\"korap-more\"></span></span>", kr.match(0).snippetHTML());
+ assertEquals("SnippetHTML (0) 2", "<span class=\"context-left\"><span class=\"more\"></span>a</span><span class=\"match\">b<em class=\"class-0 level-0\">a</em></span><span class=\"context-right\"><span class=\"more\"></span></span>", kr.match(0).snippetHTML());
// System.err.println(kr.toJSON());
@@ -232,27 +232,27 @@
kr = ki.search(sq, (short) 20);
assertEquals("totalResults", 7, kr.totalResults());
- assertEquals("SnippetBrackets (0)", "<span class=\"korap-match\">a</span><span class=\"korap-context-right\">bcabca<span class=\"korap-more\"></span></span>", kr.match(0).snippetHTML());
+ assertEquals("SnippetBrackets (0)", "<span class=\"context-left\"></span><span class=\"match\">a</span><span class=\"context-right\">bcabca<span class=\"more\"></span></span>", kr.match(0).snippetHTML());
assertEquals("SnippetBrackets (0)", "[a]bcabca ...", kr.match(0).snippetBrackets());
assertEquals("SnippetBrackets (1)", "ab[c]abcaba ...", kr.match(1).snippetBrackets());
- assertEquals("SnippetBrackets (1)", "<span class=\"korap-context-left\">ab</span><span class=\"korap-match\">c</span><span class=\"korap-context-right\">abcaba<span class=\"korap-more\"></span></span>", kr.match(1).snippetHTML());
+ assertEquals("SnippetBrackets (1)", "<span class=\"context-left\">ab</span><span class=\"match\">c</span><span class=\"context-right\">abcaba<span class=\"more\"></span></span>", kr.match(1).snippetHTML());
assertEquals("SnippetBrackets (6)", "... abcaba[c]", kr.match(6).snippetBrackets());
- assertEquals("SnippetBrackets (6)", "<span class=\"korap-context-left\"><span class=\"korap-more\"></span>abcaba</span><span class=\"korap-match\">c</span>", kr.match(6).snippetHTML());
+ assertEquals("SnippetBrackets (6)", "<span class=\"context-left\"><span class=\"more\"></span>abcaba</span><span class=\"match\">c</span><span class=\"context-right\"></span>", kr.match(6).snippetHTML());
kr = ki.search(sq, 0, (short) 20, true, (short) 0, true, (short) 0);
assertEquals("totalResults", 7, kr.totalResults());
assertEquals("SnippetBrackets (0)", "[a] ...", kr.match(0).snippetBrackets());
- assertEquals("SnippetHTML (0)", "<span class=\"korap-match\">a</span><span class=\"korap-context-right\"><span class=\"korap-more\"></span></span>", kr.match(0).snippetHTML());
+ assertEquals("SnippetHTML (0)", "<span class=\"context-left\"></span><span class=\"match\">a</span><span class=\"context-right\"><span class=\"more\"></span></span>", kr.match(0).snippetHTML());
assertEquals("SnippetBrackets (1)", "... [c] ...", kr.match(1).snippetBrackets());
- assertEquals("SnippetHTML (1)", "<span class=\"korap-context-left\"><span class=\"korap-more\"></span></span><span class=\"korap-match\">c</span><span class=\"korap-context-right\"><span class=\"korap-more\"></span></span>", kr.match(1).snippetHTML());
+ assertEquals("SnippetHTML (1)", "<span class=\"context-left\"><span class=\"more\"></span></span><span class=\"match\">c</span><span class=\"context-right\"><span class=\"more\"></span></span>", kr.match(1).snippetHTML());
assertEquals("SnippetBrackets (6)", "... [c]", kr.match(6).snippetBrackets());
- assertEquals("SnippetBrackets (6)", "<span class=\"korap-context-left\"><span class=\"korap-more\"></span></span><span class=\"korap-match\">c</span>", kr.match(6).snippetHTML());
+ assertEquals("SnippetBrackets (6)", "<span class=\"context-left\"><span class=\"more\"></span></span><span class=\"match\">c</span><span class=\"context-right\"></span>", kr.match(6).snippetHTML());
};
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
index 8c7374a..8f40a7f 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
@@ -702,7 +702,7 @@
assertEquals("totalResults", 1, kr.totalResults());
assertEquals("... schrie: [\"{3:Das war ich}!\"] und ...",kr.match(0).snippetBrackets());
- assertEquals("<span class=\"korap-context-left\"><span class=\"korap-more\"></span>schrie: </span><span class=\"korap-match\">"<span class=\"korap-highlight korap-class-3\">Das war ich</span>!"</span><span class=\"korap-context-right\"> und<span class=\"korap-more\"></span></span>",kr.match(0).snippetHTML());
+ assertEquals("<span class=\"context-left\"><span class=\"more\"></span>schrie: </span><span class=\"match\">"<em class=\"class-3 level-0\">Das war ich</em>!"</span><span class=\"context-right\"> und<span class=\"more\"></span></span>",kr.match(0).snippetHTML());
kr = ki.search(sq, 0, (short) 15, true, (short) 0, true, (short) 0);