Formatted sourcecode
Change-Id: I997e365aafdab24724a55ec45cb99fab165bfc84
diff --git a/Changes b/Changes
index a681cc0..93a2045 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,6 @@
-0.55.3 2016-02-15
+0.55.3 2016-02-19
- [bugfix] Use base foundry for default sentences and paragraphs
- (diewald)
+ (diewald, margaretha)
- [bugfix] Distance constraint exclusion serialized (diewald)
0.55.2 2016-02-13
diff --git a/src/main/java/de/ids_mannheim/korap/KrillIndex.java b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
index b2b1fce..9fb32a4 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
@@ -968,7 +968,8 @@
for (LeafReaderContext atomic : this.reader().leaves()) {
// Retrieve the single document of interest
- DocIdSet filterSet = filter.getDocIdSet(atomic, atomic.reader().getLiveDocs());
+ DocIdSet filterSet = filter.getDocIdSet(atomic, atomic.reader()
+ .getLiveDocs());
// Create a bitset for the correct document
@@ -977,7 +978,8 @@
DocIdSetIterator filterIterator = filterSet.iterator();
if (DEBUG)
- log.trace("Checking document in {} with {}", filterSet, bitset);
+ log.trace("Checking document in {} with {}", filterSet,
+ bitset);
// No document found
if (filterIterator == null)
diff --git a/src/main/java/de/ids_mannheim/korap/KrillQuery.java b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
index 86c6922..b55cd43 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
@@ -1147,7 +1147,7 @@
// Ignore foundry for orth layer
if (layer.equals(".")) {
- layer = "s";
+ layer = "s";
value.setLength(0);
}
else if (layer.equals("i")) {
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 c76f053..dc7403a 100644
--- a/src/main/java/de/ids_mannheim/korap/index/TermInfo.java
+++ b/src/main/java/de/ids_mannheim/korap/index/TermInfo.java
@@ -42,6 +42,7 @@
this.payload = payload;
};
+
public TermInfo analyze () {
if (analyzed)
return this;
@@ -78,19 +79,19 @@
ttype = 3;
break;
- case '_':
- // pos
- this.type = "pos";
- ttype = 1;
- tterm = tterm.substring(1);
- break;
+ case '_':
+ // pos
+ this.type = "pos";
+ ttype = 1;
+ tterm = tterm.substring(1);
+ break;
- case '@':
- // pos
- this.type = "attr";
- ttype = 4;
- tterm = tterm.substring(1);
- break;
+ case '@':
+ // pos
+ this.type = "attr";
+ ttype = 4;
+ tterm = tterm.substring(1);
+ break;
default:
// term
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 8af5e36..b41cd2e 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
@@ -10,10 +10,8 @@
// TODO: "contains" is necessary for a compatibility bug in Kustvakt
Pattern idRegex = Pattern.compile("^(?:match-|contains-)"
- + "(?:([^!]+?)[!\\.])?" +
- "([^!]+)-p([0-9]+)-([0-9]+)" +
- "((?:\\(-?[0-9]+\\)-?[0-9]+--?[0-9]+)*)" +
- "(?:c.+?)?$");
+ + "(?:([^!]+?)[!\\.])?" + "([^!]+)-p([0-9]+)-([0-9]+)"
+ + "((?:\\(-?[0-9]+\\)-?[0-9]+--?[0-9]+)*)" + "(?:c.+?)?$");
Pattern posRegex = Pattern.compile("\\(([0-9]+)\\)([0-9]+)-([0-9]+)");
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java
index 546efc9..9232711 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java
@@ -112,7 +112,8 @@
assertFalse(ks.hasErrors());
assertFalse(ks.hasWarnings());
assertFalse(ks.hasMessages());
- assertEquals("QueryWrapperFilter(author:/Goe:th=e/)", ks.getCollection().toString());
+ assertEquals("QueryWrapperFilter(author:/Goe:th=e/)", ks
+ .getCollection().toString());
};
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 ec38716..ae08cc4 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
@@ -28,6 +28,7 @@
ObjectMapper mapper = new ObjectMapper();
+
@Test
public void identifierExample1 () throws IOException, QueryException {
MatchIdentifier id = new MatchIdentifier("match-c1!d1-p4-20");
@@ -549,16 +550,16 @@
@Test
- public void indexFailingMatchID () throws IOException,
- QueryException {
+ public void indexFailingMatchID () throws IOException, QueryException {
KrillIndex ki = new KrillIndex();
- Match km = ki.getMatchInfo("match-PRO-DUD!PRO-DUD_KSTA-2013-01.7483-2013-01",
- "tokens", "*", "m",
- false, false);
+ Match km = ki.getMatchInfo(
+ "match-PRO-DUD!PRO-DUD_KSTA-2013-01.7483-2013-01", "tokens",
+ "*", "m", false, false);
JsonNode res = mapper.readTree(km.toJsonString());
assertEquals("730", res.at("/errors/0/0").asText());
};
+
@Test
public void indexExampleNullInfo () throws IOException, QueryException {
KrillIndex ki = new KrillIndex();
@@ -585,49 +586,36 @@
KrillIndex ki = new KrillIndex();
ki.addDoc(createAttributeFieldDoc());
ki.commit();
- Match km = ki.getMatchInfo("match-ca1!da1-p7-10",
- "tokens",
- null,
- null,
- false,
- false);
+ Match km = ki.getMatchInfo("match-ca1!da1-p7-10", "tokens", null, null,
+ false, false);
JsonNode res = mapper.readTree(km.toJsonString());
assertEquals("tokens", res.at("/field").asText());
assertTrue(res.at("/startMore").asBoolean());
assertTrue(res.at("/endMore").asBoolean());
assertEquals("ca1", res.at("/corpusID").asText());
assertEquals("da1", res.at("/docID").asText());
- assertEquals("<span class=\"context-left\">"+
- "<span class=\"more\">"+
- "</span>"+
- "</span>"+
- "<mark>"+
- // "<span title=\"@:x/s:key:value\">"+
- "<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>"+
- "</span>"+
- "<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>"+
- "<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 class=\"context-right\">"+
- "</span>", res.at("/snippet").asText());
+ assertEquals("<span class=\"context-left\">"
+ + "<span class=\"more\">"
+ + "</span>"
+ + "</span>"
+ + "<mark>"
+ +
+ // "<span title=\"@:x/s:key:value\">"+
+ "<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>" + "</span>" + "<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>" + "<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 class=\"context-right\">" + "</span>",
+ res.at("/snippet").asText());
};
@@ -714,6 +702,7 @@
return fd;
};
+
/*
Check for terms|spans|rels ...
*/
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java
index d46d930..a9d5534 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java
@@ -102,13 +102,13 @@
// cat="vb" & cat="prp" & cat="nn" & #1 .notordered #2 & #1
// .{0,2} #3 & #3 -> #2
- assertEquals(
- "spanReference(focus(#[1,2]spanSegment(focus(#2: "
- + "spanSegment(spanRelation(tokens:>:stanford/d:tag), "
- + "focus(3: spanDistance(focus(1: spanDistance({1: <tokens:vb />}, "
- + "{2: <tokens:prp />}, [(w[1:2], notOrdered, notExcluded)])), "
- + "{3: <tokens:nn />}, [(w[1:3], notOrdered, notExcluded)])))), "
- + "{2: <tokens:prp />})), 2)", sq.toString());
+ assertEquals(
+ "spanReference(focus(#[1,2]spanSegment(focus(#2: "
+ + "spanSegment(spanRelation(tokens:>:stanford/d:tag), "
+ + "focus(3: spanDistance(focus(1: spanDistance({1: <tokens:vb />}, "
+ + "{2: <tokens:prp />}, [(w[1:2], notOrdered, notExcluded)])), "
+ + "{3: <tokens:nn />}, [(w[1:3], notOrdered, notExcluded)])))), "
+ + "{2: <tokens:prp />})), 2)", sq.toString());
SpanElementQuery seq1 = new SpanElementQuery("tokens", "vb");
// new SpanTermQuery(new Term("tokens", "c:vb"));
@@ -121,11 +121,11 @@
SpanClassQuery scq3 = new SpanClassQuery(seq3, (byte) 3);
SpanDistanceQuery sdq1 = new SpanDistanceQuery(scq1, scq2,
- new DistanceConstraint(1, 2, false, false), true);
+ new DistanceConstraint(1, 2, false, false), true);
SpanFocusQuery sfq1 = new SpanFocusQuery(sdq1, (byte) 1);
SpanDistanceQuery sdq2 = new SpanDistanceQuery(sfq1, scq3,
- new DistanceConstraint(1, 3, false, false), true);
+ new DistanceConstraint(1, 3, false, false), true);
SpanFocusQuery sfq2 = new SpanFocusQuery(sdq2, (byte) 3);
// nn -> prp
@@ -198,7 +198,7 @@
"spanReference(focus(#[1,2]spanSegment(focus(#2: spanSegment(spanRelation(tokens:>:stanford/d:tag), "
+ "focus(1: spanReference(focus(#[1,2]spanSegment(focus(#2: spanSegment(spanRelation(tokens:>:stanford/d:tag), "
+ "focus(3: spanDistance(focus(1: spanDistance({1: <tokens:vb />}, {2: <tokens:prp />}, "
- + "[(w[1:2], notOrdered, notExcluded)])), {3: <tokens:nn />}, [(w[1:3], notOrdered, notExcluded)])))), "
+ + "[(w[1:2], notOrdered, notExcluded)])), {3: <tokens:nn />}, [(w[1:3], notOrdered, notExcluded)])))), "
+ "{2: <tokens:prp />})), 2)))), {3: <tokens:nn />})), 3)",
sq.toString());
kr = ki.search(sq, (short) 10);
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanReferenceQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanReferenceQueryJSON.java
index e77cfcc..a5a65b4 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanReferenceQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanReferenceQueryJSON.java
@@ -65,6 +65,7 @@
+ "{1: <tokens:c:VP />})), 1)", sq.toString());
}
+
@Test
public void testDistanceReferences () throws QueryException {
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSequenceQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSequenceQueryJSON.java
index f1306b9..8762e4f 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSequenceQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSequenceQueryJSON.java
@@ -311,18 +311,24 @@
sqwi.toQuery().toString());
};
+
@Test
public void queryJSONseqSentenceDistance () throws QueryException {
SpanQueryWrapper sqwi = jsonQueryFile("distance-sentence.jsonld");
- assertEquals("spanElementDistance({129: tokens:s:der}, {129: tokens:s:Baum}, [(base/s:s[0:0], notOrdered, notExcluded)])",sqwi.toQuery().toString());
+ assertEquals(
+ "spanElementDistance({129: tokens:s:der}, {129: tokens:s:Baum}, [(base/s:s[0:0], notOrdered, notExcluded)])",
+ sqwi.toQuery().toString());
};
+
@Test
public void queryJSONseqSentenceDistanceExcluded () throws QueryException {
SpanQueryWrapper sqwi = jsonQueryFile("distance-sentence-excluded.jsonld");
- assertEquals("spanElementDistance({129: tokens:s:der}, {129: tokens:s:Baum}, [(base/s:s[0:0], notOrdered, excluded)])",sqwi.toQuery().toString());
+ assertEquals(
+ "spanElementDistance({129: tokens:s:der}, {129: tokens:s:Baum}, [(base/s:s[0:0], notOrdered, excluded)])",
+ sqwi.toQuery().toString());
};
@@ -330,7 +336,9 @@
public void queryJSONkoralSimpleDistanceBug () throws QueryException {
SpanQueryWrapper sqwi = jsonQueryFile("distance-simple.jsonld");
- assertEquals("spanDistance(tokens:s:der, tokens:s:Baum, [(w[2:2], ordered, notExcluded)])",sqwi.toQuery().toString());
+ assertEquals(
+ "spanDistance(tokens:s:der, tokens:s:Baum, [(w[2:2], ordered, notExcluded)])",
+ sqwi.toQuery().toString());
};
diff --git a/src/test/java/de/ids_mannheim/korap/response/TestMatch.java b/src/test/java/de/ids_mannheim/korap/response/TestMatch.java
index 182300a..81cd3c3 100644
--- a/src/test/java/de/ids_mannheim/korap/response/TestMatch.java
+++ b/src/test/java/de/ids_mannheim/korap/response/TestMatch.java
@@ -17,21 +17,26 @@
assertEquals(null, m.getID());
};
+
@Test
public void testMatchBug () {
- Match m = new Match("match-PRO-DUD!PRO-DUD_KSTA-2013-01.7483-2013-01", false);
+ Match m = new Match("match-PRO-DUD!PRO-DUD_KSTA-2013-01.7483-2013-01",
+ false);
assertEquals(null, m.getID());
};
+
@Test
public void testMatchTextSigle1 () {
Match m = new Match("match-GOE!GOE_AGK.00000-p60348-60349", false);
assertEquals("GOE_AGK.00000", m.getTextSigle());
};
+
@Test
public void testMatchTextSigle2 () {
- Match m = new Match("match-PRO-DUD!PRO-DUD_KSTA-2013-01.3651-p326-327", false);
+ Match m = new Match("match-PRO-DUD!PRO-DUD_KSTA-2013-01.3651-p326-327",
+ false);
assertEquals("PRO-DUD_KSTA-2013-01.3651", m.getTextSigle());
};
};
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 2ea0760..dfca5fc 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
@@ -839,7 +839,8 @@
assertEquals(kr.getMatch(3).getSnippetBrackets(),
"Saragat-Partei zerfällt Rom ([ADN]) "
+ "die von dem Rechtssozialisten Saragat geführte ...");
- assertEquals(kr.getMatch(23).getSnippetBrackets(),
+ assertEquals(
+ kr.getMatch(23).getSnippetBrackets(),
"... dem Namen \"Einheitsbewegung der sozialistischen "
+ "Initiative\" [eine neue politische Gruppierung] "
+ "ins Leben gerufen hatten. Pressemeldungen zufolge ...");
@@ -974,7 +975,8 @@
assertEquals(0, kr.getStartIndex());
assertEquals(25, kr.getItemsPerPage());
- assertFalse(kr.getContext().toJsonNode().toString().equals("\"base/s:s\""));
+ assertFalse(kr.getContext().toJsonNode().toString()
+ .equals("\"base/s:s\""));
json = getString(getClass().getResource(
"/queries/bsp-context-sentence.jsonld").getFile());
@@ -1092,21 +1094,23 @@
assertEquals(kr.getTotalResults(), 1);
};
+
/**
- * This is a Schreibgebrauch ressource that didn't work for element queries.
+ * This is a Schreibgebrauch ressource that didn't work for
+ * element queries.
*/
@Test
public void searchSchreibgebrauchData () throws IOException {
// Construct index
KrillIndex ki = new KrillIndex();
// Indexing test files
- ki.addDoc(getClass().getResourceAsStream("/sgbr/BSP-2013-01-32.json.gz"), true);
+ ki.addDoc(getClass()
+ .getResourceAsStream("/sgbr/BSP-2013-01-32.json.gz"), true);
ki.commit();
Krill k = new Krill(new QueryBuilder("tokens").tag("base/s:s"));
- assertEquals(k.getSpanQuery().toString(),
- "<tokens:base/s:s />");
+ assertEquals(k.getSpanQuery().toString(), "<tokens:base/s:s />");
Result kr = k.apply(ki);
assertEquals(kr.getTotalResults(), 1);