Renamed KorapMatch to Match
diff --git a/Changes b/Changes
index 781c546..38f5e09 100644
--- a/Changes
+++ b/Changes
@@ -3,7 +3,9 @@
- [cleanup] Extract KrillMeta from Krill,
rename KorapQuery to KrillQuery,
extract QueryBuilder from KrillQuery,
- renamed KorapIndexer to index/Indexer (diewald)
+ renamed KorapIndexer to index/Indexer,
+ renamed KorapDocument to model/AbstractDocument,
+ renamed KorapMatch to response/Match (diewald)
- [documentation] Improved documentation for API classes (diewald)
0.50 2015-02-23
diff --git a/pom.xml b/pom.xml
index 5d4440a..e0febda 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,6 +15,7 @@
(This is not the preferred way to index new data!)
# install the indexer
$ mvn clean compile assembly:single
+
# Then run e.g.
$ java -jar target/Krill-X.XX.jar
src/main/resources/korap.conf
diff --git a/src/main/java/de/ids_mannheim/korap/KorapIndex.java b/src/main/java/de/ids_mannheim/korap/KorapIndex.java
index 5efe1e6..528868f 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapIndex.java
@@ -30,6 +30,7 @@
import de.ids_mannheim.korap.*;
import de.ids_mannheim.korap.index.*;
import de.ids_mannheim.korap.meta.*;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.query.SpanElementQuery;
import de.ids_mannheim.korap.util.QueryException;
@@ -612,7 +613,7 @@
};
- public KorapMatch getMatch (String id) throws QueryException {
+ public Match getMatch (String id) throws QueryException {
return this.getMatchInfo(
id, // MatchID
"tokens", // field
@@ -627,7 +628,7 @@
// There is a good chance that some of these methods will die ...
- public KorapMatch getMatchInfo (String id,
+ public Match getMatchInfo (String id,
String field,
String foundry,
String layer,
@@ -646,7 +647,7 @@
};
- public KorapMatch getMatchInfo (String id,
+ public Match getMatchInfo (String id,
String field,
String foundry,
String layer,
@@ -665,7 +666,7 @@
);
};
- public KorapMatch getMatchInfo (String id,
+ public Match getMatchInfo (String id,
String field,
boolean info,
String foundry,
@@ -696,10 +697,10 @@
* Get a match.
*/
/*
- KorapInfo is associated with a KorapMatch and has an array with all informations
+ KorapInfo is associated with a Match and has an array with all informations
per position in the match.
*/
- public KorapMatch getMatchInfo (String idString,
+ public Match getMatchInfo (String idString,
String field,
boolean info,
List<String> foundry,
@@ -708,7 +709,7 @@
boolean includeHighlights,
boolean extendToSentence) throws QueryException {
- KorapMatch match = new KorapMatch(idString, includeHighlights);
+ Match match = new Match(idString, includeHighlights);
if (this.getVersion() != null)
match.setVersion(this.getVersion());
@@ -1194,8 +1195,8 @@
};
// Collect matches from atomic readers
- ArrayList<KorapMatch> atomicMatches =
- new ArrayList<KorapMatch>(kr.getItemsPerPage());
+ ArrayList<Match> atomicMatches =
+ new ArrayList<Match>(kr.getItemsPerPage());
// Start time out thread
TimeOutThread tthread = new TimeOutThread();
@@ -1285,8 +1286,8 @@
// Do not load all of this, in case the doc is the same!
Document doc = lreader.document(localDocID, fields);
- // Create new KorapMatch
- KorapMatch match = new KorapMatch(
+ // Create new Match
+ Match match = new Match(
pto,
localDocID,
spans.start(),
@@ -1409,7 +1410,7 @@
HashSet<String> fields = new HashSet<>(1);
fields.add("UID");
- // List<KorapMatch> atomicMatches = new ArrayList<KorapMatch>(10);
+ // List<Match> atomicMatches = new ArrayList<Match>(10);
try {
// Rewrite query (for regex and wildcard queries)
@@ -1444,7 +1445,7 @@
// New match
// MatchIdentifier possibly needs more
/*
- KorapMatch match = new KorapMatch();
+ Match match = new Match();
match.setStartPos(spans.start());
match.setEndPos(spans.end());
diff --git a/src/main/java/de/ids_mannheim/korap/KorapResult.java b/src/main/java/de/ids_mannheim/korap/KorapResult.java
index 40232ae..20d2149 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapResult.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapResult.java
@@ -12,7 +12,9 @@
// Remove:
import de.ids_mannheim.korap.meta.SearchContext;
+
import de.ids_mannheim.korap.response.KorapResponse;
+import de.ids_mannheim.korap.response.Match;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,7 +45,7 @@
private int startIndex = 0;
private String serialQuery;
- private List<KorapMatch> matches;
+ private List<Match> matches;
private SearchContext context;
@@ -54,8 +56,8 @@
private JsonNode request;
// Logger
- // This is KorapMatch instead of KorapResult!
- private final static Logger log = LoggerFactory.getLogger(KorapMatch.class);
+ // This is Match instead of KorapResult!
+ private final static Logger log = LoggerFactory.getLogger(Match.class);
/**
@@ -96,9 +98,9 @@
/**
* Add a new match to the result set.
*
- * @param match A {@link KorapMatch} to add.
+ * @param match A {@link Match} to add.
*/
- public void add (KorapMatch km) {
+ public void add (Match km) {
this.matches.add(km);
};
@@ -195,24 +197,24 @@
/**
- * Get a certain {@link KorapMatch} by index.
+ * Get a certain {@link Match} by index.
*
* @param index The numerical index of the match,
* starts with <tt>0</tt>.
- * @return The {@link KorapMatch} object.
+ * @return The {@link Match} object.
*/
@JsonIgnore
- public KorapMatch getMatch (int index) {
+ public Match getMatch (int index) {
return this.matches.get(index);
};
/**
- * Get the list of {@link KorapMatch} matches.
+ * Get the list of {@link Match} matches.
*
- * @return The list of {@link KorapMatch} objects.
+ * @return The list of {@link Match} objects.
*/
- public List<KorapMatch> getMatches() {
+ public List<Match> getMatches() {
return this.matches;
};
@@ -306,7 +308,7 @@
int i = 1;
// Add matches as bracket strings
- for (KorapMatch km : this.getMatches())
+ for (Match km : this.getMatches())
sb.append(i++)
.append(": ")
.append(km.getSnippetBrackets())
@@ -326,7 +328,7 @@
ArrayNode array = json.putArray("matches");
// Add matches as token lists
- for (KorapMatch km : this.getMatches())
+ for (Match km : this.getMatches())
array.add(km.toTokenList());
try {
diff --git a/src/main/java/de/ids_mannheim/korap/index/MatchCollector.java b/src/main/java/de/ids_mannheim/korap/index/MatchCollector.java
index 982002f..577dd86 100644
--- a/src/main/java/de/ids_mannheim/korap/index/MatchCollector.java
+++ b/src/main/java/de/ids_mannheim/korap/index/MatchCollector.java
@@ -1,5 +1,5 @@
package de.ids_mannheim.korap.index;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.response.KorapResponse;
import java.util.*;
diff --git a/src/main/java/de/ids_mannheim/korap/index/SpanInfo.java b/src/main/java/de/ids_mannheim/korap/index/SpanInfo.java
index 0314dc1..b8d5ea5 100644
--- a/src/main/java/de/ids_mannheim/korap/index/SpanInfo.java
+++ b/src/main/java/de/ids_mannheim/korap/index/SpanInfo.java
@@ -1,6 +1,6 @@
package de.ids_mannheim.korap.index;
import de.ids_mannheim.korap.index.TermInfo;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.index.PositionsToOffset;
@@ -16,71 +16,69 @@
int localDocID;
// Logger
- private final static Logger log = LoggerFactory.getLogger(KorapMatch.class);
- // This advices the java compiler to ignore all loggings
+ private final static Logger log = LoggerFactory.getLogger(Match.class);
+ // This advices the java compiler to ignore all loggings
public static final boolean DEBUG = false;
-
public SpanInfo (PositionsToOffset pto, int localDocID) {
- this.terms = new ArrayList<TermInfo>(64);
- this.startChar = new HashMap<Integer,Integer>(16);
- this.endChar = new HashMap<Integer,Integer>(16);
- this.pto = pto;
- this.localDocID = localDocID;
+ this.terms = new ArrayList<TermInfo>(64);
+ this.startChar = new HashMap<Integer,Integer>(16);
+ this.endChar = new HashMap<Integer,Integer>(16);
+ this.pto = pto;
+ this.localDocID = localDocID;
};
public void add (TermInfo info) {
- info.analyze();
- if (info.getType() != "pos") {
- this.terms.add(info);
- }
- else {
- this.startChar.put(info.getStartPos(), info.getStartChar());
- this.endChar.put(info.getEndPos(), info.getEndChar());
- };
+ info.analyze();
+ if (info.getType() != "pos") {
+ this.terms.add(info);
+ }
+ else {
+ this.startChar.put(info.getStartPos(), info.getStartChar());
+ this.endChar.put(info.getEndPos(), info.getEndChar());
+ };
};
public ArrayList<TermInfo> getTerms () {
+ // Sort terms (this will also analyze them!)
+ Collections.sort(this.terms);
+ boolean found;
- // Sort terms (this will also analyze them!)
- Collections.sort(this.terms);
- boolean found;
+ // Add character offset information to terms that are
+ // missing this information
+ for (TermInfo t : this.terms) {
+ if (DEBUG)
+ log.trace("Check offsets for {} and {}", t.getStartPos(), t.getEndPos());
+ found = true;
+ if (t.getStartChar() == -1) {
+ if (this.startChar.containsKey(t.getStartPos()))
+ t.setStartChar(this.startChar.get(t.getStartPos()));
+ else
+ found = false;
+ }
+ if (t.getEndChar() == -1) {
+ if (this.endChar.containsKey(t.getEndPos()))
+ t.setEndChar(this.endChar.get(t.getEndPos()));
+ else
+ found = false;
+ };
+
+ // Add this to found offsets
+ if (found && t.getStartPos() == t.getEndPos())
+ this.pto.addOffset(
+ this.localDocID,
+ t.getStartPos(),
+ t.getStartChar(),
+ t.getEndChar()
+ );
+ else {
+ if (DEBUG)
+ log.trace("{} can't be found!", t.getAnnotation());
+ this.pto.add(this.localDocID, t.getStartPos());
+ this.pto.add(this.localDocID, t.getStartPos());
+ };
+ };
- // Add character offset information to terms that are
- // missing this information
- for (TermInfo t : this.terms) {
- if (DEBUG)
- log.trace("Check offsets for {} and {}", t.getStartPos(), t.getEndPos());
- found = true;
- if (t.getStartChar() == -1) {
- if (this.startChar.containsKey(t.getStartPos()))
- t.setStartChar(this.startChar.get(t.getStartPos()));
- else
- found = false;
- }
- if (t.getEndChar() == -1) {
- if (this.endChar.containsKey(t.getEndPos()))
- t.setEndChar(this.endChar.get(t.getEndPos()));
- else
- found = false;
- };
-
- // Add this to found offsets
- if (found && t.getStartPos() == t.getEndPos())
- this.pto.addOffset(
- this.localDocID,
- t.getStartPos(),
- t.getStartChar(),
- t.getEndChar()
- );
- else {
- if (DEBUG)
- log.trace("{} can't be found!", t.getAnnotation());
- this.pto.add(this.localDocID, t.getStartPos());
- this.pto.add(this.localDocID, t.getStartPos());
- };
- };
-
- return this.terms;
+ return this.terms;
};
};
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 cc3d12a..2835be3 100644
--- a/src/main/java/de/ids_mannheim/korap/index/TermInfo.java
+++ b/src/main/java/de/ids_mannheim/korap/index/TermInfo.java
@@ -4,7 +4,7 @@
import java.nio.ByteBuffer;
import java.lang.StringBuffer;
import java.util.regex.*;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -12,7 +12,7 @@
public class TermInfo implements Comparable<TermInfo> {
// Logger
- private final static Logger log = LoggerFactory.getLogger(KorapMatch.class);
+ private final static Logger log = LoggerFactory.getLogger(Match.class);
// This advices the java compiler to ignore all loggings
public static final boolean DEBUG = false;
@@ -25,114 +25,116 @@
private boolean analyzed = false;
private int startChar = -1,
- endChar = -1,
- startPos = -1,
- endPos = -1;
+ endChar = -1,
+ startPos = -1,
+ endPos = -1;
private byte depth = (byte) 0;
-
+
private Pattern prefixRegex = Pattern.compile("(?:([^/]+)/)?([^:/]+)(?::(.+?))?");
private Matcher matcher;
public TermInfo (String term, int pos, ByteBuffer payload) {
- this.term = term;
- this.startPos = pos;
- this.endPos = pos;
- this.payload = payload;
+ this.term = term;
+ this.startPos = pos;
+ this.endPos = pos;
+ this.payload = payload;
};
public TermInfo analyze () {
- if (analyzed)
- return this;
+ if (analyzed)
+ return this;
- int ttype = 0;
- String tterm = this.term;
- int lastPos = this.payload.position();
- this.payload.rewind();
+ int ttype = 0;
+ String tterm = this.term;
+ int lastPos = this.payload.position();
+ this.payload.rewind();
- switch (tterm.charAt(0)) {
- case '<':
- // "<>:mate/l:..."
- if (tterm.charAt(1) == '>') {
- // span
- this.type = "span";
- tterm = tterm.substring(3);
- ttype = 2;
- }
- // rel-target
- else {
- this.type = "relTarget";
- tterm = tterm.substring(2);
- ttype = 3;
- };
- break;
- case '>':
- // rel-src
- this.type = "relSrc";
- tterm = tterm.substring(2);
- ttype = 3;
- break;
+ switch (tterm.charAt(0)) {
+ case '<':
+ // "<>:mate/l:..."
+ if (tterm.charAt(1) == '>') {
+ // span
+ this.type = "span";
+ tterm = tterm.substring(3);
+ ttype = 2;
+ }
+ // rel-target
+ else {
+ this.type = "relTarget";
+ tterm = tterm.substring(2);
+ ttype = 3;
+ };
+ break;
- case '_':
- // pos
- this.type = "pos";
- ttype = 1;
- tterm = tterm.substring(1);
- break;
- default:
- // term
- this.type = "term";
- };
+ case '>':
+ // rel-src
+ this.type = "relSrc";
+ tterm = tterm.substring(2);
+ ttype = 3;
+ break;
+
+ case '_':
+ // pos
+ this.type = "pos";
+ ttype = 1;
+ tterm = tterm.substring(1);
+ break;
- // Analyze term value
- if (ttype != 1) {
- if (DEBUG)
- log.trace("Check {} for {}", tterm, prefixRegex.toString());
- matcher = prefixRegex.matcher(tterm);
- if (matcher.matches() && matcher.groupCount() == 3) {
- this.annotation = tterm;
- if (matcher.group(1) != null)
- this.foundry = matcher.group(1);
- else
- this.foundry = "base";
- this.layer = matcher.group(2);
- this.value = matcher.group(3);
- };
- }
+ default:
+ // term
+ this.type = "term";
+ };
- // for positions
- else {
- this.value = tterm;
- this.startChar = this.payload.getInt();
- this.endChar = this.payload.getInt();
- };
+ // Analyze term value
+ if (ttype != 1) {
+ if (DEBUG)
+ log.trace("Check {} for {}", tterm, prefixRegex.toString());
+ matcher = prefixRegex.matcher(tterm);
+ if (matcher.matches() && matcher.groupCount() == 3) {
+ this.annotation = tterm;
+ if (matcher.group(1) != null)
+ this.foundry = matcher.group(1);
+ else
+ this.foundry = "base";
+ this.layer = matcher.group(2);
+ this.value = matcher.group(3);
+ };
+ }
- // for spans
- if (ttype == 2) {
- this.startChar = this.payload.getInt();
- this.endChar = this.payload.getInt();
- };
+ // for positions
+ else {
+ this.value = tterm;
+ this.startChar = this.payload.getInt();
+ this.endChar = this.payload.getInt();
+ };
+
+ // for spans
+ if (ttype == 2) {
+ this.startChar = this.payload.getInt();
+ this.endChar = this.payload.getInt();
+ };
- // for spans and relations
- if (ttype > 1)
- // Unsure if this is correct
- this.endPos = this.payload.getInt() -1;
-
- if (ttype == 2 && this.payload.position() < lastPos) {
- this.depth = this.payload.get();
- };
-
- // payloads can have different meaning
- analyzed = true;
- return this;
+ // for spans and relations
+ if (ttype > 1)
+ // Unsure if this is correct
+ this.endPos = this.payload.getInt() -1;
+
+ if (ttype == 2 && this.payload.position() < lastPos) {
+ this.depth = this.payload.get();
+ };
+
+ // payloads can have different meaning
+ analyzed = true;
+ return this;
};
public String getType () {
- return this.type;
+ return this.type;
};
public int getStartChar () {
- return this.startChar;
+ return this.startChar;
};
public void setStartChar (int pos) {
@@ -140,7 +142,7 @@
};
public int getEndChar () {
- return this.endChar;
+ return this.endChar;
};
public void setEndChar (int pos) {
@@ -148,74 +150,74 @@
};
public int getStartPos () {
- return this.startPos;
+ return this.startPos;
};
public int getEndPos () {
- return this.endPos;
+ return this.endPos;
};
public byte getDepth () {
- return this.depth;
+ return this.depth;
};
public String getFoundry () {
- return this.foundry;
+ return this.foundry;
};
public String getLayer () {
- return this.layer;
+ return this.layer;
};
public String getValue () {
- return this.value;
+ return this.value;
};
public String getAnnotation () {
- return this.annotation;
+ return this.annotation;
};
public String toString () {
- this.analyze();
+ this.analyze();
- StringBuffer sb = new StringBuffer();
- sb.append('<').append(this.getType()).append('>');
- sb.append(this.getFoundry()).append('/').append(this.getLayer());
+ StringBuffer sb = new StringBuffer();
+ sb.append('<').append(this.getType()).append('>');
+ sb.append(this.getFoundry()).append('/').append(this.getLayer());
- if (this.getValue() != null)
- sb.append(':').append(this.getValue());
+ if (this.getValue() != null)
+ sb.append(':').append(this.getValue());
- if (this.getDepth() != (byte) 0)
- sb.append('(').append(this.getDepth()).append(')');
+ if (this.getDepth() != (byte) 0)
+ sb.append('(').append(this.getDepth()).append(')');
- sb.append('[').append(this.getStartPos());
- sb.append('-').append(this.getEndPos()).append(']');
- sb.append('[').append(this.getStartChar());
- sb.append('-').append(this.getEndChar()).append(']');
+ sb.append('[').append(this.getStartPos());
+ sb.append('-').append(this.getEndPos()).append(']');
+ sb.append('[').append(this.getStartChar());
+ sb.append('-').append(this.getEndChar()).append(']');
- return sb.toString();
+ return sb.toString();
};
@Override
public int compareTo (TermInfo obj) {
- this.analyze();
- obj.analyze();
+ this.analyze();
+ obj.analyze();
- // TODO: This sorting does not seem to work!
- // although it might only be important for depth stuff.
+ // TODO: This sorting does not seem to work!
+ // although it might only be important for depth stuff.
- if (this.startChar < obj.startChar) {
- return -1;
- }
- else if (this.startChar > obj.startChar) {
- return 1;
- }
- else if (this.depth < obj.depth) {
- return 1;
- }
- else if (this.depth > obj.depth) {
- return -1;
- };
- return 0;
+ if (this.startChar < obj.startChar) {
+ return -1;
+ }
+ else if (this.startChar > obj.startChar) {
+ return 1;
+ }
+ else if (this.depth < obj.depth) {
+ return 1;
+ }
+ else if (this.depth > obj.depth) {
+ return -1;
+ };
+ return 0;
};
};
diff --git a/src/main/java/de/ids_mannheim/korap/index/collector/MatchCollectorDB.java b/src/main/java/de/ids_mannheim/korap/index/collector/MatchCollectorDB.java
index 10650dd..1bbf33b 100644
--- a/src/main/java/de/ids_mannheim/korap/index/collector/MatchCollectorDB.java
+++ b/src/main/java/de/ids_mannheim/korap/index/collector/MatchCollectorDB.java
@@ -1,6 +1,6 @@
package de.ids_mannheim.korap.index.collector;
import de.ids_mannheim.korap.KorapNode;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.index.MatchCollector;
import com.fasterxml.jackson.annotation.*;
import java.sql.Connection;
@@ -35,46 +35,46 @@
* Create a new collector for database connections
*/
public MatchCollectorDB (int bufferSize, String resultID) {
- this.bufferSize = bufferSize;
- this.resultID = resultID;
- this.matchCollector = new ArrayList<int[]>(bufferSize + 2);
+ this.bufferSize = bufferSize;
+ this.resultID = resultID;
+ this.matchCollector = new ArrayList<int[]>(bufferSize + 2);
};
/*
* Add matches till the bufferSize exceeds - then commit to the database.
*/
public void add (int UID, int matchCount) {
- if (this.docCollect == bufferSize)
- this.commit();
+ if (this.docCollect == bufferSize)
+ this.commit();
- this.incrTotalResultDocs(1);
- this.incrTotalResults(matchCount);
- this.matchCollector.add(new int[]{UID, matchCount});
- this.docCollect++;
+ this.incrTotalResultDocs(1);
+ this.incrTotalResults(matchCount);
+ this.matchCollector.add(new int[]{UID, matchCount});
+ this.docCollect++;
};
@JsonIgnore
public void setDatabaseType (String type) {
- this.databaseType = type;
+ this.databaseType = type;
};
@JsonIgnore
public String getDatabaseType () {
- return this.databaseType;
+ return this.databaseType;
};
@JsonIgnore
public void setDBPool (String type, DataSource ds, Connection conn) throws SQLException {
- this.setDatabaseType(type);
- this.connection = conn;
- this.pool = ds;
+ this.setDatabaseType(type);
+ this.connection = conn;
+ this.pool = ds;
};
@JsonIgnore
public void setDBPool (String type, DataSource ds) throws SQLException {
- this.setDatabaseType(type);
- this.pool = ds;
+ this.setDatabaseType(type);
+ this.pool = ds;
};
/*
Create prepared statement for multiple requests
@@ -88,95 +88,94 @@
/* TODO: Ensure the commit was successful! */
public void commit () {
- if (this.pool == null)
- return;
+ if (this.pool == null)
+ return;
- try {
+ try {
/*
* This should be heavily optimized! It's aweful!
* ARGHHHHHHH!
*/
+ if (this.connection.isClosed())
+ this.connection = this.pool.getConnection();
- if (this.connection.isClosed())
- this.connection = this.pool.getConnection();
+ StringBuilder sb = new StringBuilder();
+ sb.append("INSERT INTO ")
+ .append(this.resultID)
+ .append(" (text_id, match_count) ");
+
+ // SQLite batch insertion idiom
+ if (this.getDatabaseType().equals("sqlite")) {
+ for (int i = 1; i < this.docCollect; i++) {
+ sb.append("SELECT ?, ? UNION ");
+ }
+ if (this.docCollect == 1)
+ sb.append("VALUES (?, ?)");
+ else
+ sb.append("SELECT ?, ?");
+ }
- StringBuilder sb = new StringBuilder();
- sb.append("INSERT INTO ")
- .append(this.resultID)
- .append(" (text_id, match_count) ");
+ // MySQL batch insertion idiom
+ else if (this.getDatabaseType().equals("mysql")) {
+ sb.append(" VALUES ");
+ for (int i = 1; i < this.docCollect; i++) {
+ sb.append("(?,?),");
+ };
+ sb.append("(?,?)");
+ }
+
+ // Unknown idiom
+ else {
+ log.error("Unsupported Database type");
+ return;
+ };
- // SQLite batch insertion idiom
- if (this.getDatabaseType().equals("sqlite")) {
- for (int i = 1; i < this.docCollect; i++) {
- sb.append("SELECT ?, ? UNION ");
- }
- if (this.docCollect == 1)
- sb.append("VALUES (?, ?)");
- else
- sb.append("SELECT ?, ?");
- }
+ // Prepare statement based on the string
+ PreparedStatement prep = this.connection.prepareStatement(sb.toString());
- // MySQL batch insertion idiom
- else if (this.getDatabaseType().equals("mysql")) {
- sb.append(" VALUES ");
- for (int i = 1; i < this.docCollect; i++) {
- sb.append("(?,?),");
- };
- sb.append("(?,?)");
- }
+ int i = 1;
+ ListIterator li = this.matchCollector.listIterator();
+ while (li.hasNext()) {
+ int[] v = (int[]) li.next();
+ prep.setInt(i++, v[0]);
+ prep.setInt(i++, v[1]);
+ };
- // Unknown idiom
- else {
- log.error("Unsupported Database type");
- return;
- };
+ prep.addBatch();
+ prep.executeBatch();
+ this.connection.commit();
+ }
- // Prepare statement based on the string
- PreparedStatement prep = this.connection.prepareStatement(sb.toString());
+ // An SQL error occured ...
+ catch (SQLException e) {
+ log.error(e.getLocalizedMessage());
+ };
- int i = 1;
- ListIterator li = this.matchCollector.listIterator();
- while (li.hasNext()) {
- int[] v = (int[]) li.next();
- prep.setInt(i++, v[0]);
- prep.setInt(i++, v[1]);
- };
-
- prep.addBatch();
- prep.executeBatch();
- this.connection.commit();
- }
-
- // An SQL error occured ...
- catch (SQLException e) {
- log.error(e.getLocalizedMessage());
- };
-
- this.matchCollector.clear();
- this.docCollect = 0;
- return;
+ this.matchCollector.clear();
+ this.docCollect = 0;
+ return;
};
/*
* Close collector and connection
*/
public void close () {
- this.commit();
- try {
- this.connection.close();
- }
+ this.commit();
+ try {
+ this.connection.close();
+ }
catch (SQLException e) {
- log.warn(e.getLocalizedMessage());
- }
+ log.warn(e.getLocalizedMessage());
+ }
};
/*
* Close collector and probably connection
*/
public void close (boolean close) {
- if (close)
- this.close();
- else
- this.commit();
+ if (close)
+ this.close();
+ else
+ this.commit();
};
};
diff --git a/src/main/java/de/ids_mannheim/korap/match/HighlightCombinator.java b/src/main/java/de/ids_mannheim/korap/match/HighlightCombinator.java
index d379d94..43ba8cd 100644
--- a/src/main/java/de/ids_mannheim/korap/match/HighlightCombinator.java
+++ b/src/main/java/de/ids_mannheim/korap/match/HighlightCombinator.java
@@ -1,6 +1,6 @@
package de.ids_mannheim.korap.match;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.match.HighlightCombinatorElement;
import java.util.*;
import java.io.*;
@@ -13,8 +13,8 @@
*/
public class HighlightCombinator {
- // Logger (use the KorapMatch class)
- private final static Logger log = LoggerFactory.getLogger(KorapMatch.class);
+ // Logger (use the Match class)
+ private final static Logger log = LoggerFactory.getLogger(Match.class);
// This advices the java compiler to ignore all loggings
public static final boolean DEBUG = false;
@@ -25,161 +25,161 @@
// Empty constructor
public HighlightCombinator () {
- this.combine = new LinkedList<>();
+ this.combine = new LinkedList<>();
};
// Return the combination list
public LinkedList<HighlightCombinatorElement> list () {
- return this.combine;
+ return this.combine;
};
// get the first element (without removing)
public HighlightCombinatorElement getFirst () {
- return this.combine.getFirst();
+ return this.combine.getFirst();
};
// get the last element (without removing)
public HighlightCombinatorElement getLast () {
- return this.combine.getLast();
+ return this.combine.getLast();
};
// get an element by index (without removing)
public HighlightCombinatorElement get (int index) {
- return this.combine.get(index);
+ return this.combine.get(index);
};
// Get the size of the combinator stack
public short size () {
- return (short) this.combine.size();
+ return (short) this.combine.size();
};
// Add primary data to the stack
public void addString (String characters) {
- this.combine.add(new HighlightCombinatorElement(characters));
+ this.combine.add(new HighlightCombinatorElement(characters));
};
// Add opening highlight combinator to the stack
public void addOpen (int number) {
- this.combine.add(new HighlightCombinatorElement((byte) 1, number));
- this.balanceStack.push(number);
+ this.combine.add(new HighlightCombinatorElement((byte) 1, number));
+ this.balanceStack.push(number);
};
// Add closing highlight combinator to the stack
public void addClose (int number) {
- HighlightCombinatorElement lastComb;
+ HighlightCombinatorElement lastComb;
- // Clean up temporary stack
- this.tempStack.clear();
+ // Clean up temporary stack
+ this.tempStack.clear();
+
+ // Check if there is an opening tag at least
+ if (this.balanceStack.empty()) {
+ if (DEBUG)
+ log.trace("The balance stack is empty");
+ return;
+ };
- // Check if there is an opening tag at least
- if (this.balanceStack.empty()) {
- if (DEBUG)
- log.trace("The balance stack is empty");
- return;
- };
+ // Just some debug information
+ if (DEBUG) {
+ StringBuilder sb = new StringBuilder("Stack for checking with class ");
+ sb.append(number).append(" is ");
+ for (int s : this.balanceStack) {
+ sb.append('[').append(s).append(']');
+ };
+ log.trace(sb.toString());
+ };
- // Just some debug information
- if (DEBUG) {
- StringBuilder sb = new StringBuilder("Stack for checking with class ");
- sb.append(number).append(" is ");
- for (int s : this.balanceStack) {
- sb.append('[').append(s).append(']');
- };
- log.trace(sb.toString());
- };
+ // class number of the last element
+ // It's already ensured the stack is not empty
+ int eold = this.balanceStack.pop();
+
+ // the closing element is not balanced, i.e. the last element differs
+ while (eold != number) {
+
+ // Retrieve last combinator on stack
+ lastComb = this.combine.peekLast();
+
+ if (DEBUG)
+ log.trace("Closing element is unbalanced - {} " +
+ "!= {} with lastComb {}|{}|{}",
+ eold,
+ number,
+ lastComb.type,
+ lastComb.number,
+ lastComb.characters);
- // class number of the last element
- // It's already ensured the stack is not empty
- int eold = this.balanceStack.pop();
+ // combinator is opening and the number is not equal to the last
+ // element on the balanceStack
+ if (lastComb.type == 1 && lastComb.number == eold) {
+
+ // Remove the last element - it's empty and uninteresting!
+ this.combine.removeLast();
+ }
- // the closing element is not balanced, i.e. the last element differs
- while (eold != number) {
+ // combinator is either closing (??) or another opener
+ else {
- // Retrieve last combinator on stack
- lastComb = this.combine.peekLast();
-
- if (DEBUG)
- log.trace("Closing element is unbalanced - {} " +
- "!= {} with lastComb {}|{}|{}",
- eold,
- number,
- lastComb.type,
- lastComb.number,
- lastComb.characters);
-
- // combinator is opening and the number is not equal to the last
- // element on the balanceStack
- if (lastComb.type == 1 && lastComb.number == eold) {
+ if (DEBUG)
+ log.trace("close element a) {}", eold);
- // Remove the last element - it's empty and uninteresting!
- this.combine.removeLast();
- }
+ // Add a closer for the old element (this has following elements)
+ this.combine.add(new HighlightCombinatorElement((byte) 2, eold, false));
+ };
- // combinator is either closing (??) or another opener
- else {
+ // add this element number temporarily on the stack
+ tempStack.push(eold);
- if (DEBUG)
- log.trace("close element a) {}", eold);
-
- // Add a closer for the old element (this has following elements)
- this.combine.add(new HighlightCombinatorElement((byte) 2, eold, false));
- };
+ // Check next element
+ eold = this.balanceStack.pop();
+ };
- // add this element number temporarily on the stack
- tempStack.push(eold);
+ // Get last combinator on the stack
+ lastComb = this.combine.peekLast();
- // Check next element
- eold = this.balanceStack.pop();
- };
-
- // Get last combinator on the stack
- lastComb = this.combine.peekLast();
-
- if (DEBUG) {
- log.trace("LastComb: " +
- lastComb.type +
- '|' +
- lastComb.number +
- '|' + lastComb.characters +
- " for " +
- number);
- log.trace("Stack for checking 2: {}|{}|{}|{}",
- lastComb.type,
- lastComb.number,
- lastComb.characters,
- number);
- };
-
- if (lastComb.type == 1 && lastComb.number == number) {
- while (lastComb.type == 1 && lastComb.number == number) {
- // Remove the damn thing - It's empty and uninteresting!
- this.combine.removeLast();
- lastComb = this.combine.peekLast();
- };
- }
- else {
- if (DEBUG)
- log.trace("close element b) {}", number);
+ if (DEBUG) {
+ log.trace("LastComb: " +
+ lastComb.type +
+ '|' +
+ lastComb.number +
+ '|' + lastComb.characters +
+ " for " +
+ number);
+ log.trace("Stack for checking 2: {}|{}|{}|{}",
+ lastComb.type,
+ lastComb.number,
+ lastComb.characters,
+ number);
+ };
+
+ if (lastComb.type == 1 && lastComb.number == number) {
+ while (lastComb.type == 1 && lastComb.number == number) {
+ // Remove the damn thing - It's empty and uninteresting!
+ this.combine.removeLast();
+ lastComb = this.combine.peekLast();
+ };
+ }
+ else {
+ if (DEBUG)
+ log.trace("close element b) {}", number);
- // Add a closer
- this.combine.add(new HighlightCombinatorElement((byte) 2, number));
- };
+ // Add a closer
+ this.combine.add(new HighlightCombinatorElement((byte) 2, number));
+ };
- // Fetch everything from the tempstack and reopen it
- for (int e : tempStack) {
- if (DEBUG)
- log.trace("Reopen element {}", e);
- combine.add(new HighlightCombinatorElement((byte) 1, e));
- balanceStack.push(e);
- };
+ // Fetch everything from the tempstack and reopen it
+ for (int e : tempStack) {
+ if (DEBUG)
+ log.trace("Reopen element {}", e);
+ combine.add(new HighlightCombinatorElement((byte) 1, e));
+ balanceStack.push(e);
+ };
};
// Get all combined elements as a string
public String toString () {
- StringBuilder sb = new StringBuilder();
- for (HighlightCombinatorElement e : combine) {
- sb.append(e.toString()).append("\n");
- };
- return sb.toString();
+ StringBuilder sb = new StringBuilder();
+ for (HighlightCombinatorElement e : combine) {
+ sb.append(e.toString()).append("\n");
+ };
+ return sb.toString();
};
};
diff --git a/src/main/java/de/ids_mannheim/korap/match/HighlightCombinatorElement.java b/src/main/java/de/ids_mannheim/korap/match/HighlightCombinatorElement.java
index dbd3e0a..ec0b3b4 100644
--- a/src/main/java/de/ids_mannheim/korap/match/HighlightCombinatorElement.java
+++ b/src/main/java/de/ids_mannheim/korap/match/HighlightCombinatorElement.java
@@ -1,7 +1,7 @@
package de.ids_mannheim.korap.match;
import org.apache.lucene.util.FixedBitSet;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.match.Relation;
import static de.ids_mannheim.korap.util.KorapString.*;
import java.util.*;
@@ -44,7 +44,7 @@
};
// Return html fragment for this combinator element
- public String toHTML (KorapMatch match, FixedBitSet level, byte[] levelCache) {
+ public String toHTML (Match match, FixedBitSet level, byte[] levelCache) {
// Opening
if (this.type == 1) {
StringBuilder sb = new StringBuilder();
@@ -114,7 +114,7 @@
};
// Return bracket fragment for this combinator element
- public String toBrackets (KorapMatch match) {
+ public String toBrackets (Match match) {
if (this.type == 1) {
StringBuilder sb = new StringBuilder();
diff --git a/src/main/java/de/ids_mannheim/korap/node/Resource.java b/src/main/java/de/ids_mannheim/korap/node/Resource.java
index ffeb6bf..27d4f2f 100644
--- a/src/main/java/de/ids_mannheim/korap/node/Resource.java
+++ b/src/main/java/de/ids_mannheim/korap/node/Resource.java
@@ -24,8 +24,8 @@
import de.ids_mannheim.korap.KorapIndex;
import de.ids_mannheim.korap.Krill;
import de.ids_mannheim.korap.KorapCollection;
-import de.ids_mannheim.korap.KorapMatch;
import de.ids_mannheim.korap.KorapResult;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.response.KorapResponse;
import de.ids_mannheim.korap.index.FieldDocument;
import de.ids_mannheim.korap.util.QueryException;
@@ -410,15 +410,15 @@
// Nothing found
catch (QueryException qe) {
- // Todo: Make KorapMatch rely on KorapResponse!
- KorapMatch km = new KorapMatch();
+ // Todo: Make Match rely on KorapResponse!
+ Match km = new Match();
km.addError(qe.getErrorCode(), qe.getMessage());
return km.toJsonString();
}
};
// Response with error message
- KorapMatch km = new KorapMatch();
+ Match km = new Match();
km.addError(601, "Unable to find index");
return km.toJsonString();
};
diff --git a/src/main/java/de/ids_mannheim/korap/KorapMatch.java b/src/main/java/de/ids_mannheim/korap/response/Match.java
similarity index 98%
rename from src/main/java/de/ids_mannheim/korap/KorapMatch.java
rename to src/main/java/de/ids_mannheim/korap/response/Match.java
index b8a04b3..521be0b 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapMatch.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Match.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap;
+package de.ids_mannheim.korap.response;
import java.util.*;
import java.io.*;
@@ -48,10 +48,10 @@
* @see KorapResult
*/
@JsonInclude(Include.NON_NULL)
-public class KorapMatch extends AbstractDocument {
+public class Match extends AbstractDocument {
// Logger
- private final static Logger log = LoggerFactory.getLogger(KorapMatch.class);
+ private final static Logger log = LoggerFactory.getLogger(Match.class);
// This advices the java compiler to ignore all loggings
public static final boolean DEBUG = false;
@@ -105,7 +105,7 @@
private boolean processed = false;
/**
- * Constructs a new KorapMatch object.
+ * Constructs a new Match object.
* Todo: Maybe that's not necessary!
*
* @param pto The PositionsToOffset object, containing relevant
@@ -118,7 +118,7 @@
* @see #snippetBrackets()
* @see PositionsToOffset
*/
- public KorapMatch (PositionsToOffset pto,
+ public Match (PositionsToOffset pto,
int localDocID,
int startPos,
int endPos) {
@@ -130,19 +130,19 @@
/**
- * Constructs a new KorapMatch object.
+ * Constructs a new Match object.
*/
- public KorapMatch () {};
+ public Match () {};
/**
- * Constructs a new KorapMatch object.
+ * Constructs a new Match object.
*
* @param idString Match identifier string as provided by KorapResult.
* @param includeHighlights Boolean value indicating if possible provided
* highlight information should be ignored or not.
*/
- public KorapMatch (String idString, boolean includeHighlights) {
+ public Match (String idString, boolean includeHighlights) {
MatchIdentifier id = new MatchIdentifier(idString);
if (id.getStartPos() > -1) {
this.setCorpusID(id.getCorpusID());
@@ -635,7 +635,7 @@
};
- public KorapMatch setContext (SearchContext context) {
+ public Match setContext (SearchContext context) {
this.context = context;
return this;
};
diff --git a/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java b/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
index c4a6dc5..9c1b399 100644
--- a/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
+++ b/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
@@ -11,7 +11,7 @@
import org.junit.Test;
import de.ids_mannheim.korap.KorapIndex;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.KrillQuery;
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.Krill;
@@ -79,7 +79,7 @@
kr = ki.search(sq, (short) 10);
/*
- for (KorapMatch km : kr.getMatches()){
+ for (Match km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+km.getSnippetBrackets()
);
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 79d49b0..6c0a32b 100644
--- a/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
+++ b/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
@@ -10,7 +10,7 @@
import de.ids_mannheim.korap.query.QueryBuilder;
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.Krill;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.index.FieldDocument;
import de.ids_mannheim.korap.util.QueryException;
@@ -55,7 +55,7 @@
KorapResult kr = ki.search(
(SpanQuery) kq.seq(kq._(1, kq.seg("s:b"))).toQuery()
);
- KorapMatch km = kr.getMatch(0);
+ Match km = kr.getMatch(0);
assertEquals(km.getStartPos(), 1);
assertEquals(km.getEndPos(), 2);
assertEquals(km.getStartPos(1), 1);
@@ -124,7 +124,7 @@
QueryBuilder kq = new QueryBuilder("tokens");
KorapResult kr = ki.search((SpanQuery) kq.seq(kq.seg("s:a")).append(kq.seg("s:b")).append(kq.seg("s:c")).toQuery());
- KorapMatch km = kr.getMatch(0);
+ Match km = kr.getMatch(0);
km.addHighlight(0, 1, (short) 7);
assertEquals("<span class=\"context-left\"></span><mark><mark class=\"class-7 level-0\">ab</mark>c</mark><span class=\"context-right\"></span>", km.getSnippetHTML());
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 bebd2a9..8905440 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
@@ -16,7 +16,7 @@
import org.junit.runners.JUnit4;
import de.ids_mannheim.korap.KorapIndex;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.KrillQuery;
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.query.QueryBuilder;
@@ -230,7 +230,7 @@
assertEquals(30, kr.getMatch(1).startPos);
assertEquals(33, kr.getMatch(1).endPos);
- /* for (KorapMatch km : kr.getMatches()){
+ /* for (Match km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+km.getSnippetBrackets());
}*/
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 62b2f41..b551db3 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
@@ -21,7 +21,7 @@
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.Krill;
import de.ids_mannheim.korap.KrillMeta;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.query.SpanNextQuery;
import de.ids_mannheim.korap.query.SpanClassQuery;
import de.ids_mannheim.korap.query.QueryBuilder;
@@ -138,7 +138,7 @@
QueryBuilder kq = new QueryBuilder("tokens");
KorapResult kr = ki.search((SpanQuery) kq.seq(kq._(3, kq.seg("s:b"))).toQuery());
- KorapMatch km = kr.getMatch(0);
+ Match km = kr.getMatch(0);
assertEquals(km.getPrimaryData(),"abc");
assertEquals(km.getCorpusID(),"WPD");
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMatchCollector.java b/src/test/java/de/ids_mannheim/korap/index/TestMatchCollector.java
index cefb233..fd6ee8d 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchCollector.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchCollector.java
@@ -15,7 +15,7 @@
import de.ids_mannheim.korap.KorapIndex;
import de.ids_mannheim.korap.KrillQuery;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.index.MatchCollector;
import de.ids_mannheim.korap.KorapCollection;
import de.ids_mannheim.korap.Krill;
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 65f6679..ea86ab1 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
@@ -17,7 +17,7 @@
import de.ids_mannheim.korap.Krill;
import de.ids_mannheim.korap.query.QueryBuilder;
import de.ids_mannheim.korap.KorapResult;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.util.QueryException;
@@ -102,7 +102,7 @@
assertEquals("StartPos (0)", kr.getMatch(0).startPos, 7);
assertEquals("EndPos (0)", kr.getMatch(0).endPos, 9);
- KorapMatch km = kr.getMatch(0);
+ Match km = kr.getMatch(0);
assertEquals("SnippetBrackets (0)", "... bcabca[{2:b{1:a}}]c", km.getSnippetBrackets());
assertEquals("ID (0)", "match-c1!d1-p7-9(2)7-8(1)8-8", km.getID());
@@ -114,7 +114,7 @@
ki.addDoc(createSimpleFieldDoc());
ki.commit();
- KorapMatch km = ki.getMatch("match-c1!d1-p7-9(0)8-8(2)7-8");
+ Match km = ki.getMatch("match-c1!d1-p7-9(0)8-8(2)7-8");
assertEquals("StartPos (0)", 7, km.getStartPos());
assertEquals("EndPos (0)", 9, km.getEndPos());
@@ -217,7 +217,7 @@
ki.addDoc(createSimpleFieldDoc());
ki.commit();
- KorapMatch km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8",
+ Match km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8",
"tokens",
null,
null,
@@ -267,7 +267,7 @@
ki.addDoc(createSimpleFieldDoc());
ki.commit();
- KorapMatch km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8",
+ Match km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8",
"tokens",
null,
null,
@@ -313,7 +313,7 @@
ki.addDoc(createSimpleFieldDoc());
ki.commit();
- KorapMatch km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8",
+ Match km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8",
"tokens",
null,
null,
@@ -332,7 +332,7 @@
ki.addDoc(createSimpleFieldDoc());
ki.commit();
- KorapMatch km = ki.getMatchInfo("match-c1!d1-p7-10(4)8-8(2)7-8",
+ Match km = ki.getMatchInfo("match-c1!d1-p7-10(4)8-8(2)7-8",
"tokens",
null,
null,
@@ -351,7 +351,7 @@
ki.addDoc(createSimpleFieldDoc());
ki.commit();
- KorapMatch km = ki.getMatchInfo("match-c1!d1-p7-10(4)8-8(2)7-8",
+ Match km = ki.getMatchInfo("match-c1!d1-p7-10(4)8-8(2)7-8",
"tokens",
null,
null,
@@ -414,7 +414,7 @@
ki.addDoc(createSimpleFieldDoc());
ki.commit();
- KorapMatch km = ki.getMatchInfo("match-c1!d1-p0-5(4)8-8(2)7-8",
+ Match km = ki.getMatchInfo("match-c1!d1-p0-5(4)8-8(2)7-8",
"tokens",
"x",
null,
@@ -508,7 +508,7 @@
ki.addDoc(createSimpleFieldDoc3());
ki.addDoc(createSimpleFieldDoc4());
ki.commit();
- KorapMatch km;
+ Match km;
km = ki.getMatchInfo("match-c1!d1-p3-4",
"tokens",
@@ -562,7 +562,7 @@
ki.addDoc(createSimpleFieldDoc2());
ki.commit();
- KorapMatch km = ki.getMatchInfo("match-c1!d1-p0-4",
+ Match km = ki.getMatchInfo("match-c1!d1-p0-4",
"tokens",
null,
null,
@@ -623,7 +623,7 @@
ki.addDoc(createSimpleFieldDoc4());
ki.commit();
- KorapMatch km = ki.getMatchInfo("match-c1!d4-p3-9",
+ Match km = ki.getMatchInfo("match-c1!d4-p3-9",
"tokens",
"f",
"m",
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 c1caa4a..ca98734 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
@@ -15,9 +15,9 @@
import de.ids_mannheim.korap.KorapIndex;
import de.ids_mannheim.korap.KrillQuery;
-import de.ids_mannheim.korap.KorapMatch;
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.KorapCollection;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.query.*;
import de.ids_mannheim.korap.index.FieldDocument;
import de.ids_mannheim.korap.model.MultiTermTokenStream;
@@ -333,7 +333,7 @@
assertEquals("totalResults", kr.getTotalResults(), 3);
- KorapMatch km = kr.getMatch(0);
+ Match km = kr.getMatch(0);
assertEquals("StartPos (0)", 1, km.startPos);
assertEquals("EndPos (0)", 2, km.endPos);
assertEquals("SnippetBrackets (0)", "a[{3:b}]cabcab ...", km.getSnippetBrackets());
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
index 078d651..e3c325f 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
@@ -15,7 +15,7 @@
import org.junit.runners.JUnit4;
import de.ids_mannheim.korap.KorapIndex;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.KrillQuery;
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.query.SpanNextQuery;
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
index 74c8cfe..4a9227f 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
@@ -9,7 +9,7 @@
import org.junit.Test;
import de.ids_mannheim.korap.KorapIndex;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.query.SpanAttributeQuery;
import de.ids_mannheim.korap.query.SpanElementQuery;
@@ -382,7 +382,7 @@
assertEquals(5,kr.getMatch(6).getStartPos());
assertEquals(7,kr.getMatch(6).getEndPos());
-// for (KorapMatch km : kr.getMatches()){
+// for (Match km : kr.getMatches()){
// System.out.println(km.getStartPos() +","+km.getEndPos()
// // +" "+km.getSnippetBrackets()
// );
@@ -446,7 +446,7 @@
false, true, true);
kr = ki.search(rv3,(short) 10);
- /*for (KorapMatch km : kr.getMatches()){
+ /*for (Match km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+km.getSnippetBrackets()
);
@@ -478,7 +478,7 @@
false, true, true);
kr = ki.search(rv,(short) 10);
- /*for (KorapMatch km : kr.getMatches()){
+ /*for (Match km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+km.getSnippetBrackets());
}*/
@@ -519,7 +519,7 @@
true, false, true);
kr = ki.search(rv,(short) 10);
- /*for (KorapMatch km : kr.getMatches()){
+ /*for (Match km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+km.getSnippetBrackets());
}*/
@@ -551,7 +551,7 @@
new SpanElementQuery("base","np"),
false, true, true);
kr = ki.search(rv,(short) 10);
- /*for (KorapMatch km : kr.getMatches()){
+ /*for (Match km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+km.getSnippetBrackets());
}*/
@@ -575,7 +575,7 @@
kr = ki.search(rv3,(short) 10);
- /*for (KorapMatch km : kr.getMatches()){
+ /*for (Match km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+km.getSnippetBrackets());
}*/
@@ -652,7 +652,7 @@
false, true, true);
kr = ki.search(rv,(short) 10);
- /*for (KorapMatch km : kr.getMatches()){
+ /*for (Match km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+km.getSnippetBrackets());
}*/
@@ -691,7 +691,7 @@
3, false, true, true);
kr = ki.search(rv,(short) 10);
- /*for (KorapMatch km : kr.getMatches()){
+ /*for (Match km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()
+" "+km.getSnippetBrackets()
);
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java
index 052dd0d..affd5a3 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java
@@ -11,7 +11,7 @@
import org.junit.Test;
import de.ids_mannheim.korap.KorapIndex;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.query.SpanNextQuery;
import de.ids_mannheim.korap.query.SpanRepetitionQuery;
@@ -227,7 +227,7 @@
assertEquals(77, kr.getMatch(0).getEndPos());
assertEquals(74, kr.getMatch(1).getStartPos());
assertEquals(77, kr.getMatch(1).getEndPos());
- /* for (KorapMatch km : kr.getMatches()){
+ /* for (Match km : kr.getMatches()){
System.out.println(km.getSnippetBrackets());
System.out.println(km.getStartPos() +","+km.getEndPos());
}*/
@@ -241,7 +241,7 @@
assertEquals(73, kr.getMatch(0).getStartPos());
assertEquals(77, kr.getMatch(0).getEndPos());
/*
- for (KorapMatch km : kr.getMatches()){
+ for (Match km : kr.getMatches()){
System.out.println(km.getSnippetBrackets());
System.out.println(km.getStartPos() +","+km.getEndPos());
}*/
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
index ad99e2c..7ec87db 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
@@ -56,7 +56,7 @@
assertEquals(8, kr.getMatch(2).getEndPos());
/*
- * for (KorapMatch km : kr.getMatches()) {
+ * for (Match km : kr.getMatches()) {
* System.out.println(km.getStartPos() + "," + km.getEndPos() + " " +
* km.getSnippetBrackets()); }
*/
@@ -101,7 +101,7 @@
assertEquals(156, kr.getMatch(3).getEndPos(1));
/*
- * for (KorapMatch km : kr.getMatches()){
+ * for (Match km : kr.getMatches()){
* System.out.println(km.getStartPos() +","+km.getEndPos()+" "
* +km.getSnippetBrackets()); }
*/
@@ -127,7 +127,7 @@
assertEquals(36, kr.getMatch(3).getEndPos(1));
/*
- * for (KorapMatch km : kr.getMatches()){
+ * for (Match km : kr.getMatches()){
* System.out.println(km.getStartPos() +","+km.getEndPos()+" "
* +km.getSnippetBrackets()); }
*/
@@ -161,7 +161,7 @@
assertEquals(13, kr.getMatch(3).getEndPos(1));
/*
- * for (KorapMatch km : kr.getMatches()){
+ * for (Match km : kr.getMatches()){
* System.out.println(km.getStartPos() +","+km.getEndPos()+" "
* +km.getSnippetBrackets()); }
*/
@@ -201,7 +201,7 @@
assertEquals(14, kr.getMatch(6).getEndPos(1));
/*
- * for (KorapMatch km : kr.getMatches()){
+ * for (Match km : kr.getMatches()){
* System.out.println(km.getStartPos() +","+km.getEndPos()+" "
* +km.getSnippetBrackets()); }
*/
@@ -240,7 +240,7 @@
assertEquals(12, kr.getMatch(3).getEndPos());
/*
- * for (KorapMatch km : kr.getMatches()){
+ * for (Match km : kr.getMatches()){
* System.out.println(km.getStartPos() +","+km.getEndPos()+" "
* //+km.getSnippetBrackets() ); }
*/
@@ -302,7 +302,7 @@
assertEquals(208, kr.getMatch(0).getEndPos());
/*
- * for (KorapMatch km : kr.getMatches()){
+ * for (Match km : kr.getMatches()){
* System.out.println(km.getStartPos() +","+km.getEndPos()+" "
* +km.getSnippetBrackets() ); }
*/
@@ -336,7 +336,7 @@
assertEquals((long) 3, kr.getTotalResults());
/*
- * for (KorapMatch km : kr.getMatches()){
+ * for (Match km : kr.getMatches()){
* System.out.println(km.getStartPos() +","+km.getEndPos()+" "
* +km.getSnippetBrackets() ); }
*/
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java
index 4aff0bf..d6346f8 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java
@@ -51,7 +51,7 @@
assertEquals(185, kr.getMatch(1).getEndPos());
/*
- * for (KorapMatch km : kr.getMatches()){
+ * for (Match km : kr.getMatches()){
* System.out.println(km.getStartPos() +","+km.getEndPos()
* +km.getSnippetBrackets()); }
*/
@@ -109,7 +109,7 @@
assertEquals(183, kr.getMatch(1).getStartPos());
assertEquals(185, kr.getMatch(1).getEndPos());
- // for (KorapMatch km : kr.getMatches()) {
+ // for (Match km : kr.getMatches()) {
// System.out.println(km.getStartPos() + "," + km.getEndPos()
// + km.getSnippetBrackets());
// }
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
index 25516e6..4775399 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
@@ -15,7 +15,7 @@
import de.ids_mannheim.korap.KorapCollection;
import de.ids_mannheim.korap.KorapIndex;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.Krill;
import de.ids_mannheim.korap.collection.BooleanFilter;
@@ -85,7 +85,7 @@
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 11);
//System.out.println(kr.getTotalResults());
- //for (KorapMatch km : kr.getMatches()){
+ //for (Match km : kr.getMatches()){
//System.out.println(km.getDocID() +" "+km.getStartPos() +" "+ km.getEndPos());
//System.out.println(km.getSnippetBrackets());
//System.out.println(km.toJSON());
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 e3a6a20..cb76846 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
@@ -15,7 +15,7 @@
import org.junit.runners.JUnit4;
import de.ids_mannheim.korap.KorapIndex;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.KrillQuery;
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.query.SpanElementQuery;
@@ -192,7 +192,7 @@
assertEquals("Doc (11)", 1, kr.getMatch(11).internalDocID);
/*
- for (KorapMatch km : kr.getMatches()){
+ for (Match km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+km.getSnippetBrackets());
};
@@ -1116,7 +1116,7 @@
assertEquals(252, kr.getMatch(1).getEndPos());
/*
- for (KorapMatch km : kr.getMatches()){
+ for (Match km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+km.getSnippetBrackets());
};
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java b/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
index 26452a9..875df5f 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
@@ -9,7 +9,7 @@
import de.ids_mannheim.korap.KrillQuery;
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.Krill;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.index.FieldDocument;
import de.ids_mannheim.korap.util.QueryException;
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKorapResult.java b/src/test/java/de/ids_mannheim/korap/search/TestKorapResult.java
index b84d5f2..f065b83 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKorapResult.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKorapResult.java
@@ -10,7 +10,7 @@
import de.ids_mannheim.korap.KrillQuery;
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.Krill;
-import de.ids_mannheim.korap.KorapMatch;
+import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.query.QueryBuilder;
import de.ids_mannheim.korap.index.FieldDocument;