Moved match/* to response/match/*
diff --git a/src/main/java/de/ids_mannheim/korap/match/DocIdentifier.java b/src/main/java/de/ids_mannheim/korap/match/DocIdentifier.java
deleted file mode 100644
index 1a7ec4f..0000000
--- a/src/main/java/de/ids_mannheim/korap/match/DocIdentifier.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package de.ids_mannheim.korap.match;
-import java.util.*;
-import java.util.regex.*;
-
-
-public class DocIdentifier {
- protected String corpusID, docID;
-
- public String getCorpusID () {
- return this.corpusID;
- };
-
- public void setCorpusID (String id) {
- if (id != null && !id.contains("!"))
- this.corpusID = id;
- };
-
- public String getDocID () {
- return this.docID;
- };
-
- public void setDocID (String id) {
- if (id != null && !id.contains("!"))
- this.docID = id;
- };
-};
diff --git a/src/main/java/de/ids_mannheim/korap/match/MatchIdentifier.java b/src/main/java/de/ids_mannheim/korap/match/MatchIdentifier.java
deleted file mode 100644
index b8d3921..0000000
--- a/src/main/java/de/ids_mannheim/korap/match/MatchIdentifier.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package de.ids_mannheim.korap.match;
-import java.util.*;
-import java.util.regex.*;
-
-public class MatchIdentifier extends DocIdentifier {
- private int startPos, endPos = -1;
-
- private ArrayList<int[]> pos = new ArrayList<>(8);
-
- Pattern idRegex = Pattern.compile(
- "^match-(?:([^!]+?)!)?" +
- "([^!]+)-p([0-9]+)-([0-9]+)" +
- "((?:\\(-?[0-9]+\\)-?[0-9]+--?[0-9]+)*)" +
- "(?:c.+?)?$");
- Pattern posRegex = Pattern.compile(
- "\\(([0-9]+)\\)([0-9]+)-([0-9]+)");
-
- public MatchIdentifier () {};
-
- public MatchIdentifier (String id) {
- Matcher matcher = idRegex.matcher(id);
- if (matcher.matches()) {
- this.setCorpusID(matcher.group(1));
- this.setDocID(matcher.group(2));
- this.setStartPos(Integer.parseInt(matcher.group(3)));
- this.setEndPos(Integer.parseInt(matcher.group(4)));
-
- if (matcher.group(5) != null) {
- matcher = posRegex.matcher(matcher.group(5));
- while (matcher.find()) {
- this.addPos(
- Integer.parseInt(matcher.group(2)),
- Integer.parseInt(matcher.group(3)),
- Integer.parseInt(matcher.group(1))
- );
- };
- };
- };
- };
-
- public int getStartPos () {
- return this.startPos;
- };
-
- public void setStartPos (int pos) {
- if (pos >= 0)
- this.startPos = pos;
- };
-
- public int getEndPos () {
- return this.endPos;
- };
-
- public void setEndPos (int pos) {
- if (pos >= 0)
- this.endPos = pos;
- };
-
- public void addPos(int start, int end, int number) {
- if (start >= 0 && end >= 0 && number >= 0)
- this.pos.add(new int[]{start, end, number});
- };
-
- public ArrayList<int[]> getPos () {
- return this.pos;
- };
-
- public String toString () {
-
- if (this.docID == null) return null;
-
- StringBuilder sb = new StringBuilder("match-");
-
- // Get prefix string corpus/doc
- if (this.corpusID != null) {
- sb.append(this.corpusID).append('!');
- };
- sb.append(this.docID);
-
- sb.append('-');
- sb.append(this.getPositionString());
- return sb.toString();
- };
-
- /*
- public String getPositionBytes () {
- ByteBuffer b = new ByteBuffer(8);
- b.putInt(this.startPos);
- b.putInt(this.endPos);
-
- // Get Position information
- for (int[] i : this.pos) {
- b.putInt(i[2]).putInt(i[0]).putInt(i[1]);
- };
- };
- */
-
- public String getPositionString () {
- StringBuilder sb = new StringBuilder();
- sb.append('p').append(this.startPos).append('-').append(this.endPos);
-
- // Get Position information
- for (int[] i : this.pos) {
- sb.append('(').append(i[2]).append(')');
- sb.append(i[0]).append('-').append(i[1]);
- };
-
- return sb.toString();
-
- /*
- if (this.processed) {
- sb.append('c');
- for (int[] s : this.span) {
- if (s[2] >= 256)
- continue;
-
- if (s[2] != -1)
- sb.append('(').append(s[2]).append(')');
- sb.append(s[0] + this.startOffsetChar);
- sb.append('-');
- sb.append(s[1] + this.startOffsetChar);
- };
- };
- */
- };
-};
diff --git a/src/main/java/de/ids_mannheim/korap/match/PosIdentifier.java b/src/main/java/de/ids_mannheim/korap/match/PosIdentifier.java
deleted file mode 100644
index 1198fac..0000000
--- a/src/main/java/de/ids_mannheim/korap/match/PosIdentifier.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package de.ids_mannheim.korap.match;
-import java.util.*;
-
-public class PosIdentifier extends DocIdentifier {
- private int pos;
-
- public PosIdentifier () {};
-
- public void setPos (int pos) {
- if (pos >= 0)
- this.pos = pos;
- };
-
- public int getPos () {
- return this.pos;
- };
-
- public String toString () {
-
- if (this.docID == null) return null;
-
- StringBuilder sb = new StringBuilder("word-");
-
- // Get prefix string corpus/doc
- if (this.corpusID != null) {
- sb.append(this.corpusID).append('!');
- };
- sb.append(this.docID);
-
- sb.append("-p");
- sb.append(this.pos);
-
- return sb.toString();
- };
-};
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 521be0b..9bcbc06 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Match.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Match.java
@@ -16,11 +16,11 @@
import de.ids_mannheim.korap.meta.SearchContext;
import de.ids_mannheim.korap.model.AbstractDocument;
-import de.ids_mannheim.korap.match.HighlightCombinator;
-import de.ids_mannheim.korap.match.HighlightCombinatorElement;
-import de.ids_mannheim.korap.match.Relation;
-import de.ids_mannheim.korap.match.MatchIdentifier;
-import de.ids_mannheim.korap.match.PosIdentifier;
+import de.ids_mannheim.korap.response.match.HighlightCombinator;
+import de.ids_mannheim.korap.response.match.HighlightCombinatorElement;
+import de.ids_mannheim.korap.response.match.Relation;
+import de.ids_mannheim.korap.response.match.MatchIdentifier;
+import de.ids_mannheim.korap.response.match.PosIdentifier;
import de.ids_mannheim.korap.query.SpanElementQuery;
import org.slf4j.Logger;
diff --git a/src/main/java/de/ids_mannheim/korap/response/match/DocIdentifier.java b/src/main/java/de/ids_mannheim/korap/response/match/DocIdentifier.java
new file mode 100644
index 0000000..8680742
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/response/match/DocIdentifier.java
@@ -0,0 +1,26 @@
+package de.ids_mannheim.korap.response.match;
+import java.util.*;
+import java.util.regex.*;
+
+
+public class DocIdentifier {
+ protected String corpusID, docID;
+
+ public String getCorpusID () {
+ return this.corpusID;
+ };
+
+ public void setCorpusID (String id) {
+ if (id != null && !id.contains("!"))
+ this.corpusID = id;
+ };
+
+ public String getDocID () {
+ return this.docID;
+ };
+
+ public void setDocID (String id) {
+ if (id != null && !id.contains("!"))
+ this.docID = id;
+ };
+};
diff --git a/src/main/java/de/ids_mannheim/korap/match/HighlightCombinator.java b/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinator.java
similarity index 97%
rename from src/main/java/de/ids_mannheim/korap/match/HighlightCombinator.java
rename to src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinator.java
index 43ba8cd..adce408 100644
--- a/src/main/java/de/ids_mannheim/korap/match/HighlightCombinator.java
+++ b/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinator.java
@@ -1,7 +1,7 @@
-package de.ids_mannheim.korap.match;
+package de.ids_mannheim.korap.response.match;
import de.ids_mannheim.korap.response.Match;
-import de.ids_mannheim.korap.match.HighlightCombinatorElement;
+import de.ids_mannheim.korap.response.match.HighlightCombinatorElement;
import java.util.*;
import java.io.*;
diff --git a/src/main/java/de/ids_mannheim/korap/match/HighlightCombinatorElement.java b/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinatorElement.java
similarity index 92%
rename from src/main/java/de/ids_mannheim/korap/match/HighlightCombinatorElement.java
rename to src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinatorElement.java
index ec0b3b4..ab67ed5 100644
--- a/src/main/java/de/ids_mannheim/korap/match/HighlightCombinatorElement.java
+++ b/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinatorElement.java
@@ -1,8 +1,8 @@
-package de.ids_mannheim.korap.match;
+package de.ids_mannheim.korap.response.match;
import org.apache.lucene.util.FixedBitSet;
import de.ids_mannheim.korap.response.Match;
-import de.ids_mannheim.korap.match.Relation;
+import de.ids_mannheim.korap.response.match.Relation;
import static de.ids_mannheim.korap.util.KorapString.*;
import java.util.*;
import java.io.*;
@@ -24,23 +24,23 @@
// Constructor for highlighting elements
public HighlightCombinatorElement (byte type, int number) {
- this.type = type;
- this.number = number;
+ this.type = type;
+ this.number = number;
};
// Constructor for highlighting elements,
// that may not be terminal, i.e. they were closed and will
// be reopened for overlapping issues.
public HighlightCombinatorElement (byte type, int number, boolean terminal) {
- this.type = type;
- this.number = number;
- this.terminal = terminal;
+ this.type = type;
+ this.number = number;
+ this.terminal = terminal;
};
// Constructor for textual data
public HighlightCombinatorElement (String characters) {
- this.type = (byte) 0;
- this.characters = characters;
+ this.type = (byte) 0;
+ this.characters = characters;
};
// Return html fragment for this combinator element
@@ -57,7 +57,7 @@
.append(match.getPosID(match.getClassID(this.number)))
.append("\">");
}
-
+
else if (this.number >= 256) {
sb.append("<span ");
if (this.number < 2048) {
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
new file mode 100644
index 0000000..5b954d6
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/response/match/MatchIdentifier.java
@@ -0,0 +1,97 @@
+package de.ids_mannheim.korap.response.match;
+import java.util.*;
+import java.util.regex.*;
+
+public class MatchIdentifier extends DocIdentifier {
+ private int startPos, endPos = -1;
+
+ private ArrayList<int[]> pos = new ArrayList<>(8);
+
+ Pattern idRegex = Pattern.compile(
+ "^match-(?:([^!]+?)!)?" +
+ "([^!]+)-p([0-9]+)-([0-9]+)" +
+ "((?:\\(-?[0-9]+\\)-?[0-9]+--?[0-9]+)*)" +
+ "(?:c.+?)?$");
+ Pattern posRegex = Pattern.compile(
+ "\\(([0-9]+)\\)([0-9]+)-([0-9]+)");
+
+ public MatchIdentifier () {};
+
+ public MatchIdentifier (String id) {
+ Matcher matcher = idRegex.matcher(id);
+ if (matcher.matches()) {
+ this.setCorpusID(matcher.group(1));
+ this.setDocID(matcher.group(2));
+ this.setStartPos(Integer.parseInt(matcher.group(3)));
+ this.setEndPos(Integer.parseInt(matcher.group(4)));
+
+ if (matcher.group(5) != null) {
+ matcher = posRegex.matcher(matcher.group(5));
+ while (matcher.find()) {
+ this.addPos(
+ Integer.parseInt(matcher.group(2)),
+ Integer.parseInt(matcher.group(3)),
+ Integer.parseInt(matcher.group(1))
+ );
+ };
+ };
+ };
+ };
+
+ public int getStartPos () {
+ return this.startPos;
+ };
+
+ public void setStartPos (int pos) {
+ if (pos >= 0)
+ this.startPos = pos;
+ };
+
+ public int getEndPos () {
+ return this.endPos;
+ };
+
+ public void setEndPos (int pos) {
+ if (pos >= 0)
+ this.endPos = pos;
+ };
+
+ public void addPos(int start, int end, int number) {
+ if (start >= 0 && end >= 0 && number >= 0)
+ this.pos.add(new int[]{start, end, number});
+ };
+
+ public ArrayList<int[]> getPos () {
+ return this.pos;
+ };
+
+ public String toString () {
+ if (this.docID == null) return null;
+
+ StringBuilder sb = new StringBuilder("match-");
+
+ // Get prefix string corpus/doc
+ if (this.corpusID != null)
+ sb.append(this.corpusID).append('!');
+
+ sb.append(this.docID);
+
+ sb.append('-');
+ sb.append(this.getPositionString());
+ return sb.toString();
+ };
+
+
+ public String getPositionString () {
+ StringBuilder sb = new StringBuilder();
+ sb.append('p').append(this.startPos).append('-').append(this.endPos);
+
+ // Get Position information
+ for (int[] i : this.pos) {
+ sb.append('(').append(i[2]).append(')');
+ sb.append(i[0]).append('-').append(i[1]);
+ };
+
+ return sb.toString();
+ };
+};
diff --git a/src/main/java/de/ids_mannheim/korap/response/match/PosIdentifier.java b/src/main/java/de/ids_mannheim/korap/response/match/PosIdentifier.java
new file mode 100644
index 0000000..8606aa6
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/response/match/PosIdentifier.java
@@ -0,0 +1,34 @@
+package de.ids_mannheim.korap.response.match;
+import java.util.*;
+
+public class PosIdentifier extends DocIdentifier {
+ private int pos;
+
+ public PosIdentifier () {};
+
+ public void setPos (int pos) {
+ if (pos >= 0)
+ this.pos = pos;
+ };
+
+ public int getPos () {
+ return this.pos;
+ };
+
+ public String toString () {
+ if (this.docID == null) return null;
+
+ StringBuilder sb = new StringBuilder("word-");
+
+ // Get prefix string corpus/doc
+ if (this.corpusID != null) {
+ sb.append(this.corpusID).append('!');
+ };
+ sb.append(this.docID);
+
+ sb.append("-p");
+ sb.append(this.pos);
+
+ return sb.toString();
+ };
+};
diff --git a/src/main/java/de/ids_mannheim/korap/match/Relation.java b/src/main/java/de/ids_mannheim/korap/response/match/Relation.java
similarity index 62%
rename from src/main/java/de/ids_mannheim/korap/match/Relation.java
rename to src/main/java/de/ids_mannheim/korap/response/match/Relation.java
index f8e01c7..1587ed3 100644
--- a/src/main/java/de/ids_mannheim/korap/match/Relation.java
+++ b/src/main/java/de/ids_mannheim/korap/response/match/Relation.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.match;
+package de.ids_mannheim.korap.response.match;
/**
* Class for relational highlights.
@@ -7,7 +7,7 @@
public int ref;
public String annotation;
public Relation (String annotation, int ref) {
- this.annotation = annotation;
- this.ref = ref;
+ this.annotation = annotation;
+ this.ref = ref;
};
};
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 ea86ab1..94d639f 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
@@ -9,8 +9,8 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import de.ids_mannheim.korap.match.MatchIdentifier;
-import de.ids_mannheim.korap.match.PosIdentifier;
+import de.ids_mannheim.korap.response.match.MatchIdentifier;
+import de.ids_mannheim.korap.response.match.PosIdentifier;
import de.ids_mannheim.korap.KorapIndex;
import de.ids_mannheim.korap.KrillQuery;