Improve java compatibility by renaming _ method to nr
Change-Id: I07735272f148d67e40afe3ce2304131d7029afaf
diff --git a/Changes b/Changes
index 4e95d44..44958ab 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
-0.56.2 2018-02-07
+0.56.2 2018-02-09
- [feature] Introduce meta field retrieval method (diewald)
+ - [cleanup] Rename KrillQuery's "_"-method to "nr" to improve
+ compatibility with future versions of Java (diewald)
0.56.1 2018-01-31
- [bugfix] Changed relation serialization in snippet to work
diff --git a/src/main/java/de/ids_mannheim/korap/query/QueryBuilder.java b/src/main/java/de/ids_mannheim/korap/query/QueryBuilder.java
index f065737..da433ba 100644
--- a/src/main/java/de/ids_mannheim/korap/query/QueryBuilder.java
+++ b/src/main/java/de/ids_mannheim/korap/query/QueryBuilder.java
@@ -402,22 +402,22 @@
// Class
- public SpanClassQueryWrapper _ (byte number, SpanQueryWrapper element) {
+ public SpanClassQueryWrapper nr (byte number, SpanQueryWrapper element) {
return new SpanClassQueryWrapper(element, number);
};
- public SpanClassQueryWrapper _ (int number, SpanQueryWrapper element) {
+ public SpanClassQueryWrapper nr (int number, SpanQueryWrapper element) {
return new SpanClassQueryWrapper(element, number);
};
- public SpanClassQueryWrapper _ (short number, SpanQueryWrapper element) {
+ public SpanClassQueryWrapper nr (short number, SpanQueryWrapper element) {
return new SpanClassQueryWrapper(element, number);
};
- public SpanClassQueryWrapper _ (SpanQueryWrapper element) {
+ public SpanClassQueryWrapper nr (SpanQueryWrapper element) {
return new SpanClassQueryWrapper(element);
};
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 56cf1d3..7a5c550 100644
--- a/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
+++ b/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
@@ -44,7 +44,7 @@
QueryBuilder kq = new QueryBuilder("tokens");
Result kr = ki
- .search((SpanQuery) kq.seq(kq._(1, kq.seg("s:b"))).toQuery());
+ .search((SpanQuery) kq.seq(kq.nr(1, kq.seg("s:b"))).toQuery());
Match km = kr.getMatch(0);
assertEquals(km.getStartPos(), 1);
assertEquals(km.getEndPos(), 2);
@@ -54,8 +54,8 @@
"<span class=\"context-left\">a</span><span class=\"match\"><mark><mark class=\"class-1 level-0\">b</mark></mark></span><span class=\"context-right\">c</span>",
km.getSnippetHTML());
- kr = ki.search((SpanQuery) kq.seq(kq._(1, kq.seg("s:b")))
- .append(kq._(2, kq.seg("s:c"))).toQuery());
+ kr = ki.search((SpanQuery) kq.seq(kq.nr(1, kq.seg("s:b")))
+ .append(kq.nr(2, kq.seg("s:c"))).toQuery());
km = kr.getMatch(0);
assertEquals(km.getStartPos(), 1);
assertEquals(km.getEndPos(), 3);
@@ -69,8 +69,8 @@
kr = ki.search((SpanQuery) kq
- .seq(kq._(1, kq.seq(kq.seg("s:a")).append(kq.seg("s:b"))))
- .append(kq._(2, kq.seg("s:c"))).toQuery());
+ .seq(kq.nr(1, kq.seq(kq.seg("s:a")).append(kq.seg("s:b"))))
+ .append(kq.nr(2, kq.seg("s:c"))).toQuery());
km = kr.getMatch(0);
assertEquals(km.getStartPos(), 0);
assertEquals(km.getEndPos(), 3);
@@ -84,12 +84,12 @@
kr = ki.search(
- (SpanQuery) kq._(
+ (SpanQuery) kq.nr(
3, kq
- .seq(kq._(1,
+ .seq(kq.nr(1,
kq.seq(kq.seg("s:a"))
.append(kq.seg("s:b"))))
- .append(kq._(2, kq.seg("s:c"))))
+ .append(kq.nr(2, kq.seg("s:c"))))
.toQuery());
km = kr.getMatch(0);
assertEquals(km.getStartPos(), 0);
@@ -185,8 +185,8 @@
ki.commit();
QueryBuilder kq = new QueryBuilder("base");
- SpanQuery q = (SpanQuery) kq.or(kq._(1, kq.seg("s:a")))
- .or(kq._(2, kq.seg("s:b"))).toQuery();
+ SpanQuery q = (SpanQuery) kq.or(kq.nr(1, kq.seg("s:a")))
+ .or(kq.nr(2, kq.seg("s:b"))).toQuery();
Result kr = ki.search(q);
assertEquals((long) 14, kr.getTotalResults());
assertEquals("[[{1:a}]]bab", kr.getMatch(0).getSnippetBrackets());
@@ -209,7 +209,7 @@
assertEquals("ab[[{1:a}]]", kr.getMatch(13).getSnippetBrackets());
kq = new QueryBuilder("base");
- q = (SpanQuery) kq.or(kq._(1, kq.seg("i:a"))).or(kq._(2, kq.seg("i:c")))
+ q = (SpanQuery) kq.or(kq.nr(1, kq.seg("i:a"))).or(kq.nr(2, kq.seg("i:c")))
.toQuery();
Krill qs = new Krill(q);
qs.getMeta().getContext().left.setToken(true).setLength((short) 1);
@@ -245,7 +245,7 @@
assertEquals("... [[{2:a}]]", kr.getMatch(9).getSnippetBrackets());
q = (SpanQuery) kq
- ._(3, kq.or(kq._(1, kq.seg("i:a"))).or(kq._(2, kq.seg("i:c"))))
+ .nr(3, kq.or(kq.nr(1, kq.seg("i:a"))).or(kq.nr(2, kq.seg("i:c"))))
.toQuery();
qs = new Krill(q);
qs.getMeta().getContext().left.setToken(true).setLength((short) 0);
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 8f418ac..6fe131b 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
@@ -116,7 +116,7 @@
QueryBuilder kq = new QueryBuilder("tokens");
Result kr = ki
- .search((SpanQuery) kq.seq(kq._(3, kq.seg("s:b"))).toQuery());
+ .search((SpanQuery) kq.seq(kq.nr(3, kq.seg("s:b"))).toQuery());
Match km = kr.getMatch(0);
@@ -157,7 +157,7 @@
// Start creating query
// within(<s>, {1: {2: [mate/p=ADJA & mate/m=number:sg]}[opennlp/p=NN & tt/p=NN]})
- ks = new Krill(kq.within(kq.tag("base/s:s"), kq._(1,
+ ks = new Krill(kq.within(kq.tag("base/s:s"), kq.nr(1,
kq.seq(kq.seg("mate/p:ADJA")).append(kq.seg("opennlp/p:NN")))));
KrillMeta meta = ks.getMeta();
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 f74efd8..135c1f9 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
@@ -135,7 +135,7 @@
QueryBuilder kq = new QueryBuilder("tokens");
Krill ks = new Krill(
- kq._(2, kq.seq(kq.seg("s:b")).append(kq._(kq.seg("s:a")))));
+ kq.nr(2, kq.seq(kq.seg("s:b")).append(kq.nr(kq.seg("s:a")))));
Result kr = ki.search(ks);
assertEquals("totalResults", kr.getTotalResults(), 1);
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 932d448..756da3f 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
@@ -326,8 +326,8 @@
QueryBuilder kq = new QueryBuilder("base");
- SpanQuery sq = kq._(1, kq.seq(kq.seg("s:b")).append(kq.seg("s:a"))
- .append(kq._(2, kq.seg("s:c")))).toQuery();
+ SpanQuery sq = kq.nr(1, kq.seq(kq.seg("s:b")).append(kq.seg("s:a"))
+ .append(kq.nr(2, kq.seg("s:c")))).toQuery();
kr = ki.search(sq, 0, (short) 20, true, (short) 2, true, (short) 5);
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
index 47a6117..3d22662 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
@@ -42,7 +42,7 @@
QueryBuilder kq = new QueryBuilder("tokens");
ks = new Krill(kq
.within(kq.tag("base/s:s"),
- kq.seq(kq.re("s:.*")).append(kq._(kq.re("s:.*"))))
+ kq.seq(kq.re("s:.*")).append(kq.nr(kq.re("s:.*"))))
.toQuery());
ks.getMeta().setTimeOut(10000);
kr = ks.apply(ki);
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 f6e9f17..30a6e10 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
@@ -364,7 +364,7 @@
assertEquals((long) 0, kr.getTotalResults());
// Test with classes
- sq = kq._(kq.re("s:z.*e")).toQuery();
+ sq = kq.nr(kq.re("s:z.*e")).toQuery();
assertEquals(
"{1: SpanMultiTermQueryWrapper(base:/s:z.*e/)}",
sq.toString());
@@ -372,7 +372,7 @@
assertEquals((long) 0, kr.getTotalResults());
// Test with nested classes
- sq = kq.within(kq._(kq.re("s:z.*e")), kq.seg("s:affe")).toQuery();
+ sq = kq.within(kq.nr(kq.re("s:z.*e")), kq.seg("s:affe")).toQuery();
assertEquals(
"spanContain({1: SpanMultiTermQueryWrapper(base:/s:z.*e/)}, base:s:affe)",
sq.toString());
@@ -417,7 +417,7 @@
// Test with multiple distances and a class
sq = new SpanMultipleDistanceQuery(
- kq._(kq.re("s:z.*e")).toQuery(),
+ kq.nr(kq.re("s:z.*e")).toQuery(),
kq.seg("s:affe").toQuery(),
constraints,
true,
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKrillQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestKrillQuery.java
index 101290d..cb4c5b6 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKrillQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKrillQuery.java
@@ -140,7 +140,7 @@
public void KorapClassQuery () throws QueryException {
QueryBuilder kq = new QueryBuilder("field");
SpanQuery sq = kq.seq(kq.seg("tree"),
- kq._(1, kq.contains(kq.tag("s"), kq.tag("np"))), kq.re("hey.*"))
+ kq.nr(1, kq.contains(kq.tag("s"), kq.tag("np"))), kq.re("hey.*"))
.toQuery();
assertEquals(
"spanNext(spanNext(field:tree, {1: spanContain(<field:s />, <field:np />)}), SpanMultiTermQueryWrapper(field:/hey.*/))",
@@ -151,7 +151,7 @@
@Test
public void KorapClassQuery2 () throws QueryException {
QueryBuilder kq = new QueryBuilder("field");
- SpanQuery sq = kq._(kq.seg("base:test")).toQuery();
+ SpanQuery sq = kq.nr(kq.seg("base:test")).toQuery();
assertEquals("{1: field:base:test}", sq.toString());
};
@@ -160,7 +160,7 @@
public void KorapClassQuery3 () throws QueryException {
QueryBuilder kq = new QueryBuilder("field");
SpanQuery sq = kq.seq(kq.seg("tree"),
- kq.contains(kq.tag("s"), kq._(kq.tag("np"))), kq.re("hey.*"))
+ kq.contains(kq.tag("s"), kq.nr(kq.tag("np"))), kq.re("hey.*"))
.toQuery();
assertEquals(
"spanNext(spanNext(field:tree, spanContain(<field:s />, {1: <field:np />})), SpanMultiTermQueryWrapper(field:/hey.*/))",
@@ -187,7 +187,7 @@
@Test
public void KorapShrinkQuery2 () throws QueryException {
QueryBuilder kq = new QueryBuilder("field");
- SpanQuery sq = kq.focus(1, kq._(1, kq.tag("np"))).toQuery();
+ SpanQuery sq = kq.focus(1, kq.nr(1, kq.tag("np"))).toQuery();
assertEquals("focus(1: {1: <field:np />})", sq.toString());
};
@@ -195,8 +195,8 @@
@Test
public void KorapShrinkQuery3 () throws QueryException {
QueryBuilder kq = new QueryBuilder("field");
- SpanQuery sq = kq.focus(1, kq._(1,
- kq.seq(kq.tag("np"), kq._(kq.seg("test").without("no")))))
+ SpanQuery sq = kq.focus(1, kq.nr(1,
+ kq.seq(kq.tag("np"), kq.nr(kq.seg("test").without("no")))))
.toQuery();
assertEquals(
"focus(1: {1: spanNext(<field:np />, {1: spanNot(field:test, field:no, 0, 0)})})",
@@ -208,7 +208,7 @@
public void KorapShrinkQuery4 () throws QueryException {
QueryBuilder kq = new QueryBuilder("field");
SpanQuery sq = kq.seq(kq.seg("try1"),
- kq.focus(1, kq._(1, kq.seg("try2"))), kq.seg("try3")).toQuery();
+ kq.focus(1, kq.nr(1, kq.seg("try2"))), kq.seg("try3")).toQuery();
assertEquals(
"spanNext(spanNext(field:try1, focus(1: {1: field:try2})), field:try3)",
sq.toString());
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 3c4c475..a8b7eaa 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
@@ -740,7 +740,7 @@
QueryBuilder kq = new QueryBuilder("tokens");
Krill ks = new Krill(kq.focus(1,
- kq.contains(kq.tag("base/s:s"), kq._(1, kq.seg("s:Leben")))));
+ kq.contains(kq.tag("base/s:s"), kq.nr(1, kq.seg("s:Leben")))));
Result kr = ks.apply(ki);
assertEquals(kr.getSerialQuery(),
@@ -754,7 +754,7 @@
// Try with high class - don't highlight
ks = new Krill(kq.focus(129,
- kq.contains(kq.tag("base/s:s"), kq._(129, kq.seg("s:Leben")))));
+ kq.contains(kq.tag("base/s:s"), kq.nr(129, kq.seg("s:Leben")))));
kr = ks.apply(ki);
assertEquals(kr.getSerialQuery(),
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestResult.java b/src/test/java/de/ids_mannheim/korap/search/TestResult.java
index 7e1442f..7fa390f 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestResult.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestResult.java
@@ -51,8 +51,8 @@
ki.commit();
QueryBuilder kq = new QueryBuilder("base");
- SpanQuery q = (SpanQuery) kq.or(kq._(1, kq.seg("s:a")))
- .or(kq._(2, kq.seg("s:b"))).toQuery();
+ SpanQuery q = (SpanQuery) kq.or(kq.nr(1, kq.seg("s:a")))
+ .or(kq.nr(2, kq.seg("s:b"))).toQuery();
Result kr = ki.search(q);
assertEquals((long) 7, kr.getTotalResults());