Renamed analysis to /model and shrink() to focus()
diff --git a/Changes b/Changes
index 9f310c4..27c7e07 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.49.4 2015-02-05
+0.49.4 2015-02-06
- [documentation] Improved documentation for API classes,
improved test coverage for utility classes (diewald)
- [performance] Updated Lucene dependency from 4.5.1 to 4.10.3,
@@ -11,7 +11,9 @@
MatchModifyClassSpans no longer rely on payload copies (diewald)
- [cleanup] Renamed /filter to /collection,
merge KorapHTML and KorapString,
- removed KorapSpan, KorapTermSpan and KorapLongSpan (diewald)
+ removed KorapSpan, KorapTermSpan and KorapLongSpan,
+ renamed /analysis to /model,
+ renamed shrink() to focus() (diewald)
0.49.3 2015-02-03
- [documentation] Improved documentation for API classes (diewald)
diff --git a/src/main/java/de/ids_mannheim/korap/KorapQuery.java b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
index 8747413..78d050b 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
@@ -1303,19 +1303,19 @@
};
// MatchModify
- public SpanMatchModifyQueryWrapper shrink (byte number, SpanQueryWrapper element) {
+ public SpanMatchModifyQueryWrapper focus (byte number, SpanQueryWrapper element) {
return new SpanMatchModifyQueryWrapper(element, number);
};
- public SpanMatchModifyQueryWrapper shrink (int number, SpanQueryWrapper element) {
+ public SpanMatchModifyQueryWrapper focus (int number, SpanQueryWrapper element) {
return new SpanMatchModifyQueryWrapper(element, number);
};
- public SpanMatchModifyQueryWrapper shrink (short number, SpanQueryWrapper element) {
+ public SpanMatchModifyQueryWrapper focus (short number, SpanQueryWrapper element) {
return new SpanMatchModifyQueryWrapper(element, number);
};
- public SpanMatchModifyQueryWrapper shrink (SpanQueryWrapper element) {
+ public SpanMatchModifyQueryWrapper focus (SpanQueryWrapper element) {
return new SpanMatchModifyQueryWrapper(element);
};
diff --git a/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java b/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
index 4b7b9f8..c0815ec 100644
--- a/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
+++ b/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
@@ -1,8 +1,8 @@
package de.ids_mannheim.korap.index;
import org.apache.lucene.document.Document;
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
-import de.ids_mannheim.korap.analysis.MultiTermToken;
+import de.ids_mannheim.korap.model.MultiTermTokenStream;
+import de.ids_mannheim.korap.model.MultiTermToken;
import de.ids_mannheim.korap.KorapDocument;
import de.ids_mannheim.korap.util.KorapDate;
diff --git a/src/main/java/de/ids_mannheim/korap/analysis/MultiTerm.java b/src/main/java/de/ids_mannheim/korap/model/MultiTerm.java
similarity index 99%
rename from src/main/java/de/ids_mannheim/korap/analysis/MultiTerm.java
rename to src/main/java/de/ids_mannheim/korap/model/MultiTerm.java
index 754268d..3ba5748 100644
--- a/src/main/java/de/ids_mannheim/korap/analysis/MultiTerm.java
+++ b/src/main/java/de/ids_mannheim/korap/model/MultiTerm.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.analysis;
+package de.ids_mannheim.korap.model;
import static de.ids_mannheim.korap.util.KorapArray.*;
import org.apache.lucene.util.BytesRef;
diff --git a/src/main/java/de/ids_mannheim/korap/analysis/MultiTermToken.java b/src/main/java/de/ids_mannheim/korap/model/MultiTermToken.java
similarity index 98%
rename from src/main/java/de/ids_mannheim/korap/analysis/MultiTermToken.java
rename to src/main/java/de/ids_mannheim/korap/model/MultiTermToken.java
index f923ef7..21e106f 100644
--- a/src/main/java/de/ids_mannheim/korap/analysis/MultiTermToken.java
+++ b/src/main/java/de/ids_mannheim/korap/model/MultiTermToken.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.analysis;
+package de.ids_mannheim.korap.model;
import java.util.*;
diff --git a/src/main/java/de/ids_mannheim/korap/analysis/MultiTermTokenStream.java b/src/main/java/de/ids_mannheim/korap/model/MultiTermTokenStream.java
similarity index 99%
rename from src/main/java/de/ids_mannheim/korap/analysis/MultiTermTokenStream.java
rename to src/main/java/de/ids_mannheim/korap/model/MultiTermTokenStream.java
index d53aac2..9ebb11b 100644
--- a/src/main/java/de/ids_mannheim/korap/analysis/MultiTermTokenStream.java
+++ b/src/main/java/de/ids_mannheim/korap/model/MultiTermTokenStream.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.analysis;
+package de.ids_mannheim.korap.model;
import static de.ids_mannheim.korap.util.KorapByte.*;
import org.apache.lucene.util.BytesRef;
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanMatchModifyClassQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanMatchModifyClassQuery.java
index 1f3d3f6..59a271a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanMatchModifyClassQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanMatchModifyClassQuery.java
@@ -19,88 +19,120 @@
import de.ids_mannheim.korap.query.SpanClassQuery;
/**
- * Shrinks spans to a classed span.
+ * Modify the span of a match to the boundaries of a certain class.
+ *
+ * In case multiple classes are found with the very same number, the span
+ * is maximized to start on the first occurrence from the left and end on
+ * the last occurrence on the right.
+ *
+ * In case the class to modify on is not found in the subquery,
+ * the match is ignored.
+ *
+ * @author diewald
+ *
+ * @see MatchModifyClassSpans
*/
public class SpanMatchModifyClassQuery extends SpanClassQuery {
+ /**
+ * Construct a new SpanMatchModifyClassQuery.
+ *
+ * @param operand The nested {@link SpanQuery}, that contains one or
+ * more classed spans.
+ * @param number The class number to focus on.
+ */
public SpanMatchModifyClassQuery (SpanQuery operand, byte number) {
- super(operand, number);
+ super(operand, number);
};
+
+ /**
+ * Construct a new SpanMatchModifyClassQuery.
+ * The class to focus on defaults to <tt>1</tt>.
+ *
+ * @param operand The nested {@link SpanQuery}, that contains one or
+ * more classed spans.
+ */
public SpanMatchModifyClassQuery (SpanQuery operand) {
- this(operand, (byte) 1);
+ this(operand, (byte) 1);
};
+
@Override
public String toString (String field) {
- StringBuffer buffer = new StringBuffer();
- buffer.append("shrink(");
- short classNr = (short) this.number;
- buffer.append(classNr & 0xFF).append(": ");
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("focus(");
+ short classNr = (short) this.number;
+ buffer.append(classNr & 0xFF).append(": ");
buffer.append(this.operand.toString());
- buffer.append(')');
-
- buffer.append(ToStringUtils.boost(getBoost()));
- return buffer.toString();
+ buffer.append(')');
+ buffer.append(ToStringUtils.boost(getBoost()));
+ return buffer.toString();
};
+
@Override
- public Spans getSpans (final AtomicReaderContext context, Bits acceptDocs, Map<Term,TermContext> termContexts) throws IOException {
- return (Spans) new MatchModifyClassSpans(this.operand, context, acceptDocs, termContexts, number);
+ public Spans getSpans (final AtomicReaderContext context,
+ Bits acceptDocs,
+ Map<Term,TermContext> termContexts) throws IOException {
+ return (Spans) new MatchModifyClassSpans(
+ this.operand,
+ context,
+ acceptDocs,
+ termContexts,
+ number
+ );
};
+
@Override
public Query rewrite (IndexReader reader) throws IOException {
- SpanMatchModifyClassQuery clone = null;
- SpanQuery query = (SpanQuery) this.operand.rewrite(reader);
+ SpanMatchModifyClassQuery clone = null;
+ SpanQuery query = (SpanQuery) this.operand.rewrite(reader);
+
+ if (query != this.operand) {
+ if (clone == null)
+ clone = this.clone();
+ clone.operand = query;
+ };
- if (query != this.operand) {
- if (clone == null)
- clone = this.clone();
- clone.operand = query;
- };
+ if (clone != null)
+ return clone;
- if (clone != null)
- return clone;
-
- return this;
+ return this;
};
+
@Override
public SpanMatchModifyClassQuery clone() {
- SpanMatchModifyClassQuery spanMatchQuery = new SpanMatchModifyClassQuery(
- (SpanQuery) this.operand.clone(),
- this.number
+ SpanMatchModifyClassQuery spanMatchQuery = new SpanMatchModifyClassQuery(
+ (SpanQuery) this.operand.clone(),
+ this.number
);
- spanMatchQuery.setBoost(getBoost());
- return spanMatchQuery;
+ spanMatchQuery.setBoost(getBoost());
+ return spanMatchQuery;
};
- /** Returns true iff <code>o</code> is equal to this. */
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof SpanMatchModifyClassQuery)) return false;
+ public boolean equals (Object o) {
+ if (this == o) return true;
+ if (!(o instanceof SpanMatchModifyClassQuery)) return false;
- final SpanMatchModifyClassQuery spanMatchModifyClassQuery = (SpanMatchModifyClassQuery) o;
+ final SpanMatchModifyClassQuery spanMatchModifyClassQuery =
+ (SpanMatchModifyClassQuery) o;
- if (!this.operand.equals(spanMatchModifyClassQuery.operand)) return false;
- if (this.number != spanMatchModifyClassQuery.number) return false;
- // if (this.divide != spanMatchModifyClassQuery.divide) return false;
- return getBoost() == spanMatchModifyClassQuery.getBoost();
+ if (!this.operand.equals(spanMatchModifyClassQuery.operand)) return false;
+ if (this.number != spanMatchModifyClassQuery.number) return false;
+ return getBoost() == spanMatchModifyClassQuery.getBoost();
};
- // I don't know what I am doing here
@Override
public int hashCode() {
- int result = 1;
- result = operand.hashCode();
- result += number + 33_333;
- // result += divide ? 1 : 0;
- result ^= (result << 15) | (result >>> 18);
- result += Float.floatToRawIntBits(getBoost());
- return result;
+ int result = operand.hashCode();
+ result = 31 * result + number;
+ result += Float.floatToRawIntBits(getBoost());
+ return result;
};
};
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/MatchModifyClassSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/MatchModifyClassSpans.java
index a9f196a..9a1da9f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/MatchModifyClassSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/MatchModifyClassSpans.java
@@ -32,7 +32,8 @@
* In case the class to focus on is not found in the payloads,
* the match is ignored.
*
- * <strong>Warning</strong>: Payloads other than class payloads won't bubble up.
+ * <strong>Warning</strong>: Payloads other than class payloads won't
+ * bubble up currently. That behaviour may change in the future
*
* @author diewald
*/
diff --git a/src/test/java/de/ids_mannheim/korap/Test.java b/src/test/java/de/ids_mannheim/korap/Test.java
index 0e8d68b..e8837f3 100644
--- a/src/test/java/de/ids_mannheim/korap/Test.java
+++ b/src/test/java/de/ids_mannheim/korap/Test.java
@@ -3,8 +3,8 @@
import java.util.*;
import java.io.IOException;
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
-import de.ids_mannheim.korap.analysis.MultiTermToken;
+import de.ids_mannheim.korap.model.MultiTermTokenStream;
+import de.ids_mannheim.korap.model.MultiTermToken;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.TextField;
diff --git a/src/test/java/de/ids_mannheim/korap/TestSimple.java b/src/test/java/de/ids_mannheim/korap/TestSimple.java
index ecea801..1dd85f3 100644
--- a/src/test/java/de/ids_mannheim/korap/TestSimple.java
+++ b/src/test/java/de/ids_mannheim/korap/TestSimple.java
@@ -6,7 +6,7 @@
import static org.junit.Assert.*;
import de.ids_mannheim.korap.KorapQuery;
-import de.ids_mannheim.korap.analysis.*;
+import de.ids_mannheim.korap.model.*;
import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
import de.ids_mannheim.korap.util.QueryException;
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
index ba1dd54..df4c8ae 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
@@ -21,7 +21,7 @@
import de.ids_mannheim.korap.query.SpanElementQuery;
import de.ids_mannheim.korap.query.SpanWithinQuery;
import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
+import de.ids_mannheim.korap.model.MultiTermTokenStream;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java
index 3f14ab3..6d203e9 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java
@@ -18,7 +18,7 @@
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.query.SpanElementQuery;
import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
+import de.ids_mannheim.korap.model.MultiTermTokenStream;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.index.Term;
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 20ea4be..9e0318e 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
@@ -26,7 +26,7 @@
import de.ids_mannheim.korap.query.SpanMatchModifyClassQuery;
import de.ids_mannheim.korap.query.SpanClassQuery;
import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
+import de.ids_mannheim.korap.model.MultiTermTokenStream;
import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestIndex.java
index 42d18ed..94b7e8b 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestIndex.java
@@ -3,7 +3,7 @@
import java.util.*;
import java.io.*;
-import de.ids_mannheim.korap.analysis.MultiTermToken;
+import de.ids_mannheim.korap.model.MultiTermToken;
import de.ids_mannheim.korap.query.wrap.SpanSegmentQueryWrapper;
import de.ids_mannheim.korap.query.wrap.SpanRegexQueryWrapper;
import de.ids_mannheim.korap.query.wrap.SpanSequenceQueryWrapper;
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestKorapIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestKorapIndex.java
index ef3a3f8..417a8b4 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestKorapIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestKorapIndex.java
@@ -16,7 +16,7 @@
import de.ids_mannheim.korap.KorapIndex;
import de.ids_mannheim.korap.KorapQuery;
import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
+import de.ids_mannheim.korap.model.MultiTermTokenStream;
@RunWith(JUnit4.class)
public class TestKorapIndex {
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 f61254b..2a733da 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchCollector.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchCollector.java
@@ -23,7 +23,7 @@
import de.ids_mannheim.korap.query.SpanMatchModifyClassQuery;
import de.ids_mannheim.korap.query.SpanClassQuery;
import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
+import de.ids_mannheim.korap.model.MultiTermTokenStream;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanOrQuery;
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 5894963..59c8fce 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
@@ -23,7 +23,7 @@
import de.ids_mannheim.korap.query.SpanMatchModifyClassQuery;
import de.ids_mannheim.korap.query.SpanClassQuery;
import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
+import de.ids_mannheim.korap.model.MultiTermTokenStream;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanOrQuery;
@@ -32,7 +32,7 @@
// mvn -Dtest=TestWithinIndex#indexExample1 test
-// match is shrink and split
+// match is focus and split
@RunWith(JUnit4.class)
public class TestMatchIndex {
@@ -366,7 +366,7 @@
@Test
- public void indexExampleShrinkWithSpan () throws IOException {
+ public void indexExampleFocusWithSpan () throws IOException {
KorapIndex ki = new KorapIndex();
// abcabcabac
@@ -407,7 +407,7 @@
);
kr = ki.search(sq, (short) 10);
- assertEquals(kr.getQuery(), "shrink(3: spanContain({2: <base:s />}, {3: base:s:b}))");
+ assertEquals(kr.getQuery(), "focus(3: spanContain({2: <base:s />}, {3: base:s:b}))");
assertEquals(kr.getMatch(0).getSnippetBrackets(), "a[{3:b}]cabcab ...");
};
};
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 00fa232..b4e22b6 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
@@ -20,7 +20,7 @@
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.query.SpanNextQuery;
import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
+import de.ids_mannheim.korap.model.MultiTermTokenStream;
import org.apache.lucene.search.spans.SpanOrQuery;
import org.apache.lucene.search.spans.SpanQuery;
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java b/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java
index f096877..33fbf10 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java
@@ -17,7 +17,7 @@
import de.ids_mannheim.korap.query.SpanNextQuery;
import de.ids_mannheim.korap.query.SpanClassQuery;
import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
+import de.ids_mannheim.korap.model.MultiTermTokenStream;
import de.ids_mannheim.korap.index.PositionsToOffset;
import org.apache.lucene.index.AtomicReaderContext;
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 04c7913..ef34315 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
@@ -18,7 +18,7 @@
import de.ids_mannheim.korap.KorapResult;
import de.ids_mannheim.korap.KorapSearch;
import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
+import de.ids_mannheim.korap.model.MultiTermTokenStream;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
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 bf86f29..6b38784 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
@@ -25,7 +25,7 @@
import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
import de.ids_mannheim.korap.util.QueryException;
import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
+import de.ids_mannheim.korap.model.MultiTermTokenStream;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.index.Term;
diff --git a/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTerm.java b/src/test/java/de/ids_mannheim/korap/model/TestMultiTerm.java
similarity index 97%
rename from src/test/java/de/ids_mannheim/korap/analysis/TestMultiTerm.java
rename to src/test/java/de/ids_mannheim/korap/model/TestMultiTerm.java
index b568fbe..8ee1bd4 100644
--- a/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTerm.java
+++ b/src/test/java/de/ids_mannheim/korap/model/TestMultiTerm.java
@@ -1,7 +1,7 @@
-package de.ids_mannheim.korap.analysis;
+package de.ids_mannheim.korap.model;
import java.util.*;
-import de.ids_mannheim.korap.analysis.MultiTerm;
+import de.ids_mannheim.korap.model.MultiTerm;
import java.io.IOException;
import org.apache.lucene.util.BytesRef;
diff --git a/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermToken.java b/src/test/java/de/ids_mannheim/korap/model/TestMultiTermToken.java
similarity index 93%
rename from src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermToken.java
rename to src/test/java/de/ids_mannheim/korap/model/TestMultiTermToken.java
index 9d46025..3e301ee 100644
--- a/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermToken.java
+++ b/src/test/java/de/ids_mannheim/korap/model/TestMultiTermToken.java
@@ -1,7 +1,7 @@
-package de.ids_mannheim.korap.analysis;
+package de.ids_mannheim.korap.model;
import java.util.*;
-import de.ids_mannheim.korap.analysis.MultiTermToken;
+import de.ids_mannheim.korap.model.MultiTermToken;
import java.io.IOException;
import org.apache.lucene.util.BytesRef;
diff --git a/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermTokenStream.java b/src/test/java/de/ids_mannheim/korap/model/TestMultiTermTokenStream.java
similarity index 95%
rename from src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermTokenStream.java
rename to src/test/java/de/ids_mannheim/korap/model/TestMultiTermTokenStream.java
index feade6f..f1e3597 100644
--- a/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermTokenStream.java
+++ b/src/test/java/de/ids_mannheim/korap/model/TestMultiTermTokenStream.java
Binary files differ
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKorapQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestKorapQuery.java
index 5720aa2..4db4c0e 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQuery.java
@@ -129,36 +129,36 @@
@Test
public void KorapShrinkQuery () throws QueryException {
KorapQuery kq = new KorapQuery("field");
- SpanQuery sq = kq.shrink(kq.tag("np")).toQuery();
- assertEquals("shrink(1: <field:np />)", sq.toString());
+ SpanQuery sq = kq.focus(kq.tag("np")).toQuery();
+ assertEquals("focus(1: <field:np />)", sq.toString());
};
@Test
public void KorapShrinkQuery1 () throws QueryException {
KorapQuery kq = new KorapQuery("field");
- SpanQuery sq = kq.shrink(1, kq.tag("np")).toQuery();
- assertEquals("shrink(1: <field:np />)", sq.toString());
+ SpanQuery sq = kq.focus(1, kq.tag("np")).toQuery();
+ assertEquals("focus(1: <field:np />)", sq.toString());
};
@Test
public void KorapShrinkQuery2 () throws QueryException {
KorapQuery kq = new KorapQuery("field");
- SpanQuery sq = kq.shrink(1, kq._(1, kq.tag("np"))).toQuery();
- assertEquals("shrink(1: {1: <field:np />})", sq.toString());
+ SpanQuery sq = kq.focus(1, kq._(1, kq.tag("np"))).toQuery();
+ assertEquals("focus(1: {1: <field:np />})", sq.toString());
};
@Test
public void KorapShrinkQuery3 () throws QueryException {
KorapQuery kq = new KorapQuery("field");
- SpanQuery sq = kq.shrink(1, kq._(1, kq.seq(kq.tag("np"), kq._(kq.seg("test").without("no"))))).toQuery();
- assertEquals("shrink(1: {1: spanNext(<field:np />, {1: spanNot(field:test, field:no, 0, 0)})})", sq.toString());
+ SpanQuery sq = kq.focus(1, kq._(1, kq.seq(kq.tag("np"), kq._(kq.seg("test").without("no"))))).toQuery();
+ assertEquals("focus(1: {1: spanNext(<field:np />, {1: spanNot(field:test, field:no, 0, 0)})})", sq.toString());
};
@Test
public void KorapShrinkQuery4 () throws QueryException {
KorapQuery kq = new KorapQuery("field");
- SpanQuery sq = kq.seq(kq.seg("try1"), kq.shrink(1, kq._(1, kq.seg("try2"))), kq.seg("try3")).toQuery();
- assertEquals("spanNext(spanNext(field:try1, shrink(1: {1: field:try2})), field:try3)", sq.toString());
+ SpanQuery sq = kq.seq(kq.seg("try1"), kq.focus(1, kq._(1, kq.seg("try2"))), kq.seg("try3")).toQuery();
+ assertEquals("spanNext(spanNext(field:try1, focus(1: {1: field:try2})), field:try3)", sq.toString());
};
@Test
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
index 0a75172..4478375 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
@@ -51,24 +51,24 @@
public void queryJSONBsp3 () throws QueryException {
SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp3.jsonld").getFile());
- // shrink({[base=Mann]})
- assertEquals(sqwi.toQuery().toString(), "shrink(1: {1: tokens:mate/l:Mann})");
+ // focus({[base=Mann]})
+ assertEquals(sqwi.toQuery().toString(), "focus(1: {1: tokens:mate/l:Mann})");
};
@Test
public void queryJSONBsp4 () throws QueryException {
SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp4.jsonld").getFile());
- // shrink({[base=foo]}[orth=bar])
- assertEquals(sqwi.toQuery().toString(), "shrink(1: spanNext({1: tokens:mate/l:foo}, tokens:s:bar))");
+ // focus({[base=foo]}[orth=bar])
+ assertEquals(sqwi.toQuery().toString(), "focus(1: spanNext({1: tokens:mate/l:foo}, tokens:s:bar))");
};
@Test
public void queryJSONBsp5 () throws QueryException {
SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp5.jsonld").getFile());
- // shrink(1:[base=Der]{1:[base=Mann]})
- assertEquals(sqwi.toQuery().toString(), "shrink(1: spanNext(tokens:mate/l:Der, {1: tokens:mate/l:Mann}))");
+ // focus(1:[base=Der]{1:[base=Mann]})
+ assertEquals(sqwi.toQuery().toString(), "focus(1: spanNext(tokens:mate/l:Der, {1: tokens:mate/l:Mann}))");
};
@Test
@@ -242,7 +242,7 @@
SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/cosmas16.json").getFile());
// "$wegen #IN(L) <s>"
- assertEquals(sqwi.toQuery().toString(), "shrink(1: spanStartsWith(<tokens:s />, {1: tokens:i:wegen}))");
+ assertEquals(sqwi.toQuery().toString(), "focus(1: spanStartsWith(<tokens:s />, {1: tokens:i:wegen}))");
};
@Test
@@ -258,7 +258,7 @@
SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/cosmas20.json").getFile());
// "MORPH(V) #IN(R) #ELEM(S)"
- assertEquals(sqwi.toQuery().toString(), "shrink(1: spanEndsWith(<tokens:s />, {1: tokens:p:V}))");
+ assertEquals(sqwi.toQuery().toString(), "focus(1: spanEndsWith(<tokens:s />, {1: tokens:p:V}))");
};
@Test
@@ -282,7 +282,7 @@
SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bugs/cosmas_boundary.jsonld").getFile());
// Namen /s1 Leben
- assertEquals(sqwi.toQuery().toString(), "shrink(129: spanElementDistance({129: tokens:s:Namen}, {129: tokens:s:Leben}, [(base/s:s[0:1], notOrdered, notExcluded)]))");
+ assertEquals(sqwi.toQuery().toString(), "focus(129: spanElementDistance({129: tokens:s:Namen}, {129: tokens:s:Leben}, [(base/s:s[0:1], notOrdered, notExcluded)]))");
};
@Test
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java
index 342a90f..1fd3093 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java
@@ -48,7 +48,7 @@
.getFile();
SpanQueryWrapper sqwi = getJSONQuery(filepath);
SpanQuery sq = sqwi.toQuery();
- assertEquals(sq.toString(), "shrink(129: spanElementDistance({129: tokens:s:der},"+
+ assertEquals(sq.toString(), "focus(129: spanElementDistance({129: tokens:s:der},"+
" {129: subspan(<tokens:s />,0,1)}, [(s[0:0], ordered, notExcluded)]))");
}
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 afa8bab..33a776a 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
@@ -54,7 +54,7 @@
KorapSearch ks = new KorapSearch(json);
KorapResult kr = ks.run(ki);
- assertEquals(kr.getQuery(),"shrink(130: {131: spanContain({129: <tokens:s />}, {130: tokens:s:wegen})})");
+ assertEquals(kr.getQuery(),"focus(130: {131: spanContain({129: <tokens:s />}, {130: tokens:s:wegen})})");
assertEquals(kr.getTotalResults(),0);
assertEquals(kr.getStartIndex(),0);
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
index a4bbf12..e1aae5e 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
@@ -725,7 +725,7 @@
KorapQuery kq = new KorapQuery("tokens");
KorapSearch ks = new KorapSearch(
- kq.shrink(
+ kq.focus(
1,
kq.contains(kq.tag("base/s:s"), kq._(1, kq.seg("s:Leben")))
)
@@ -734,7 +734,7 @@
KorapResult kr = ks.run(ki);
assertEquals(
kr.getQuery(),
- "shrink(1: spanContain(<tokens:base/s:s />, {1: tokens:s:Leben}))"
+ "focus(1: spanContain(<tokens:base/s:s />, {1: tokens:s:Leben}))"
);
assertEquals(
kr.getMatch(0).getSnippetBrackets(),
@@ -744,7 +744,7 @@
// Try with high class - don't highlight
ks = new KorapSearch(
- kq.shrink(
+ kq.focus(
129,
kq.contains(kq.tag("base/s:s"), kq._(129, kq.seg("s:Leben")))
)
@@ -753,7 +753,7 @@
kr = ks.run(ki);
assertEquals(
kr.getQuery(),
- "shrink(129: spanContain(<tokens:base/s:s />, {129: tokens:s:Leben}))"
+ "focus(129: spanContain(<tokens:base/s:s />, {129: tokens:s:Leben}))"
);
assertEquals(
kr.getMatch(0).getSnippetBrackets(),
@@ -765,7 +765,7 @@
kr = ks.run(ki);
assertEquals(
kr.getQuery(),
- "shrink(129: spanElementDistance({129: tokens:s:Namen}, " +
+ "focus(129: spanElementDistance({129: tokens:s:Namen}, " +
"{129: tokens:s:Leben}, [(base/s:s[0:1], notOrdered, notExcluded)]))"
);
assertEquals(
diff --git a/src/test/java/de/ids_mannheim/korap/util/TestKorapByte.java b/src/test/java/de/ids_mannheim/korap/util/TestKorapByte.java
index e106699..598496b 100644
--- a/src/test/java/de/ids_mannheim/korap/util/TestKorapByte.java
+++ b/src/test/java/de/ids_mannheim/korap/util/TestKorapByte.java
@@ -29,5 +29,11 @@
assertEquals(1024, byte2int(int2byte(1024)));
assertEquals(66_666, byte2int(int2byte(66_666)));
assertEquals(66_666, byte2int(int2byte(66_666)), 0);
+
+ byte[] bb = ByteBuffer.allocate(12).putInt(99999).putInt(666).putInt(1234).array();
+
+ assertEquals(99999, byte2int(bb,0));
+ assertEquals(666, byte2int(bb,4));
+ assertEquals(1234, byte2int(bb,8));
};
};