Fixed matchID
Change-Id: Ice31fae8802e95a7dbd4afe6cb08cb46220e53be
diff --git a/Changes b/Changes
index a562e4c..78efcbf 100644
--- a/Changes
+++ b/Changes
@@ -9,6 +9,7 @@
constraint (diewald)
- [bugfix] Mirror collection (diewald)
- [bugfix] Updated default fields for meta data (diewald)
+ - [bugfix] Updated match identifier for "sigle" data (diewald)
0.51 2015-03-17
- This is a major version (prepared for the GitHub release)
diff --git a/src/main/java/de/ids_mannheim/korap/KrillIndex.java b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
index ebcc32c..25dfd0d 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
@@ -1241,9 +1241,12 @@
fields.add(field);
// Some initializations ...
- int i = 0, startIndex = kr.getStartIndex(), count = kr
- .getItemsPerPage(), hits = kr.getItemsPerPage() + startIndex, limit = meta
- .getLimit(), itemsPerResourceCounter = 0;
+ int i = 0;
+ int startIndex = kr.getStartIndex();
+ int count = kr.getItemsPerPage();
+ int hits = kr.getItemsPerPage() + startIndex;
+ int limit = meta.getLimit();
+ int itemsPerResourceCounter = 0;
boolean cutoff = meta.doCutOff();
short itemsPerResource = meta.getItemsPerResource();
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 90285dc..272a027 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Match.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Match.java
@@ -651,11 +651,18 @@
if (this.localDocID == -1)
return null;
+
MatchIdentifier id = this.getMatchIdentifier();
// Get prefix string corpus/doc
- id.setCorpusID(this.getCorpusID());
- id.setDocID(this.getDocID());
+ if (this.getTextSigle() != null) {
+ id.setTextSigle(this.getTextSigle());
+ }
+ // LEGACY
+ else {
+ id.setCorpusID(this.getCorpusID());
+ id.setDocID(this.getDocID());
+ };
return (this.identifier = id.toString());
};
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
index 2526e94..9b16727 100644
--- a/src/main/java/de/ids_mannheim/korap/response/match/DocIdentifier.java
+++ b/src/main/java/de/ids_mannheim/korap/response/match/DocIdentifier.java
@@ -4,28 +4,45 @@
import java.util.regex.*;
+// TODO: This should only use textSigle!
+
public class DocIdentifier {
- protected String corpusID, docID;
+ protected String
+ textSigle,
+ corpusID, // LEGACY
+ docID; // LEGACY
-
+ // Legacy
public String getCorpusID () {
return this.corpusID;
};
+ // Legacy
public void setCorpusID (String id) {
if (id != null && !id.contains("!"))
this.corpusID = id;
};
+ // Legacy
public String getDocID () {
return this.docID;
};
+ // Legacy
public void setDocID (String id) {
if (id != null && !id.contains("!"))
this.docID = id;
};
+
+ public String getTextSigle () {
+ return this.textSigle;
+ };
+
+ public void setTextSigle (String id) {
+ if (id != null && !id.contains("!"))
+ this.textSigle = id;
+ };
};
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 5f13a3b..7247d17 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
@@ -8,7 +8,7 @@
private ArrayList<int[]> pos = new ArrayList<>(8);
- Pattern idRegex = Pattern.compile("^match-(?:([^!]+?)!)?"
+ 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]+)");
@@ -22,6 +22,10 @@
if (matcher.matches()) {
this.setCorpusID(matcher.group(1));
this.setDocID(matcher.group(2));
+ // TODO! FIXME!
+
+ this.setTextSigle(this.getCorpusID() + "." + this.getDocID());
+
this.setStartPos(Integer.parseInt(matcher.group(3)));
this.setEndPos(Integer.parseInt(matcher.group(4)));
@@ -71,19 +75,26 @@
public String toString () {
- if (this.docID == null)
- return null;
-
StringBuilder sb = new StringBuilder("match-");
+ if (this.docID == null) {
+ if (this.textSigle == null)
+ return null;
+
+ sb.append(this.textSigle);
+ }
+
// Get prefix string corpus/doc
- if (this.corpusID != null)
- sb.append(this.corpusID).append('!');
+ // LEGACY
+ else if (this.corpusID != null) {
+ sb.append(this.corpusID).append('!').append(this.docID);
+ }
+ else {
+ sb.append(this.docID);
+ };
- sb.append(this.docID);
-
- sb.append('-');
- sb.append(this.getPositionString());
+ sb.append('-')
+ .append(this.getPositionString());
return sb.toString();
};
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java b/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
index a23c7e3..b53f13a 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
@@ -144,5 +144,6 @@
assertEquals("Goethe: Maximen und Reflexionen, (1827-1842)", res.at("/matches/0/docTitle").asText());
assertEquals("1827", res.at("/matches/0/creationDate").asText());
assertEquals("372-377", res.at("/matches/0/pages").asText());
+ assertEquals("match-GOE_AGX.00002-p7-8", res.at("/matches/0/ID").asText());
};
};