Reformat
Change-Id: I595ad41b8776ba2c0aeac103b8fc277ef1b3a9d3
diff --git a/src/main/java/de/ids_mannheim/korap/Krill.java b/src/main/java/de/ids_mannheim/korap/Krill.java
index 0531c63..ccea5df 100644
--- a/src/main/java/de/ids_mannheim/korap/Krill.java
+++ b/src/main/java/de/ids_mannheim/korap/Krill.java
@@ -215,7 +215,8 @@
// TODO: Temporary
if (collNode.fieldNames().hasNext()) {
- this.setCollection(new KrillCollection().fromKoral(collNode));
+ this.setCollection(new KrillCollection()
+ .fromKoral(collNode));
};
}
diff --git a/src/main/java/de/ids_mannheim/korap/KrillCollection.java b/src/main/java/de/ids_mannheim/korap/KrillCollection.java
index 50f591a..d839422 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillCollection.java
@@ -292,6 +292,7 @@
throw new QueryException(813, "Collection type is not supported");
};
+
/**
* Set the collection from a {@link CollectionBuilder} object.
*
diff --git a/src/main/java/de/ids_mannheim/korap/KrillIndex.java b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
index bc10a5d..ca9f70b 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
@@ -535,7 +535,7 @@
}
catch (IOException e) {
log.error("File json not found or unmappable: {}",
- e.getLocalizedMessage());
+ e.getLocalizedMessage());
};
return (FieldDocument) null;
};
@@ -783,7 +783,8 @@
// Rewrite parse ID
uid = new Integer(Integer.parseInt(uid)).toString();
- Filter filter = (Filter) new QueryWrapperFilter(new TermQuery(new Term("UID", uid)));
+ Filter filter = (Filter) new QueryWrapperFilter(new TermQuery(new Term(
+ "UID", uid)));
try {
@@ -792,7 +793,7 @@
// Retrieve the single document of interest
DocIdSet filterSet = filter.getDocIdSet(atomic, atomic.reader()
- .getLiveDocs());
+ .getLiveDocs());
// Create a bitset for the correct document
Bits bitset = filterSet.bits();
@@ -841,6 +842,7 @@
return text;
};
+
public String getMatchIDWithContext (String id) {
/* No includeHighlights */
return "";
@@ -1031,7 +1033,7 @@
if (DEBUG)
log.trace("The final regexObj is {}", regexObj.toString());
};
-
+
try {
// Iterate over all atomic indices and find the matching document
@@ -1092,14 +1094,12 @@
// Todo:
SearchContext context = match.getContext();
- // Override the normal match marking
- // to have an inner match
- match.overrideMatchPosition(
- match.getStartPos(),
- match.getEndPos() - 1
- );
+ // Override the normal match marking
+ // to have an inner match
+ match.overrideMatchPosition(match.getStartPos(),
+ match.getEndPos() - 1);
-
+
// Search for minimal surrounding sentences
if (extendToSentence) {
String element = "base/s:s";
diff --git a/src/main/java/de/ids_mannheim/korap/KrillQuery.java b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
index 0bb3e37..538b0ad 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
@@ -299,8 +299,8 @@
if (DEBUG)
log.trace("Wrap class reference {}", number);
- return new SpanFocusQueryWrapper(
- this._fromKoral(operands.get(0)), number);
+ return new SpanFocusQueryWrapper(this._fromKoral(operands
+ .get(0)), number);
case "koral:token":
diff --git a/src/main/java/de/ids_mannheim/korap/KrillStats.java b/src/main/java/de/ids_mannheim/korap/KrillStats.java
index 898058b..24d3467 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillStats.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillStats.java
@@ -19,31 +19,31 @@
* Create a Statistics object.
*
* This is early work and highliy experimental!
- *
+ *
* <blockquote><pre>
* KrillStats ks = new KrillStats(json);
* </pre></blockquote>
- *
+ *
* Should serialize to something like
- *
+ *
* "stats" : {
- * "@type" : "koral:stats",
- * "collection" : [
- * {
- * "@type" : "stats:collection",
- * "foundry" : "base",
- * "layer" : "s",
- * "key" : "s",
- * "value" : 450
- * },
- * {
- * "@type" : "stats:collection",
- * "key" : "texts",
- * "value" : 2
- * }
- * ]
+ * "@type" : "koral:stats",
+ * "collection" : [
+ * {
+ * "@type" : "stats:collection",
+ * "foundry" : "base",
+ * "layer" : "s",
+ * "key" : "s",
+ * "value" : 450
+ * },
+ * {
+ * "@type" : "stats:collection",
+ * "key" : "texts",
+ * "value" : 2
* }
- *
+ * ]
+ * }
+ *
*
* @author diewald
*/
@@ -53,8 +53,7 @@
public final class KrillStats extends Notifications {
// Logger
- private final static Logger log = LoggerFactory
- .getLogger(KrillStats.class);
+ private final static Logger log = LoggerFactory.getLogger(KrillStats.class);
// This advices the java compiler to ignore all loggings
public static final boolean DEBUG = false;
@@ -66,6 +65,7 @@
*/
public KrillStats () {};
+
@Override
public JsonNode toJsonNode () {
ObjectMapper mapper = new ObjectMapper();
@@ -74,5 +74,5 @@
json.put("@type", "koral:stats");
return (JsonNode) json;
- }
+ }
};
diff --git a/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java b/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java
index f90945f..b293a47 100644
--- a/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java
+++ b/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java
@@ -79,6 +79,7 @@
// Meta information regarding annotations
tokenSource, layerInfos;
+
/**
* Populate document meta information with information coming from
* the index.
@@ -97,6 +98,7 @@
this.populateDocument(doc, field, fieldList);
};
+
public void populateFields (Document doc) {
HashSet<String> fieldList = new HashSet<>(32);
@@ -107,6 +109,7 @@
this.populateFields(doc, fieldList);
};
+
public void populateFields (Document doc, Collection<String> fields) {
// Remember - never serialize "tokens"
@@ -205,6 +208,7 @@
this.setFileEditionStatement(doc.get("fileEditionStatement"));
};
+
/**
* Populate document meta information with information coming from
* the index.
@@ -1184,12 +1188,14 @@
return this.field;
};
+
@Deprecated
@JsonProperty("corpusID")
public String getCorpusID () {
return this.corpusID;
};
+
@Deprecated
public void setCorpusID (String corpusID) {
this.corpusID = corpusID;
@@ -1208,6 +1214,7 @@
this.ID = ID;
};
+
/**
* Serialize response as a {@link JsonNode}.
*
diff --git a/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java b/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
index 73a7ecf..f1f412d 100644
--- a/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
+++ b/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
@@ -305,6 +305,7 @@
this.addString("ID", ID);
};
+
@Override
@JsonIgnore
public void setUID (int ID) {
@@ -314,6 +315,7 @@
}
};
+
@Override
public void setUID (String ID) {
if (ID != null) {
@@ -322,6 +324,7 @@
};
};
+
// No longer supported
@Override
public void setLayerInfo (String layerInfo) {
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 40c7300..965c736 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Match.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Match.java
@@ -788,7 +788,7 @@
// Start building highlighted snippets
private boolean _processHighlight () {
- if (processed)
+ if (processed)
return true;
// Relevant details are missing
@@ -810,10 +810,11 @@
log.trace("PTO will retrieve {} & {} (Match boundary)",
this.getStartPos(), this.getEndPos());
- // Set inner match
- if (this.innerMatchEndPos != 1)
- this.addHighlight(this.innerMatchStartPos, this.innerMatchEndPos, -1);
-
+ // Set inner match
+ if (this.innerMatchEndPos != 1)
+ this.addHighlight(this.innerMatchStartPos, this.innerMatchEndPos,
+ -1);
+
// Add all highlights for character retrieval
if (this.highlight != null) {
for (Highlight hl : this.highlight) {
@@ -875,12 +876,12 @@
}
else if (arg0[1] == arg1[1]) {
- // Compare class number
- if (arg0[2] > arg1[2])
- return 1;
- else if (arg0[2] < arg1[1])
- return -1;
- return 0;
+ // Compare class number
+ if (arg0[2] > arg1[2])
+ return 1;
+ else if (arg0[2] < arg1[1])
+ return -1;
+ return 0;
}
return 1;
@@ -901,14 +902,14 @@
}
else if (arg0[1] == arg1[1]) {
- // Check start positions
- if (arg0[0] < arg1[0]) {
- return 1;
- }
- else if (arg0[0] == arg1[0]) {
- return 0;
- };
- return -1;
+ // Check start positions
+ if (arg0[0] < arg1[0]) {
+ return 1;
+ }
+ else if (arg0[0] == arg1[0]) {
+ return 0;
+ };
+ return -1;
};
return -1;
};
@@ -1019,11 +1020,11 @@
rightContext.append("</span>");
// Iterate through all remaining elements
- sb.append("<span class=\"match\">");
+ sb.append("<span class=\"match\">");
for (short i = start; i <= end; i++) {
sb.append(this.snippetArray.get(i).toHTML(this, level, levelCache));
};
- sb.append("</span>");
+ sb.append("</span>");
sb.append(rightContext);
return (this.snippetHTML = sb.toString());
@@ -1043,39 +1044,39 @@
short start = (short) 0;
short end = this.snippetArray.size();
end--;
-
+
StringBuilder sb = new StringBuilder();
if (this.startMore)
sb.append("... ");
- // First element of sorted array
+ // First element of sorted array
HighlightCombinatorElement elem = this.snippetArray.getFirst();
- if (elem.type == 0) {
- sb.append(elem.toBrackets(this));
- start++;
- };
+ if (elem.type == 0) {
+ sb.append(elem.toBrackets(this));
+ start++;
+ };
- sb.append("[");
-
- // Last element of sorted array
+ sb.append("[");
+
+ // Last element of sorted array
elem = this.snippetArray.getLast();
StringBuilder rightContext = new StringBuilder();
- // Last element is textual
+ // Last element is textual
if (elem != null && elem.type == 0) {
rightContext.append(elem.toBrackets(this));
// decrement end
end--;
};
- for (short i = start; i <= end; i++) {
- sb.append(this.snippetArray.get(i).toBrackets(this));
- };
+ for (short i = start; i <= end; i++) {
+ sb.append(this.snippetArray.get(i).toBrackets(this));
+ };
- sb.append("]");
- sb.append(rightContext);
-
+ sb.append("]");
+ sb.append(rightContext);
+
if (this.endMore)
sb.append(" ...");
@@ -1133,19 +1134,20 @@
return stack;
};
- /**
- * Sometimes the match start and end positions are inside the
- * matching region, e.g. when the match was expanded.
- * This will override the original matching positions
- * And matrk the real matching.
- */
- public void overrideMatchPosition (int start, int end) {
- if (DEBUG)
- log.trace("--- Override match position");
- this.innerMatchStartPos = start;
- this.innerMatchEndPos = end;
- };
+ /**
+ * Sometimes the match start and end positions are inside the
+ * matching region, e.g. when the match was expanded.
+ * This will override the original matching positions
+ * And matrk the real matching.
+ */
+ public void overrideMatchPosition (int start, int end) {
+ if (DEBUG)
+ log.trace("--- Override match position");
+
+ this.innerMatchStartPos = start;
+ this.innerMatchEndPos = end;
+ };
/**
@@ -1205,8 +1207,8 @@
int startOffsetChar = startPosChar - intArray[0];
// Add match span, in case no inner match is defined
- if (this.innerMatchEndPos == -1)
- this.span.add(intArray);
+ if (this.innerMatchEndPos == -1)
+ this.span.add(intArray);
// highlights
// -- I'm not sure about this.
diff --git a/src/main/java/de/ids_mannheim/korap/response/Text.java b/src/main/java/de/ids_mannheim/korap/response/Text.java
index 437f24c..3e6647a 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Text.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Text.java
@@ -33,8 +33,10 @@
// Mapper for JSON serialization
ObjectMapper mapper = new ObjectMapper();
+
public Text () {};
+
public String toJsonString () {
JsonNode json = (JsonNode) this.toJsonNode();
diff --git a/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinatorElement.java b/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinatorElement.java
index 1190eb4..9762aef 100644
--- a/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinatorElement.java
+++ b/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinatorElement.java
@@ -53,29 +53,31 @@
if (this.type == 1) {
StringBuilder sb = new StringBuilder();
- // This is the surrounding match mark
+ // This is the surrounding match mark
if (this.number == -1) {
sb.append("<mark>");
}
else if (this.number < -1) {
sb.append("<span xml:id=\"")
- .append(escapeHTML(match.getPosID(match.getClassID(this.number))))
- .append("\">");
+ .append(escapeHTML(match.getPosID(match
+ .getClassID(this.number)))).append("\">");
}
else if (this.number >= 256) {
sb.append("<span ");
if (this.number < 2048) {
sb.append("title=\"")
- .append(escapeHTML(match.getAnnotationID(this.number)))
- .append('"');
+ .append(escapeHTML(match
+ .getAnnotationID(this.number))).append('"');
}
else {
Relation rel = match.getRelationID(this.number);
- sb.append("xlink:title=\"").append(escapeHTML(rel.annotation))
+ sb.append("xlink:title=\"")
+ .append(escapeHTML(rel.annotation))
.append("\" xlink:type=\"simple\" xlink:href=\"#")
- .append(escapeHTML(match.getPosID(rel.ref))).append('"');
+ .append(escapeHTML(match.getPosID(rel.ref)))
+ .append('"');
};
sb.append('>');
}
diff --git a/src/main/java/de/ids_mannheim/korap/response/match/MatchIdentifier.java b/src/main/java/de/ids_mannheim/korap/response/match/MatchIdentifier.java
index 10f0303..ff15e13 100644
--- a/src/main/java/de/ids_mannheim/korap/response/match/MatchIdentifier.java
+++ b/src/main/java/de/ids_mannheim/korap/response/match/MatchIdentifier.java
@@ -9,9 +9,8 @@
private ArrayList<int[]> pos = new ArrayList<>(8);
// Remember: "contains" is necessary for a compatibility bug in Kustvakt
- Pattern idRegex = Pattern.compile("^(?:match-|contains-)" +
- "(?:([^!]+?)[!\\.])?" +
- "([^!]+)[-/]p([0-9]+)-([0-9]+)"
+ Pattern idRegex = Pattern.compile("^(?:match-|contains-)"
+ + "(?:([^!]+?)[!\\.])?" + "([^!]+)[-/]p([0-9]+)-([0-9]+)"
+ "((?:\\(-?[0-9]+\\)-?[0-9]+--?[0-9]+)*)" + "(?:c.+?)?$");
Pattern posRegex = Pattern.compile("\\(([0-9]+)\\)([0-9]+)-([0-9]+)");
@@ -23,7 +22,8 @@
* Construct a new MatchIdentifier.
* Due to lots of internal changes and compatibility reasons,
* the structure of the identifier has changed a lot.
- * The constructor supports different legacy structures for test compatibility.
+ * The constructor supports different legacy structures for test
+ * compatibility.
*/
public MatchIdentifier (String id) {
diff --git a/src/main/java/de/ids_mannheim/korap/server/Resource.java b/src/main/java/de/ids_mannheim/korap/server/Resource.java
index 08f5399..e4b94ff 100644
--- a/src/main/java/de/ids_mannheim/korap/server/Resource.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Resource.java
@@ -225,6 +225,7 @@
return kresp.toJsonString();
};
+
// PUT: Return corpus info for virtual corpus
diff --git a/src/main/java/de/ids_mannheim/korap/util/KrillString.java b/src/main/java/de/ids_mannheim/korap/util/KrillString.java
index 8a11d33..602709b 100644
--- a/src/main/java/de/ids_mannheim/korap/util/KrillString.java
+++ b/src/main/java/de/ids_mannheim/korap/util/KrillString.java
@@ -68,6 +68,7 @@
return text.replaceAll("([\\{\\}\\[\\]\\\\])", "\\\\$1");
};
+
/**
* Add surrounding double quotes.
*
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
index b5dadd7..27071fa 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
@@ -405,13 +405,13 @@
assertEquals("Paragraphs", 48, kc.numberOf("paragraphs"));
// Create a query
- Krill ks = new Krill(new QueryBuilder("tokens").seg("opennlp/p:NN").with("tt/p:NN"));
+ Krill ks = new Krill(new QueryBuilder("tokens").seg("opennlp/p:NN")
+ .with("tt/p:NN"));
ks.setCollection(kc)
- .getMeta()
- .setStartIndex(0)
- .setCount((short) 20)
- .setContext(new SearchContext(true, (short) 5, true, (short) 5))
- ;
+ .getMeta()
+ .setStartIndex(0)
+ .setCount((short) 20)
+ .setContext(new SearchContext(true, (short) 5, true, (short) 5));
Result kr = ks.apply(ki);
@@ -497,13 +497,13 @@
assertEquals("Paragraphs", 48, kc.numberOf("paragraphs"));
// Create a query
- Krill ks = new Krill(new QueryBuilder("tokens").seg("opennlp/p:NN").with("tt/p:NN"));
+ Krill ks = new Krill(new QueryBuilder("tokens").seg("opennlp/p:NN")
+ .with("tt/p:NN"));
ks.setCollection(kc)
- .getMeta()
- .setStartIndex(0)
- .setCount((short) 20)
- .setContext(new SearchContext(true, (short) 5, true, (short) 5))
- ;
+ .getMeta()
+ .setStartIndex(0)
+ .setCount((short) 20)
+ .setContext(new SearchContext(true, (short) 5, true, (short) 5));
Result kr = ks.apply(ki);
/*
@@ -590,12 +590,13 @@
// Create a query
- Krill ks = new Krill(new QueryBuilder("tokens").seg("opennlp/p:NN").with("tt/p:NN"));
+ Krill ks = new Krill(new QueryBuilder("tokens").seg("opennlp/p:NN")
+ .with("tt/p:NN"));
ks.setCollection(kc)
- .getMeta()
- .setStartIndex(0)
- .setCount((short) 20)
- .setContext(new SearchContext(true, (short) 5, true, (short) 5));
+ .getMeta()
+ .setStartIndex(0)
+ .setCount((short) 20)
+ .setContext(new SearchContext(true, (short) 5, true, (short) 5));
Result kr = ks.apply(ki);
@@ -655,14 +656,13 @@
assertEquals("Sentences", 103, kc.numberOf("sentences"));
assertEquals("Tokens", 1229, kc.numberOf("tokens"));
-
+
Krill ks = new Krill(sq);
ks.setCollection(kc)
- .getMeta()
- .setStartIndex(0)
- .setCount((short) 20)
- .setContext(new SearchContext(true, (short) 5, true, (short) 5))
- ;
+ .getMeta()
+ .setStartIndex(0)
+ .setCount((short) 20)
+ .setContext(new SearchContext(true, (short) 5, true, (short) 5));
kr = ks.apply(ki);
// kr = ki.search(kc, sq, 0, (short) 20, true, (short) 5, true, (short) 5);
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 c8a7a5a..45ae9e3 100644
--- a/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
+++ b/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
@@ -249,12 +249,14 @@
assertEquals((long) 10, kr.getTotalResults());
assertEquals("[[{3:{1:a}}]] ...", kr.getMatch(0).getSnippetBrackets());
- assertEquals("... [[{3:{2:a}}]] ...", kr.getMatch(1).getSnippetBrackets());
+ assertEquals("... [[{3:{2:a}}]] ...", kr.getMatch(1)
+ .getSnippetBrackets());
assertEquals("... [[{3:{1:b}}]]", kr.getMatch(2).getSnippetBrackets());
assertEquals("[[{3:{1:a}}]] ...", kr.getMatch(3).getSnippetBrackets());
assertEquals("... [[{3:{2:a}}]]", kr.getMatch(4).getSnippetBrackets());
assertEquals("[[{3:{1:a}}]] ...", kr.getMatch(5).getSnippetBrackets());
- assertEquals("... [[{3:{2:a}}]] ...", kr.getMatch(6).getSnippetBrackets());
+ assertEquals("... [[{3:{2:a}}]] ...", kr.getMatch(6)
+ .getSnippetBrackets());
assertEquals("... [[{3:{1:b}}]]", kr.getMatch(7).getSnippetBrackets());
assertEquals("[[{3:{1:a}}]] ...", kr.getMatch(8).getSnippetBrackets());
assertEquals("... [[{3:{2:a}}]]", kr.getMatch(9).getSnippetBrackets());
@@ -352,6 +354,7 @@
"Valid class numbers exceeded");
};
+
@Test
public void highlightEscapes () throws IOException, QueryException {
KrillIndex ki = new KrillIndex();
@@ -362,11 +365,13 @@
// Make this clean for HTML and Brackets!
- fd.addTV("base", "Mit \"Mann\" & {Ma\\us}",
- "[(0-3)s:Mit|i:mit|_0#0-3|-:t$<i>4|<>:base/t:t$<b>64<i>0<i>20<i>4<b>0]" +
- "[(4-10)s:\"Mann\"|i:\"mann\"|base/l:\"Mann\"|_1#4-10]" +
- "[(11-12)s:&|i:&|base/l:&|_2#11-12]" +
- "[(13-20)s:{Ma\\us}|i:{ma\\us}|_3#13-20]");
+ fd.addTV(
+ "base",
+ "Mit \"Mann\" & {Ma\\us}",
+ "[(0-3)s:Mit|i:mit|_0#0-3|-:t$<i>4|<>:base/t:t$<b>64<i>0<i>20<i>4<b>0]"
+ + "[(4-10)s:\"Mann\"|i:\"mann\"|base/l:\"Mann\"|_1#4-10]"
+ + "[(11-12)s:&|i:&|base/l:&|_2#11-12]"
+ + "[(13-20)s:{Ma\\us}|i:{ma\\us}|_3#13-20]");
ki.addDoc(fd);
// Commit!
@@ -380,25 +385,22 @@
Result kr = ki.search(qs);
assertEquals((long) 1, kr.getTotalResults());
- assertEquals("[[Mit \"Mann\" & \\{Ma\\\\us\\}]]", kr.getMatch(0).getSnippetBrackets());
- assertEquals("<span class=\"context-left\"></span><span class=\"match\"><mark>Mit "Mann" & {Ma\\us}</mark></span><span class=\"context-right\"></span>", kr.getMatch(0).getSnippetHTML());
+ assertEquals("[[Mit \"Mann\" & \\{Ma\\\\us\\}]]", kr.getMatch(0)
+ .getSnippetBrackets());
+ assertEquals(
+ "<span class=\"context-left\"></span><span class=\"match\"><mark>Mit "Mann" & {Ma\\us}</mark></span><span class=\"context-right\"></span>",
+ kr.getMatch(0).getSnippetHTML());
assertEquals("match-c1/d1/1-p0-4", kr.getMatch(0).getID());
- Match km = ki.getMatchInfo("match-c1/d1/1-p0-4", "base", true, (ArrayList) null, (ArrayList) null, true, true, false);
+ Match km = ki.getMatchInfo("match-c1/d1/1-p0-4", "base", true,
+ (ArrayList) null, (ArrayList) null, true, true, false);
assertEquals(0, km.getStartPos());
- assertEquals("<span class=\"context-left\"></span>"+
- "<span class=\"match\"><mark><span title=\"base/t:t\">"+
- "Mit "+
- "<span title=\"base/l:"Mann"\">"+
- ""Mann""+
- "</span>"+
- " "+
- "<span title=\"base/l:&\">&</span>"+
- " "+
- "{Ma\\us}"+
- "</span>"+
- "</mark></span>"+
- "<span class=\"context-right\"></span>",
- km.getSnippetHTML());
+ assertEquals("<span class=\"context-left\"></span>"
+ + "<span class=\"match\"><mark><span title=\"base/t:t\">"
+ + "Mit " + "<span title=\"base/l:"Mann"\">"
+ + ""Mann"" + "</span>" + " "
+ + "<span title=\"base/l:&\">&</span>" + " "
+ + "{Ma\\us}" + "</span>" + "</mark></span>"
+ + "<span class=\"context-right\"></span>", km.getSnippetHTML());
};
};
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestClassFilterIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestClassFilterIndex.java
index e15c3d1..8536540 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestClassFilterIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestClassFilterIndex.java
@@ -57,8 +57,8 @@
assertEquals(18, kr.getMatch(1).getEndPos());
assertEquals(
"Frankenstein, treat my daughter well. She [[{2:is {1:the one} that saved "
- + "your master who you hold so dear}]].", kr.getMatch(1)
- .getSnippetBrackets());
+ + "your master who you hold so dear}]].", kr
+ .getMatch(1).getSnippetBrackets());
assertEquals(
"Frankenstein, treat my daughter well. She [[{2:is {1:the one that "
+ "saved your master who you hold so dear}}]].", kr
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 2268d5b..d9f1acf 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
@@ -97,13 +97,13 @@
assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
- assertEquals("snippetBrackets (1)", "abca[[{1:b}]]cabac", kr.getMatch(1)
- .getSnippetBrackets());
+ assertEquals("snippetBrackets (1)", "abca[[{1:b}]]cabac", kr
+ .getMatch(1).getSnippetBrackets());
assertEquals("StartPos (2)", 7, kr.getMatch(2).startPos);
assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
- assertEquals("snippetBrackets (2)", "... bcabca[[{1:b}]]ac",
- kr.getMatch(2).getSnippetBrackets());
+ assertEquals("snippetBrackets (2)", "... bcabca[[{1:b}]]ac", kr
+ .getMatch(2).getSnippetBrackets());
sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:a")),
@@ -125,12 +125,12 @@
assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
- assertEquals("SnippetBrackets (1)", "abc[[a{1:b}]]cabac", kr.getMatch(1)
- .getSnippetBrackets());
+ assertEquals("SnippetBrackets (1)", "abc[[a{1:b}]]cabac", kr
+ .getMatch(1).getSnippetBrackets());
assertEquals("StartPos (2)", 6, kr.getMatch(2).startPos);
assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
- assertEquals("SnippetBrackets (2)", "abcabc[[a{1:b}]]ac", kr.getMatch(2)
- .getSnippetBrackets());
+ assertEquals("SnippetBrackets (2)", "abcabc[[a{1:b}]]ac", kr
+ .getMatch(2).getSnippetBrackets());
// abcabcabac
@@ -245,17 +245,17 @@
SpanQuery sq;
Result kr;
-/*
- sq = new SpanNextQuery(
- new SpanTermQuery(new Term("base", "s:c")),
- new SpanElementQuery("base", "x")
- );
-
- kr = ki.search(sq, (short) 10);
- assertEquals("ab[cabca]bac", kr.getMatch(0).getSnippetBrackets());
-*/
/*
- System.err.println();
+ sq = new SpanNextQuery(
+ new SpanTermQuery(new Term("base", "s:c")),
+ new SpanElementQuery("base", "x")
+ );
+
+ kr = ki.search(sq, (short) 10);
+ assertEquals("ab[cabca]bac", kr.getMatch(0).getSnippetBrackets());
+ */
+ /*
+ System.err.println();
sq = new SpanNextQuery(
new SpanElementQuery("base", "x"),
new SpanTermQuery(new Term("base", "s:b"))
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
index 21f8ba7..026a86a 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
@@ -245,6 +245,7 @@
assertEquals("[[ec]]ebdc", kr.getMatch(0).getSnippetBrackets());
};
+
public static String getString (String path) {
StringBuilder contentBuilder = new StringBuilder();
try {
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 0112f40..0962e64 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
@@ -206,7 +206,9 @@
false, (short) 5);
assertEquals(1, kr.getTotalResults());
- assertEquals("... bezeichnen, sofern [[{1:der} schwedische Buchstabe „Å“ nicht]] verfügbar ist im SI-Einheitensystem ist ...", kr.getMatch(0).getSnippetBrackets());
+ assertEquals(
+ "... bezeichnen, sofern [[{1:der} schwedische Buchstabe „Å“ nicht]] verfügbar ist im SI-Einheitensystem ist ...",
+ kr.getMatch(0).getSnippetBrackets());
};
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestKrillIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestKrillIndex.java
index 6db3030..c20434b 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestKrillIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestKrillIndex.java
@@ -123,6 +123,7 @@
// hasDeletions, hasPendingMerges
};
+
/*
* This test demonstrates the behaviour
*/
@@ -135,12 +136,10 @@
// These values are canonically equivalent
// But indexed as byte sequences
- fd.addTV("base",
- new String("ju" + "\u006E" + "\u0303" + "o") +
- " " +
- new String("ju" + "\u00F1" + "o"),
- "[(0-5)s:ju" + "\u006E" + "\u0303" + "o|_0$<i>0<i>5|-:t$<i>2]"
- + "[(6-10)s:ju" + "\u00F1" + "o|_1$<i>6<i>10]");
+ fd.addTV("base", new String("ju" + "\u006E" + "\u0303" + "o") + " "
+ + new String("ju" + "\u00F1" + "o"), "[(0-5)s:ju" + "\u006E"
+ + "\u0303" + "o|_0$<i>0<i>5|-:t$<i>2]" + "[(6-10)s:ju"
+ + "\u00F1" + "o|_1$<i>6<i>10]");
ki.addDoc(fd);
ki.commit();
@@ -154,6 +153,7 @@
assertEquals(1, kr.getTotalResults());
};
+
@Test
public void indexFieldInfo () throws IOException {
KrillIndex ki = new KrillIndex();
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 ba13544..7859614 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
@@ -185,15 +185,15 @@
km.getSnippetBrackets());
assertEquals("SnippetHTML (4)", "<span class=\"context-left\">"
- + "<span class=\"more\">" + "</span>" + "</span>" +
- "<span class=\"match\">" + "<mark>"
+ + "<span class=\"more\">" + "</span>" + "</span>"
+ + "<span class=\"match\">" + "<mark>"
+ "<mark class=\"class-2 level-0\">"
+ "<span title=\"f/m:acht\">" + "<span title=\"f/y:eight\">"
+ "b" + "</span>" + "</span>"
+ "<mark class=\"class-4 level-1\">"
+ "<span title=\"f/m:neun\">" + "<span title=\"f/y:nine\">"
+ "a" + "</span>" + "</span>" + "</mark>" + "</mark>"
- + "</mark>" + "</span>" + "<span class=\"context-right\">"
+ + "</mark>" + "</span>" + "<span class=\"context-right\">"
+ "<span class=\"more\">" + "</span>" + "</span>",
km.getSnippetHTML());
@@ -220,7 +220,8 @@
assertEquals("SnippetHTML (1)", "<span class=\"context-left\">"
- + "<span class=\"more\">" + "</span>" + "</span>" + "<span class=\"match\">" + "<mark>"
+ + "<span class=\"more\">" + "</span>" + "</span>"
+ + "<span class=\"match\">" + "<mark>"
+ "<mark class=\"class-2 level-0\">"
+ "<span title=\"f/m:acht\">" + "<span title=\"f/y:eight\">"
+ "<span title=\"it/is:8\">" + "<span title=\"x/o:achtens\">"
@@ -229,7 +230,7 @@
+ "<span title=\"f/m:neun\">" + "<span title=\"f/y:nine\">"
+ "<span title=\"it/is:9\">" + "<span title=\"x/o:neuntens\">"
+ "a" + "</span>" + "</span>" + "</span>" + "</span>"
- + "</mark>" + "</mark>" + "</mark>" + "</span>"
+ + "</mark>" + "</mark>" + "</mark>" + "</span>"
+ "<span class=\"context-right\">" + "<span class=\"more\">"
+ "</span>" + "</span>", km.getSnippetHTML());
};
@@ -246,7 +247,8 @@
assertEquals("SnippetHTML (1)", "<span class=\"context-left\">"
- + "<span class=\"more\">" + "</span>" + "</span>" + "<span class=\"match\">" + "<mark>"
+ + "<span class=\"more\">" + "</span>" + "</span>"
+ + "<span class=\"match\">" + "<mark>"
+ "<span title=\"f/m:acht\">" + "<span title=\"f/y:eight\">"
+ "<span title=\"it/is:8\">" + "<span title=\"x/o:achtens\">"
+ "b" + "</span>" + "</span>" + "</span>" + "</span>"
@@ -325,8 +327,8 @@
km.getSnippetBrackets());
assertEquals("SnippetHTML (1)", "<span class=\"context-left\">"
- + "<span class=\"more\">" + "</span>" + "</span>" +
- "<span class=\"match\">" +"<mark>"
+ + "<span class=\"more\">" + "</span>" + "</span>"
+ + "<span class=\"match\">" + "<mark>"
+ "<span title=\"x/tag\">" + "<mark class=\"class-2 level-0\">"
+ "<span title=\"f/m:acht\">" + "<span title=\"f/y:eight\">"
+ "<span title=\"it/is:8\">" + "<span title=\"x/o:achtens\">"
@@ -338,8 +340,7 @@
+ "</mark>" + "</mark>" + "<span title=\"f/m:zehn\">"
+ "<span title=\"f/y:ten\">" + "<span title=\"it/is:10\">"
+ "<span title=\"x/o:zehntens\">" + "c" + "</span>" + "</span>"
- + "</span>" + "</span>" + "</span>" + "</mark>"
- + "</span>"
+ + "</span>" + "</span>" + "</span>" + "</mark>" + "</span>"
+ "<span class=\"context-right\">" + "</span>",
km.getSnippetHTML());
};
@@ -359,34 +360,27 @@
"[[{x/rel:a>3:{x/o:erstens:a}}{x/o:zweitens:b}{x/o:drittens:c}{#3:{x/o:viertens:a}}{x/o:fünftens:b}]] ...",
km.getSnippetBrackets());
- assertEquals("SnippetBrackets (1)",
- "<span class=\"context-left\">"
- + "</span>"
- + "<span class=\"match\">"
- + "<mark>"
- + "<span xlink:title=\"x/rel:a\" "
- + "xlink:type=\"simple\" " + "xlink:href=\"#word-c1!d1-p3\">"
- + "<span title=\"x/o:erstens\">" + "a" + "</span>" + "</span>"
- + "<span title=\"x/o:zweitens\">" + "b" + "</span>"
- + "<span title=\"x/o:drittens\">" + "c" + "</span>"
- + "<span xml:id=\"word-c1!d1-p3\">"
- + "<span title=\"x/o:viertens\">" + "a" + "</span>"
- + "</span>"
- + "<span title=\"x/o:fünftens\">" + "b" + "</span>"
- + "</mark>"
- + "</span>"
- + "<span class=\"context-right\">" + "<span class=\"more\">"
- + "</span>" +
- "</span>", km.getSnippetHTML());
+ assertEquals("SnippetBrackets (1)", "<span class=\"context-left\">"
+ + "</span>" + "<span class=\"match\">" + "<mark>"
+ + "<span xlink:title=\"x/rel:a\" " + "xlink:type=\"simple\" "
+ + "xlink:href=\"#word-c1!d1-p3\">"
+ + "<span title=\"x/o:erstens\">" + "a" + "</span>" + "</span>"
+ + "<span title=\"x/o:zweitens\">" + "b" + "</span>"
+ + "<span title=\"x/o:drittens\">" + "c" + "</span>"
+ + "<span xml:id=\"word-c1!d1-p3\">"
+ + "<span title=\"x/o:viertens\">" + "a" + "</span>" + "</span>"
+ + "<span title=\"x/o:fünftens\">" + "b" + "</span>" + "</mark>"
+ + "</span>" + "<span class=\"context-right\">"
+ + "<span class=\"more\">" + "</span>" + "</span>",
+ km.getSnippetHTML());
km = ki.getMatchInfo("match-c1!d1-p0-5(7)2-3(4)8-8(2)7-8", "tokens",
"x", null, true, true);
assertEquals("SnippetBrackets (1)", "<span class=\"context-left\">"
- + "</span>" +
- "<span class=\"match\">" +
- "<mark>" + "<span xlink:title=\"x/rel:a\" "
- + "xlink:type=\"simple\" " + "xlink:href=\"#word-c1!d1-p3\">"
+ + "</span>" + "<span class=\"match\">" + "<mark>"
+ + "<span xlink:title=\"x/rel:a\" " + "xlink:type=\"simple\" "
+ + "xlink:href=\"#word-c1!d1-p3\">"
+ "<span title=\"x/o:erstens\">" + "a" + "</span>" + "</span>"
+ "<span title=\"x/o:zweitens\">" + "b" + "</span>"
+ "<mark class=\"class-7 level-0\">"
@@ -394,9 +388,7 @@
+ "<span xml:id=\"word-c1!d1-p3\">"
+ "<span title=\"x/o:viertens\">" + "a" + "</span>" + "</span>"
+ "</mark>" + "<span title=\"x/o:fünftens\">" + "b" + "</span>"
- + "</mark>" +
-"</span>" +
- "<span class=\"context-right\">"
+ + "</mark>" + "</span>" + "<span class=\"context-right\">"
+ "<span class=\"more\">" + "</span>" + "</span>",
km.getSnippetHTML());
};
@@ -430,36 +422,20 @@
"[{f/m:drei:{f/y:three:{it/is:3:{x/o:drittens:c}}}}[{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}]{f/m:fuenf:{f/y:five:{it/is:5:{x/o:fünftens:b}}}}]",
km.getSnippetBrackets());
- assertEquals(
- "<span class=\"context-left\"></span>"+
- "<span class=\"match\">" +
- "<span title=\"f/m:drei\">"+
- "<span title=\"f/y:three\">"+
- "<span title=\"it/is:3\">"+
- "<span title=\"x/o:drittens\">c</span>"+
- "</span>"+
- "</span>"+
- "</span>"+
- "<mark>"+
- "<span title=\"f/m:vier\">"+
- "<span title=\"f/y:four\">"+
- "<span title=\"it/is:4\">"+
- "<span title=\"x/o:viertens\">a</span>"+
- "</span>"+
- "</span>"+
- "</span>"+
- "</mark>"+
- "<span title=\"f/m:fuenf\">"+
- "<span title=\"f/y:five\">"+
- "<span title=\"it/is:5\">"+
- "<span title=\"x/o:fünftens\">b</span>"+
- "</span>"+
- "</span>"+
- "</span>"+
- "</span>" +
- "<span class=\"context-right\"></span>",
- km.getSnippetHTML());
-
+ assertEquals("<span class=\"context-left\"></span>"
+ + "<span class=\"match\">" + "<span title=\"f/m:drei\">"
+ + "<span title=\"f/y:three\">" + "<span title=\"it/is:3\">"
+ + "<span title=\"x/o:drittens\">c</span>" + "</span>"
+ + "</span>" + "</span>" + "<mark>"
+ + "<span title=\"f/m:vier\">" + "<span title=\"f/y:four\">"
+ + "<span title=\"it/is:4\">"
+ + "<span title=\"x/o:viertens\">a</span>" + "</span>"
+ + "</span>" + "</span>" + "</mark>"
+ + "<span title=\"f/m:fuenf\">" + "<span title=\"f/y:five\">"
+ + "<span title=\"it/is:5\">"
+ + "<span title=\"x/o:fünftens\">b</span>" + "</span>"
+ + "</span>" + "</span>" + "</span>"
+ + "<span class=\"context-right\"></span>", km.getSnippetHTML());
@@ -494,7 +470,7 @@
"SnippetHTML (2)",
"<span class=\"context-left\">"
+ "</span>"
- + "<span class=\"match\">"
+ + "<span class=\"match\">"
+ "<mark>"
+ "<span xlink:title=\"x/rel:a\" xlink:type=\"simple\" xlink:href=\"#word-c1!d1-p3\">"
+ "<span title=\"f/m:eins\">"
@@ -521,9 +497,8 @@
+ "<span title=\"f/y:four\">"
+ "<span title=\"it/is:4\">"
+ "<span title=\"x/o:viertens\">a</span>" + "</span>"
- + "</span>" + "</span>" + "</span>" + "</mark>"
- + "</span>"
- + "<span class=\"context-right\">"
+ + "</span>" + "</span>" + "</span>" + "</mark>"
+ + "</span>" + "<span class=\"context-right\">"
+ "<span class=\"more\">" + "</span>" + "</span>",
km.getSnippetHTML());
};
@@ -670,8 +645,7 @@
+ "</span>" + "</span>" + "<span title=\"f/m:zehn\">"
+ "<span title=\"f/y:ten\">" + "<span title=\"it/is:10\">"
+ "<span title=\"x/o:zehntens\">c</span>" + "</span>"
- + "</span>" + "</span>" + "</mark>"
- + "</span>"
+ + "</span>" + "</span>" + "</mark>" + "</span>"
+ "<span class=\"context-right\">" + "</span>",
res.at("/snippet").asText());
};
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 a8b5491..fe3212d 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
@@ -86,8 +86,7 @@
+ "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]"
+ "[(3-4)s:a|i:a|_3$<i>3<i>4]" + "[(4-5)s:b|i:b|_4$<i>4<i>5]"
+ "[(5-6)s:c|i:c|_5$<i>5<i>6]" + "[(6-7)s:a|i:a|_6$<i>6<i>7]"
- + "[(7-8)s:b|i:b|_7$<i>7<i>8]" +
- "[(8-9)s:a|i:a|_8$<i>8<i>9]"
+ + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:a|i:a|_8$<i>8<i>9]"
+ "[(9-10)s:c|i:c|_9$<i>9<i>10]");
ki.addDoc(fd);
@@ -104,16 +103,16 @@
assertEquals("StartPos (0)", 7, kr.getMatch(0).startPos);
assertEquals("EndPos (0)", 9, kr.getMatch(0).endPos);
- assertEquals("SnippetBrackets (0)", "... bcabca[[b{1:a}]]c",
- kr.getMatch(0).getSnippetBrackets());
+ assertEquals("SnippetBrackets (0)", "... bcabca[[b{1:a}]]c", kr
+ .getMatch(0).getSnippetBrackets());
- assertEquals(
+ assertEquals(
"Test no 'more' context",
"<span class=\"context-left\"><span class=\"more\"></span>bcabca</span><span class=\"match\"><mark>b<mark class=\"class-1 level-0\">a</mark></mark></span><span class=\"context-right\">c</span>",
kr.getMatch(0).getSnippetHTML());
- sq = new SpanFocusQuery(new SpanNextQuery(new SpanTermQuery(new Term(
+ sq = new SpanFocusQuery(new SpanNextQuery(new SpanTermQuery(new Term(
"base", "s:b")), new SpanClassQuery(new SpanTermQuery(new Term(
"base", "s:a")))));
kr = ki.search(sq, (short) 10);
@@ -143,8 +142,8 @@
assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
- assertEquals("SnippetBrackets (1)", "abca[[{3:b}]]cabac", kr.getMatch(1)
- .getSnippetBrackets());
+ assertEquals("SnippetBrackets (1)", "abca[[{3:b}]]cabac", kr
+ .getMatch(1).getSnippetBrackets());
assertEquals(
"<span class=\"context-left\">abca</span><span class=\"match\"><mark><mark class=\"class-3 level-0\">b</mark></mark></span><span class=\"context-right\">cabac</span>",
@@ -152,8 +151,8 @@
assertEquals("StartPos (2)", 7, kr.getMatch(2).startPos);
assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
- assertEquals("SnippetBrackets (2)", "... bcabca[[{3:b}]]ac",
- kr.getMatch(2).getSnippetBrackets());
+ assertEquals("SnippetBrackets (2)", "... bcabca[[{3:b}]]ac", kr
+ .getMatch(2).getSnippetBrackets());
@@ -179,8 +178,8 @@
// Offset tokens
kr = ki.search(sq, 0, (short) 10, true, (short) 2, true, (short) 2);
assertEquals("totalResults", kr.getTotalResults(), 1);
- assertEquals("SnippetBrackets (0)", "... ca[[{2:b{1:a}}]]c",
- kr.getMatch(0).getSnippetBrackets());
+ assertEquals("SnippetBrackets (0)", "... ca[[{2:b{1:a}}]]c", kr
+ .getMatch(0).getSnippetBrackets());
@@ -217,12 +216,12 @@
assertEquals("totalResults", kr.getTotalResults(), 2);
assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
- assertEquals("SnippetBrackets (0)", "a[[{1:bc}]]abcaba ...",
- kr.getMatch(0).getSnippetBrackets());
+ assertEquals("SnippetBrackets (0)", "a[[{1:bc}]]abcaba ...", kr
+ .getMatch(0).getSnippetBrackets());
assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
- assertEquals("SnippetBrackets (1)", "abca[[{1:bc}]]abac", kr.getMatch(1)
- .getSnippetBrackets());
+ assertEquals("SnippetBrackets (1)", "abca[[{1:bc}]]abac", kr
+ .getMatch(1).getSnippetBrackets());
assertEquals(1, ki.numberOf("base", "documents"));
assertEquals(10, ki.numberOf("base", "t"));
@@ -327,8 +326,8 @@
kr = ki.search(sq, 0, (short) 20, true, (short) 2, true, (short) 5);
assertEquals("totalResults", kr.getTotalResults(), 1);
- assertEquals("SnippetBrackets (0)", "... ca[[{1:ba{2:c}}]]",
- kr.getMatch(0).getSnippetBrackets());
+ assertEquals("SnippetBrackets (0)", "... ca[[{1:ba{2:c}}]]", kr
+ .getMatch(0).getSnippetBrackets());
};
@@ -421,7 +420,8 @@
assertEquals(kr.getSerialQuery(),
"focus(3: spanContain({2: <base:s />}, {3: base:s:b}))");
- assertEquals(kr.getMatch(0).getSnippetBrackets(), "a[[{3:b}]]cabcab ...");
+ assertEquals(kr.getMatch(0).getSnippetBrackets(),
+ "a[[{3:b}]]cabcab ...");
};
@@ -498,17 +498,17 @@
Krill ks = new Krill(sq);
ks.getMeta()
- .setStartIndex(0)
- .setCount((short) 20)
- .setContext(new SearchContext(true, (short) 5, true, (short) 5))
- // .setCollection(kc)
- ;
+ .setStartIndex(0)
+ .setCount((short) 20)
+ .setContext(new SearchContext(true, (short) 5, true, (short) 5))
+ // .setCollection(kc)
+ ;
kr = ks.apply(ki);
// kr = ki.search(kc, sq, 0, (short) 20, true, (short) 5, true, (short) 5);
assertEquals(
- kr.getSerialQuery(),
+ kr.getSerialQuery(),
"spanContain(<base:p />, focus(3: spanContain({2: <base:s />}, {3: base:s:a})))");
assertEquals(12, kr.getTotalResults());
assertEquals("[a{2:bc{3:a}b}cabac]", kr.getMatch(0)
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
index 1cc71a5..9bda6d1 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
@@ -41,10 +41,11 @@
QueryBuilder kq = new QueryBuilder("base");
SpanQueryWrapper sqw = kq.re("s:af*e");
- assertEquals("SpanMultiTermQueryWrapper(base:/s:af*e/)", sqw.toQuery().toString());
+ assertEquals("SpanMultiTermQueryWrapper(base:/s:af*e/)", sqw.toQuery()
+ .toString());
Krill ks = _newKrill(sqw);
-
+
Result kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("[[affe]] afffe ...", kr.getMatch(0).getSnippetBrackets());
@@ -56,17 +57,17 @@
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... afffe [[baum]] baumgarten ...", kr.getMatch(0)
- .getSnippetBrackets());
+ .getSnippetBrackets());
assertEquals("... baum [[baumgarten]] steingarten ...", kr.getMatch(1)
- .getSnippetBrackets());
+ .getSnippetBrackets());
ks = _newKrill(new QueryBuilder("base").re("s:.....?garten"));
kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... baum [[baumgarten]] steingarten ...", kr.getMatch(0)
- .getSnippetBrackets());
+ .getSnippetBrackets());
assertEquals("... baumgarten [[steingarten]] franz ...", kr.getMatch(1)
- .getSnippetBrackets());
+ .getSnippetBrackets());
ks = _newKrill(new QueryBuilder("base").re("s:ha.s"));
kr = ki.search(ks);
@@ -85,6 +86,7 @@
assertEquals("... efeu [[effe]]", kr.getMatch(2).getSnippetBrackets());
};
+
@Test
public void indexWildcard () throws Exception {
KrillIndex ki = new KrillIndex();
@@ -110,7 +112,8 @@
QueryBuilder kq = new QueryBuilder("base");
SpanQueryWrapper sq = kq.wc("s:af*e");
- assertEquals("SpanMultiTermQueryWrapper(base:s:af*e)", sq.toQuery().toString());
+ assertEquals("SpanMultiTermQueryWrapper(base:s:af*e)", sq.toQuery()
+ .toString());
Krill ks = _newKrill(sq);
@@ -182,7 +185,8 @@
QueryBuilder kq = new QueryBuilder("base");
SpanQueryWrapper sqw = kq.re("s:Af*e", true);
- assertEquals("SpanMultiTermQueryWrapper(base:/i:af*e/)", sqw.toQuery().toString());
+ assertEquals("SpanMultiTermQueryWrapper(base:/i:af*e/)", sqw.toQuery()
+ .toString());
Krill ks = _newKrill(sqw);
Result kr = ki.search(ks);
@@ -196,8 +200,7 @@
assertEquals((long) 1, kr.getTotalResults());
assertEquals("[[AfFe]] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
- ks = _newKrill(new QueryBuilder("base").re("s:baum.*",
- true));
+ ks = _newKrill(new QueryBuilder("base").re("s:baum.*", true));
kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... aFfFE [[Baum]] Baumgarten ...", kr.getMatch(0)
@@ -205,8 +208,7 @@
assertEquals("... Baum [[Baumgarten]] SteinGarten ...", kr.getMatch(1)
.getSnippetBrackets());
- ks = _newKrill(new QueryBuilder("base").re(
- "s:.*garten", true));
+ ks = _newKrill(new QueryBuilder("base").re("s:.*garten", true));
kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... Baum [[Baumgarten]] SteinGarten ...", kr.getMatch(0)
@@ -220,8 +222,7 @@
assertEquals("... Baum [[Baumgarten]] SteinGarten ...", kr.getMatch(0)
.getSnippetBrackets());
- ks = _newKrill(new QueryBuilder("base").re("s:ha.s",
- true));
+ ks = _newKrill(new QueryBuilder("base").re("s:ha.s", true));
kr = ki.search(ks);
assertEquals((long) 2, kr.getTotalResults());
assertEquals("... franZ [[HaNs]] Haus ...", kr.getMatch(0)
@@ -229,8 +230,7 @@
assertEquals("... HaNs [[Haus]] Efeu ...", kr.getMatch(1)
.getSnippetBrackets());
- ks = _newKrill(new QueryBuilder("base").re("s:.*f*e",
- true));
+ ks = _newKrill(new QueryBuilder("base").re("s:.*f*e", true));
kr = ki.search(ks);
assertEquals((long) 3, kr.getTotalResults());
assertEquals("[[AfFe]] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
@@ -280,6 +280,7 @@
.getSnippetBrackets());
};
+
@Test
public void indexRegexWithinRewrite () throws Exception {
KrillIndex ki = new KrillIndex();
@@ -320,6 +321,7 @@
.getSnippetBrackets());
};
+
private Krill _newKrill (SpanQueryWrapper query) {
Krill ks = new Krill(query);
ks.getMeta().getContext().left.setToken(true).setLength(1);
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 cff70ca..f77f42a 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
@@ -435,12 +435,12 @@
assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
- assertEquals("Snippet (0)", "[[h h i j ]]h i j h i j ...", kr
- .getMatch(0).getSnippetBrackets());
+ assertEquals("Snippet (0)", "[[h h i j ]]h i j h i j ...",
+ kr.getMatch(0).getSnippetBrackets());
assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 4, kr.getMatch(1).endPos);
- assertEquals("Snippet (1)", "[[h h i j ]]h i j h i j ...", kr
- .getMatch(1).getSnippetBrackets());
+ assertEquals("Snippet (1)", "[[h h i j ]]h i j h i j ...",
+ kr.getMatch(1).getSnippetBrackets());
assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
@@ -832,8 +832,8 @@
kr = ki.search(sq, 0, (short) 15, true, (short) 1, true, (short) 1);
assertEquals("totalResults", kr.getTotalResults(), 1);
- assertEquals("... schrie: [[\"{3:Das war ich}!\"]] und ...",
- kr.getMatch(0).getSnippetBrackets());
+ assertEquals("... schrie: [[\"{3:Das war ich}!\"]] und ...", kr
+ .getMatch(0).getSnippetBrackets());
assertEquals(
"<span class=\"context-left\"><span class=\"more\"></span>schrie: </span><span class=\"match\"><mark>"<mark class=\"class-3 level-0\">Das war ich</mark>!"</mark></span><span class=\"context-right\"> und<span class=\"more\"></span></span>",
kr.getMatch(0).getSnippetHTML());
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKrill.java b/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
index 4c465b3..774d48e 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
@@ -137,8 +137,8 @@
assertEquals(kr.getTotalResults(), 66);
assertEquals(5, kr.getItemsPerPage());
assertEquals(5, kr.getStartIndex());
- assertEquals("... a: A ist [[der klangreichste]] der V ...",
- kr.getMatch(0).getSnippetBrackets());
+ assertEquals("... a: A ist [[der klangreichste]] der V ...", kr
+ .getMatch(0).getSnippetBrackets());
};
diff --git a/src/test/java/de/ids_mannheim/korap/server/TestResource.java b/src/test/java/de/ids_mannheim/korap/server/TestResource.java
index 11f27d7..633a277 100644
--- a/src/test/java/de/ids_mannheim/korap/server/TestResource.java
+++ b/src/test/java/de/ids_mannheim/korap/server/TestResource.java
@@ -76,8 +76,8 @@
Node.closeDBPool();
t4 = System.nanoTime();
- double startup = (double) (t2 - t1) / 1000000000.0;
- double action = (double) (t3 - t2) / 1000000000.0;
+ double startup = (double) (t2 - t1) / 1000000000.0;
+ double action = (double) (t3 - t2) / 1000000000.0;
double shutdown = (double) (t4 - t3) / 1000000000.0;
};
@@ -111,7 +111,7 @@
for (String i : new String[] { "00001", "00002", "00003", "00004",
"00005", "00006" }) {
-
+
String json = StringfromFile(getClass().getResource(
"/wiki/" + i + ".json").getFile());
@@ -167,7 +167,8 @@
resp = target.path("/index/00005").request().get(String.class);
res = mapper.readTree(resp);
- assertEquals("freizeit-unterhaltung reisen schrott tabellen", res.at("/textClass").asText());
+ assertEquals("freizeit-unterhaltung reisen schrott tabellen",
+ res.at("/textClass").asText());
assertEquals("Å (Orte in Norwegen)", res.at("/title").asText());
assertEquals("WPD", res.at("/corpusID").asText());
assertEquals(5, res.at("/UID").asInt());
@@ -178,7 +179,8 @@
resp = target.path("/index/5").request().get(String.class);
res = mapper.readTree(resp);
- assertEquals("freizeit-unterhaltung reisen schrott tabellen", res.at("/textClass").asText());
+ assertEquals("freizeit-unterhaltung reisen schrott tabellen",
+ res.at("/textClass").asText());
assertEquals("Å (Orte in Norwegen)", res.at("/title").asText());
assertEquals("WPD", res.at("/corpusID").asText());
assertEquals(5, res.at("/UID").asInt());
diff --git a/src/test/java/de/ids_mannheim/korap/util/TestKrillString.java b/src/test/java/de/ids_mannheim/korap/util/TestKrillString.java
index 43d226c..7db0642 100644
--- a/src/test/java/de/ids_mannheim/korap/util/TestKrillString.java
+++ b/src/test/java/de/ids_mannheim/korap/util/TestKrillString.java
@@ -20,11 +20,13 @@
escapeHTML("Er sagte: \"Das ist ja toll!\""));
};
+
@Test
public void testQuote () {
assertEquals("\"hallo\"", quote("hallo"));
assertEquals("\"h'all'o\"", quote("h'all'o"));
- assertEquals("\"er sagte: \\\"Hallo!\\\"\"", quote("er sagte: \"Hallo!\""));
+ assertEquals("\"er sagte: \\\"Hallo!\\\"\"",
+ quote("er sagte: \"Hallo!\""));
assertEquals("\"a \\\\\\\" b\"", quote("a \\\" b"));
};
};