Started adapting tests to new Collection API
Change-Id: I6dcf7ecbdc4404f65628e1038cf234ae32d1b070
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestCollectionBuilder.java b/src/test/java/de/ids_mannheim/korap/collection/TestCollectionBuilderLegacy.java
similarity index 91%
rename from src/test/java/de/ids_mannheim/korap/collection/TestCollectionBuilder.java
rename to src/test/java/de/ids_mannheim/korap/collection/TestCollectionBuilderLegacy.java
index 417de65..b8f0019 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestCollectionBuilder.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestCollectionBuilderLegacy.java
@@ -13,14 +13,14 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import de.ids_mannheim.korap.collection.CollectionBuilder;
+import de.ids_mannheim.korap.collection.CollectionBuilderLegacy;
@RunWith(JUnit4.class)
-public class TestCollectionBuilder {
+public class TestCollectionBuilderLegacy {
@Test
public void filterExample () throws IOException {
- CollectionBuilder kf = new CollectionBuilder();
+ CollectionBuilderLegacy kf = new CollectionBuilderLegacy();
assertEquals("+textClass:tree", kf.and("textClass", "tree").toString());
assertEquals("+textClass:tree +textClass:sport",
@@ -40,7 +40,7 @@
@Test
public void rangeExample () throws IOException {
- CollectionBuilder kf = new CollectionBuilder();
+ CollectionBuilderLegacy kf = new CollectionBuilderLegacy();
assertEquals("+pubDate:[20030604 TO 20030899]",
kf.between("2003-06-04", "2003-08-99").toString());
assertEquals("+pubDate:[0 TO 20030604]", kf.till("2003-06-04")
@@ -53,7 +53,7 @@
@Test
public void rangeLimited () throws IOException {
- CollectionBuilder kf = new CollectionBuilder();
+ CollectionBuilderLegacy kf = new CollectionBuilderLegacy();
assertEquals("+pubDate:[20050000 TO 20099999]",
kf.between("2005", "2009").toString());
assertEquals("+pubDate:[20051000 TO 20090899]",
@@ -97,7 +97,7 @@
@Test
public void rangeFailure () throws IOException {
- CollectionBuilder kf = new CollectionBuilder();
+ CollectionBuilderLegacy kf = new CollectionBuilderLegacy();
assertEquals("", kf.between("aaaa-bb-cc", "aaaabbcc").toString());
assertEquals("", kf.till("aaaa-bb-cc").toString());
assertEquals("", kf.since("aaaa-bb-cc").toString());
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
index 7cd11f0..a41bc59 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionIndex.java
@@ -2,8 +2,8 @@
import java.io.IOException;
import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.KrillCollectionNew;
-import de.ids_mannheim.korap.collection.CollectionBuilderNew;
+import de.ids_mannheim.korap.KrillCollection;
+import de.ids_mannheim.korap.collection.CollectionBuilder;
import de.ids_mannheim.korap.index.FieldDocument;
import de.ids_mannheim.korap.index.TextAnalyzer;
@@ -28,8 +28,8 @@
ki.addDoc(createDoc2());
ki.addDoc(createDoc3());
ki.commit();
- CollectionBuilderNew cb = new CollectionBuilderNew();
- KrillCollectionNew kcn = new KrillCollectionNew(ki);
+ CollectionBuilder cb = new CollectionBuilder();
+ KrillCollection kcn = new KrillCollection(ki);
// Simple string tests
kcn.fromBuilder(cb.term("author", "Frank"));
@@ -54,47 +54,47 @@
assertEquals(1, kcn.docCount());
// Simple orGroup tests
- kcn.fromBuilder(cb.orGroup(cb.term("author", "Frank")).with(cb.term("author", "Michael")));
+ kcn.fromBuilder(cb.orGroup().with(cb.term("author", "Frank")).with(cb.term("author", "Michael")));
assertEquals(1, kcn.docCount());
- kcn.fromBuilder(cb.orGroup(cb.term("author", "Frank")).with(cb.term("author", "Sebastian")));
+ kcn.fromBuilder(cb.orGroup().with(cb.term("author", "Frank")).with(cb.term("author", "Sebastian")));
assertEquals(2, kcn.docCount());
- kcn.fromBuilder(cb.orGroup(cb.term("author", "Frank"))
+ kcn.fromBuilder(cb.orGroup().with(cb.term("author", "Frank"))
.with(cb.term("author", "Sebastian"))
.with(cb.term("author", "Peter")));
assertEquals(3, kcn.docCount());
- kcn.fromBuilder(cb.orGroup(cb.term("author", "Huhu"))
+ kcn.fromBuilder(cb.orGroup().with(cb.term("author", "Huhu"))
.with(cb.term("author", "Haha"))
.with(cb.term("author", "Hehe")));
assertEquals(0, kcn.docCount());
// Multi field orGroup tests
- kcn.fromBuilder(cb.orGroup(cb.term("ID", "doc-1")).with(cb.term("author", "Peter")));
+ kcn.fromBuilder(cb.orGroup().with(cb.term("ID", "doc-1")).with(cb.term("author", "Peter")));
assertEquals(2, kcn.docCount());
- kcn.fromBuilder(cb.orGroup(cb.term("ID", "doc-1")).with(cb.term("author", "Frank")));
+ kcn.fromBuilder(cb.orGroup().with(cb.term("ID", "doc-1")).with(cb.term("author", "Frank")));
assertEquals(1, kcn.docCount());
- kcn.fromBuilder(cb.orGroup(cb.term("ID", "doc-1")).with(cb.term("author", "Michael")));
+ kcn.fromBuilder(cb.orGroup().with(cb.term("ID", "doc-1")).with(cb.term("author", "Michael")));
assertEquals(1, kcn.docCount());
// Simple andGroup tests
- kcn.fromBuilder(cb.andGroup(cb.term("author", "Frank")).with(cb.term("author", "Michael")));
+ kcn.fromBuilder(cb.andGroup().with(cb.term("author", "Frank")).with(cb.term("author", "Michael")));
assertEquals(0, kcn.docCount());
- kcn.fromBuilder(cb.andGroup(cb.term("ID", "doc-1")).with(cb.term("author", "Frank")));
+ kcn.fromBuilder(cb.andGroup().with(cb.term("ID", "doc-1")).with(cb.term("author", "Frank")));
assertEquals(1, kcn.docCount());
// andGroup in keyword field test
- kcn.fromBuilder(cb.andGroup(cb.term("textClass", "reisen")).with(cb.term("textClass", "finanzen")));
+ kcn.fromBuilder(cb.andGroup().with(cb.term("textClass", "reisen")).with(cb.term("textClass", "finanzen")));
assertEquals(1, kcn.docCount());
- kcn.fromBuilder(cb.andGroup(cb.term("textClass", "reisen")).with(cb.term("textClass", "kultur")));
+ kcn.fromBuilder(cb.andGroup().with(cb.term("textClass", "reisen")).with(cb.term("textClass", "kultur")));
assertEquals(2, kcn.docCount());
- kcn.fromBuilder(cb.andGroup(cb.term("textClass", "finanzen")).with(cb.term("textClass", "kultur")));
+ kcn.fromBuilder(cb.andGroup().with(cb.term("textClass", "finanzen")).with(cb.term("textClass", "kultur")));
assertEquals(0, kcn.docCount());
kcn.fromBuilder(cb.term("text", "mann"));
@@ -111,8 +111,8 @@
ki.addDoc(createDoc2());
ki.addDoc(createDoc3());
ki.commit();
- CollectionBuilderNew cb = new CollectionBuilderNew();
- KrillCollectionNew kcn = new KrillCollectionNew(ki);
+ CollectionBuilder cb = new CollectionBuilder();
+ KrillCollection kcn = new KrillCollection(ki);
// Simple negation tests
kcn.fromBuilder(cb.term("author", "Frank").not());
@@ -126,12 +126,12 @@
// orGroup with simple Negation
kcn.fromBuilder(
- cb.orGroup(cb.term("textClass", "kultur").not()).with(cb.term("author", "Peter"))
+ cb.orGroup().with(cb.term("textClass", "kultur").not()).with(cb.term("author", "Peter"))
);
assertEquals(2, kcn.docCount());
kcn.fromBuilder(
- cb.orGroup(cb.term("textClass", "kultur").not()).with(cb.term("author", "Sebastian"))
+ cb.orGroup().with(cb.term("textClass", "kultur").not()).with(cb.term("author", "Sebastian"))
);
assertEquals(1, kcn.docCount());
@@ -143,8 +143,8 @@
ki.addDoc(createDoc1());
ki.addDoc(createDoc2());
ki.commit();
- CollectionBuilderNew cb = new CollectionBuilderNew();
- KrillCollectionNew kcn = new KrillCollectionNew(ki);
+ CollectionBuilder cb = new CollectionBuilder();
+ KrillCollection kcn = new KrillCollection(ki);
kcn.fromBuilder(cb.term("author", "Frank"));
assertEquals(1, kcn.docCount());
@@ -231,8 +231,8 @@
ki.addDoc(createDoc2());
ki.addDoc(createDoc3());
ki.commit();
- CollectionBuilderNew cb = new CollectionBuilderNew();
- KrillCollectionNew kcn = new KrillCollectionNew(ki);
+ CollectionBuilder cb = new CollectionBuilder();
+ KrillCollection kcn = new KrillCollection(ki);
kcn.fromBuilder(cb.date("pubDate", "2005"));
assertEquals(3, kcn.docCount());
@@ -294,8 +294,8 @@
ki.addDoc(createDoc3());
ki.commit();
- CollectionBuilderNew cb = new CollectionBuilderNew();
- KrillCollectionNew kcn = new KrillCollectionNew(ki);
+ CollectionBuilder cb = new CollectionBuilder();
+ KrillCollection kcn = new KrillCollection(ki);
kcn.fromBuilder(cb.re("author", "Fran.*"));
assertEquals(1, kcn.docCount());
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 cbc60bc..46e59cd 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java
@@ -30,7 +30,7 @@
String metaQuery = _getJSONString("collection_1.jsonld");
KrillCollection kc = new KrillCollection(metaQuery);
assertEquals(kc.toString(),
- "filter with QueryWrapperFilter(+pubDate:20000101); ");
+ "pubDate:[20000101 TO 20000101]");
};
@@ -39,8 +39,7 @@
String metaQuery = _getJSONString("collection_2.jsonld");
KrillCollection kc = new KrillCollection(metaQuery);
assertEquals(kc.toString(),
- "filter with QueryWrapperFilter(+(+pubDate:"
- + "[19900000 TO 99999999] +pubDate:[0 TO 20061099])); ");
+ "AndGroup(pubDate:[19900000 TO 99999999] pubDate:[0 TO 20061099])");
};
@@ -56,8 +55,7 @@
public void collection5 () {
String metaQuery = _getJSONString("collection_5.jsonld");
KrillCollection kc = new KrillCollection(metaQuery);
- assertEquals(kc.toString(), "filter with QueryWrapperFilter(+(pubDate:"
- + "[19900000 TO 99999999] title:Mannheim)); ");
+ assertEquals(kc.toString(), "OrGroup(pubDate:[19900000 TO 99999999] title:Mannheim)");
};
@@ -68,7 +66,7 @@
assertFalse(ks.hasErrors());
assertFalse(ks.hasWarnings());
assertFalse(ks.hasMessages());
- assertEquals("filter with QueryWrapperFilter(+author:/Goethe/); ", ks
+ assertEquals("author:/Goethe/", ks
.getCollection().toString());
};
@@ -80,7 +78,7 @@
assertFalse(ks.hasErrors());
assertFalse(ks.hasWarnings());
assertFalse(ks.hasMessages());
- assertEquals("filter with QueryWrapperFilter(-author:/Goethe/); ", ks
+ assertEquals("-author:/Goethe/", ks
.getCollection().toString());
};
@@ -92,12 +90,12 @@
assertFalse(ks.hasErrors());
assertFalse(ks.hasWarnings());
assertFalse(ks.hasMessages());
- assertEquals("filter with QueryWrapperFilter(-author:Goethe); ", ks
+ assertEquals("-author:Goethe", ks
.getCollection().toString());
};
- @Ignore
+ @Test
public void nocollectiontypegiven () {
String metaQuery = _getJSONString("multiterm_rewrite_collection.jsonld");
KrillCollection kc = new KrillCollection(metaQuery);
@@ -109,8 +107,8 @@
public void noCollection () {
String metaQuery = _getJSONString("no_collection.jsonld");
KrillCollection kc = new KrillCollection(metaQuery);
- assertEquals("filter with QueryWrapperFilter(+corpusID:WPD); ",
- kc.toString());
+ assertTrue(kc.hasErrors());
+ assertEquals("", kc.toString());
};
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSONLegacy.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSONLegacy.java
index f83804f..2c668c3 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSONLegacy.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSONLegacy.java
@@ -3,7 +3,7 @@
import java.util.*;
import java.io.*;
-import de.ids_mannheim.korap.KrillCollection;
+import de.ids_mannheim.korap.KrillCollectionLegacy;
import static de.ids_mannheim.korap.TestSimple.*;
@@ -20,7 +20,7 @@
public void metaQuery1 () {
String metaQuery = getString(getClass().getResource(
"/queries/metaquery.jsonld").getFile());
- KrillCollection kc = new KrillCollection(metaQuery);
+ KrillCollectionLegacy kc = new KrillCollectionLegacy(metaQuery);
assertEquals("filter with QueryWrapperFilter(+textClass:wissenschaft)",
kc.getFilter(0).toString());
@@ -38,7 +38,7 @@
public void metaQuery2 () {
String metaQuery = getString(getClass().getResource(
"/queries/metaquery2.jsonld").getFile());
- KrillCollection kc = new KrillCollection(metaQuery);
+ KrillCollectionLegacy kc = new KrillCollectionLegacy(metaQuery);
assertEquals(1, kc.getCount());
assertEquals(
"filter with QueryWrapperFilter(+(+author:Hesse +pubDate:[0 TO 20131205]))",
@@ -50,7 +50,7 @@
public void metaQuery3 () {
String metaQuery = getString(getClass().getResource(
"/queries/metaquery4.jsonld").getFile());
- KrillCollection kc = new KrillCollection(metaQuery);
+ KrillCollectionLegacy kc = new KrillCollectionLegacy(metaQuery);
assertEquals(1, kc.getCount());
assertEquals(
"filter with QueryWrapperFilter(+pubDate:[20000101 TO 20131231])",
@@ -62,7 +62,7 @@
public void metaQuery7 () {
String metaQuery = getString(getClass().getResource(
"/queries/metaquery7.jsonld").getFile());
- KrillCollection kc = new KrillCollection(metaQuery);
+ KrillCollectionLegacy kc = new KrillCollectionLegacy(metaQuery);
assertEquals(2, kc.getCount());
assertEquals(
"filter with QueryWrapperFilter(+(corpusID:c-1 corpusID:c-2))",
@@ -77,7 +77,7 @@
public void metaQuery9 () {
String metaQuery = getString(getClass().getResource(
"/queries/metaquery9.jsonld").getFile());
- KrillCollection kc = new KrillCollection(metaQuery);
+ KrillCollectionLegacy kc = new KrillCollectionLegacy(metaQuery);
assertEquals(1, kc.getCount());
assertEquals("filter with QueryWrapperFilter(+corpusID:WPD)", kc
.getFilter(0).toString());
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionLegacy.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionLegacy.java
index 8341c1c..287ceba 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionLegacy.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionLegacy.java
@@ -4,7 +4,7 @@
import de.ids_mannheim.korap.KrillIndex;
import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.KrillCollection;
+import de.ids_mannheim.korap.KrillCollectionLegacy;
import de.ids_mannheim.korap.response.Result;
import de.ids_mannheim.korap.KrillQuery;
import de.ids_mannheim.korap.query.QueryBuilder;
@@ -38,10 +38,10 @@
};
ki.commit();
- CollectionBuilder kf = new CollectionBuilder();
+ CollectionBuilderLegacy kf = new CollectionBuilderLegacy();
// Create Virtual collections:
- KrillCollection kc = new KrillCollection(ki);
+ KrillCollectionLegacy kc = new KrillCollectionLegacy(ki);
assertEquals("Documents", 7, kc.numberOf("documents"));
@@ -107,10 +107,10 @@
ki.commit();
};
- CollectionBuilder kf = new CollectionBuilder();
+ CollectionBuilderLegacy kf = new CollectionBuilderLegacy();
// Create Virtual collections:
- KrillCollection kc = new KrillCollection(ki);
+ KrillCollectionLegacy kc = new KrillCollectionLegacy(ki);
assertEquals("Documents", 7, kc.numberOf("documents"));
@@ -184,10 +184,10 @@
ki.commit();
- CollectionBuilder kf = new CollectionBuilder();
+ CollectionBuilderLegacy kf = new CollectionBuilderLegacy();
// Create Virtual collections:
- KrillCollection kc = new KrillCollection(ki);
+ KrillCollectionLegacy kc = new KrillCollectionLegacy(ki);
kc.filter(kf.and("textClass", "reisen").and("textClass",
"freizeit-unterhaltung"));
assertEquals("Documents", 5, kc.numberOf("documents"));
@@ -237,7 +237,7 @@
assertEquals(86, kr.getTotalResults());
// Create Virtual collections:
- KrillCollection kc = new KrillCollection();
+ KrillCollectionLegacy kc = new KrillCollectionLegacy();
kc.filterUIDs(new String[] { "2", "3", "4" });
kc.setIndex(ki);
assertEquals("Documents", 3, kc.numberOf("documents"));
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionNew.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionNew.java
index 8408176..52dc59d 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionNew.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionNew.java
@@ -3,7 +3,7 @@
import java.util.*;
import java.io.*;
-import de.ids_mannheim.korap.collection.CollectionBuilderNew;
+import de.ids_mannheim.korap.collection.CollectionBuilder;
import static org.junit.Assert.*;
import org.junit.Test;
@@ -17,42 +17,42 @@
@Test
public void builderTerm () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
+ CollectionBuilder kc = new CollectionBuilder();
assertEquals("author:tree",
kc.term("author", "tree").toString());
};
@Test
public void builderRegex () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
+ CollectionBuilder kc = new CollectionBuilder();
assertEquals("QueryWrapperFilter(author:/tre*?/)",
kc.re("author", "tre*?").toString());
};
@Test
public void builderDateYear () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
+ CollectionBuilder kc = new CollectionBuilder();
assertEquals("pubDate:[20050000 TO 20059999]",
kc.date("pubDate", "2005").toString());
};
@Test
public void builderDateMonth () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
+ CollectionBuilder kc = new CollectionBuilder();
assertEquals("pubDate:[20051000 TO 20051099]",
kc.date("pubDate", "2005-10").toString());
};
@Test
public void builderDateDay () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
+ CollectionBuilder kc = new CollectionBuilder();
assertEquals("pubDate:[20051011 TO 20051011]",
kc.date("pubDate", "2005-10-11").toString());
};
@Test
public void builderDateBorders () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
+ CollectionBuilder kc = new CollectionBuilder();
// CollectionBuilderNew.CollectionBuilderInterface kbi = ;
assertNull(kc.date("pubDate", ""));
@@ -66,7 +66,7 @@
@Test
public void builderSince () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
+ CollectionBuilder kc = new CollectionBuilder();
assertEquals("pubDate:[20050000 TO 99999999]",
kc.since("pubDate", "2005").toString());
@@ -80,7 +80,7 @@
@Test
public void builderTill () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
+ CollectionBuilder kc = new CollectionBuilder();
assertEquals("pubDate:[0 TO 20059999]",
kc.till("pubDate", "2005").toString());
@@ -94,71 +94,71 @@
@Test
public void builderAndSimple () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
- assertEquals("author:tree", kc.andGroup(kc.term("author", "tree")).toString());
+ CollectionBuilder kc = new CollectionBuilder();
+ assertEquals("author:tree", kc.andGroup().with(kc.term("author", "tree")).toString());
};
@Test
public void builderOrSimple () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
- assertEquals("author:tree", kc.orGroup(kc.term("author", "tree")).toString());
+ CollectionBuilder kc = new CollectionBuilder();
+ assertEquals("author:tree", kc.orGroup().with(kc.term("author", "tree")).toString());
};
@Test
public void builderAndCombined () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
+ CollectionBuilder kc = new CollectionBuilder();
assertEquals("AndGroup(author:tree title:name)",
- kc.andGroup(kc.term("author", "tree"))
+ kc.andGroup().with(kc.term("author", "tree"))
.with(kc.term("title", "name")).toString());
};
@Test
public void builderAndNestedSimple () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
+ CollectionBuilder kc = new CollectionBuilder();
assertEquals("AndGroup(author:tree title:name)",
- kc.andGroup(kc.andGroup(kc.term("author", "tree")).with(kc.term("title", "name"))).toString());
+ kc.andGroup().with(kc.andGroup().with(kc.term("author", "tree")).with(kc.term("title", "name"))).toString());
};
@Test
public void builderOrCombined () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
+ CollectionBuilder kc = new CollectionBuilder();
assertEquals("OrGroup(author:tree title:name)",
- kc.orGroup(kc.term("author", "tree"))
+ kc.orGroup().with(kc.term("author", "tree"))
.with(kc.term("title", "name")).toString());
};
@Test
public void builderOrNestedSimple () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
+ CollectionBuilder kc = new CollectionBuilder();
assertEquals("OrGroup(author:tree title:name)",
- kc.orGroup(kc.orGroup(kc.term("author", "tree"))
+ kc.orGroup().with(kc.orGroup().with(kc.term("author", "tree"))
.with(kc.term("title", "name"))).toString()
);
};
@Test
public void builderGroups () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
- String g = kc.orGroup(
- kc.orGroup(kc.term("author", "tree1")).with(kc.term("title", "name1"))
+ CollectionBuilder kc = new CollectionBuilder();
+ String g = kc.orGroup().with(
+ kc.orGroup().with(kc.term("author", "tree1")).with(kc.term("title", "name1"))
).with(
- kc.andGroup(kc.term("author", "tree2")).with(kc.term("title", "name2"))
+ kc.andGroup().with(kc.term("author", "tree2")).with(kc.term("title", "name2"))
).toString();
assertEquals("OrGroup(OrGroup(author:tree1 title:name1) AndGroup(author:tree2 title:name2))", g);
};
@Test
public void builderNegationRoot () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
- CollectionBuilderNew.CollectionBuilderInterface kbi = kc.orGroup(kc.term("author", "tree1")).with(kc.term("title", "name1"));
+ CollectionBuilder kc = new CollectionBuilder();
+ CollectionBuilder.CollectionBuilderInterface kbi = kc.orGroup().with(kc.term("author", "tree1")).with(kc.term("title", "name1"));
assertEquals(
"OrGroup(author:tree1 title:name1)",
kbi.toString());
assertFalse(kbi.isNegative());
- kbi = kc.andGroup(
- kc.orGroup(kc.term("author", "tree1")).with(kc.term("title", "name1"))
+ kbi = kc.andGroup().with(
+ kc.orGroup().with(kc.term("author", "tree1")).with(kc.term("title", "name1"))
).not();
assertEquals("OrGroup(author:tree1 title:name1)", kbi.toString());
assertTrue(kbi.isNegative());
@@ -167,17 +167,17 @@
@Test
public void builderNegation () throws IOException {
- CollectionBuilderNew kc = new CollectionBuilderNew();
- CollectionBuilderNew.CollectionBuilderInterface kbi =
+ CollectionBuilder kc = new CollectionBuilder();
+ CollectionBuilder.CollectionBuilderInterface kbi =
kc.term("author", "tree").not();
assertEquals("author:tree", kbi.toString());
assertTrue(kbi.isNegative());
- kbi = kc.andGroup(kc.term("author", "tree").not());
+ kbi = kc.andGroup().with(kc.term("author", "tree").not());
assertEquals("author:tree", kbi.toString());
assertTrue(kbi.isNegative());
- kbi = kc.orGroup(kc.term("author", "tree").not());
+ kbi = kc.orGroup().with(kc.term("author", "tree").not());
assertEquals("author:tree", kbi.toString());
assertTrue(kbi.isNegative());
};
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
index 1b1ef4d..603cbbc 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
@@ -14,6 +14,7 @@
import org.junit.Test;
import de.ids_mannheim.korap.KrillCollection;
+import de.ids_mannheim.korap.collection.CollectionBuilder;
import de.ids_mannheim.korap.KrillIndex;
import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.response.Result;
@@ -167,10 +168,17 @@
//0.8s
// Check if it includes some results
- BooleanFilter bf = new BooleanFilter();
+
+ /*
+BooleanFilter bf = new BooleanFilter();
bf.or("ID", "WPD_BBB.04463", "WPD_III.00758");
+ */
+
KrillCollection kc = new KrillCollection();
- kc.filter(bf);
+ CollectionBuilder cb = new CollectionBuilder();
+ kc.fromBuilder(cb.orGroup().with(cb.term("ID", "WPD_BBB.04463")).with(cb.term("ID", "WPD_III.00758")));
+
+ // kc.filter(bf);
ks.setCollection(kc);
kr = ks.apply(ki);
assertEquals(1094, kr.getMatch(0).getStartPos());
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 87eeea3..2f23d35 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
@@ -10,6 +10,7 @@
import java.util.HashMap;
import org.junit.Test;
+import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -90,9 +91,9 @@
Krill ks = new Krill(new QueryBuilder("tokens").seg("s:Buchstaben"));
- // Todo: This is not an acceptable collection, but sigh
- ks.getCollection().filter(
- new CollectionBuilder().and("textClass", "reisen"));
+ CollectionBuilder cb = new CollectionBuilder();
+
+ ks.getCollection().fromBuilder(cb.term("textClass", "reisen"));
KrillMeta meta = ks.getMeta();
meta.setCount(3);
@@ -808,7 +809,12 @@
// Index was set but vc restricted to WPD
assertEquals(0, kc.numberOf("documents"));
+ /*
kc.extend(new CollectionBuilder().or("corpusSigle", "BZK"));
+ */
+ CollectionBuilder cb = new CollectionBuilder();
+ kc.fromBuilder(cb.orGroup().with(kc.getBuilder()).with(cb.term("corpusSigle", "BZK")));
+
ks.setCollection(kc);
assertEquals(1, kc.numberOf("documents"));
@@ -894,16 +900,20 @@
assertEquals(0, kr.getStartIndex());
assertEquals(10, kr.getItemsPerPage());
+
json = getString(getClass().getResource(
"/queries/metaquery8-filtered-nested.jsonld").getFile());
ks = new Krill(json);
kr = ks.apply(ki);
+ /*
assertEquals("filter with QueryWrapperFilter("
+ "+(ID:WPD_AAA.00003 (+tokens:s:die"
+ " +tokens:s:Schriftzeichen)))",
ks.getCollection().getFilter(1).toString());
+ */
+ assertEquals("AndGroup(OrGroup(ID:WPD_AAA.00001 ID:WPD_AAA.00002) OrGroup(ID:WPD_AAA.00003 AndGroup(tokens:s:die tokens:s:Schriftzeichen)))", ks.getCollection().toString());
assertEquals(kr.getTotalResults(), 119);
assertEquals(0, kr.getStartIndex());
@@ -1062,6 +1072,7 @@
This test will crash soon - it's just here for nostalgic reasons!
*/
@Test
+ @Ignore
public void getFoundryDistribution () throws Exception {
// Construct index
KrillIndex ki = new KrillIndex();
@@ -1078,16 +1089,19 @@
assertEquals(7, kc.numberOf("documents"));
+ /*
HashMap map = kc.getTermRelation("foundries");
assertEquals((long) 7, map.get("-docs"));
assertEquals((long) 7, map.get("treetagger"));
assertEquals((long) 6, map.get("opennlp/morpho"));
assertEquals((long) 6, map.get("#__opennlp/morpho:###:treetagger"));
assertEquals((long) 7, map.get("#__opennlp:###:treetagger"));
+ */
};
@Test
+ @Ignore
public void getTextClassDistribution () throws Exception {
KrillIndex ki = new KrillIndex();
ki.addDoc("{" + " \"fields\" : ["
@@ -1117,7 +1131,7 @@
KrillCollection kc = new KrillCollection(ki);
assertEquals(3, kc.numberOf("documents"));
-
+ /*
HashMap map = kc.getTermRelation("textClass");
assertEquals((long) 1, map.get("singing"));
assertEquals((long) 1, map.get("jumping"));
@@ -1131,12 +1145,13 @@
assertEquals((long) 1, map.get("#__jumping:###:music"));
assertEquals((long) 1, map.get("#__music:###:singing"));
assertEquals(11, map.size());
-
+ */
// System.err.println(kc.getTermRelationJSON("textClass"));
};
@Test
+ @Ignore
public void getTextClassDistribution2 () throws Exception {
KrillIndex ki = new KrillIndex();
ki.addDoc("{" + " \"fields\" : ["
@@ -1175,7 +1190,7 @@
KrillCollection kc = new KrillCollection(ki);
assertEquals(4, kc.numberOf("documents"));
-
+ /*
HashMap map = kc.getTermRelation("textClass");
assertEquals((long) 1, map.get("singing"));
assertEquals((long) 1, map.get("jumping"));
@@ -1189,5 +1204,6 @@
assertEquals((long) 1, map.get("#__jumping:###:music"));
assertEquals((long) 1, map.get("#__music:###:singing"));
assertEquals(11, map.size());
+ */
};
};
diff --git a/src/test/resources/queries/metaquery8-filtered-further.jsonld b/src/test/resources/queries/metaquery8-filtered-further.jsonld
index 5a497cf..06d3766 100644
--- a/src/test/resources/queries/metaquery8-filtered-further.jsonld
+++ b/src/test/resources/queries/metaquery8-filtered-further.jsonld
@@ -18,6 +18,72 @@
"right":["char",90]
}
},
+ "collection" : {
+ "@type": "koral:docGroup",
+ "operation": "operation:and",
+ "operands": [
+ {
+ "@type": "koral:docGroup",
+ "operation": "operation:or",
+ "operands": [
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00001",
+ "type": "type:string"
+ },
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00002",
+ "type": "type:string"
+ }
+ ]
+ },
+ {
+ "@type": "koral:docGroup",
+ "operation": "operation:or",
+ "operands": [
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00003",
+ "type": "type:string"
+ },
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00002",
+ "type": "type:string"
+ }
+ ]
+ },
+ {
+ "@type": "koral:docGroup",
+ "operation": "operation:or",
+ "operands": [
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00001",
+ "type": "type:string"
+ },
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00005",
+ "type": "type:string"
+ }
+ ]
+ }
+ ]
+ },
"collections": [
{
"@type": "koral:meta-filter",
diff --git a/src/test/resources/queries/metaquery8-filtered-nested.jsonld b/src/test/resources/queries/metaquery8-filtered-nested.jsonld
index 7c8cf43..fd14b53 100644
--- a/src/test/resources/queries/metaquery8-filtered-nested.jsonld
+++ b/src/test/resources/queries/metaquery8-filtered-nested.jsonld
@@ -1,73 +1,132 @@
{
- "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
- "query": {
- "@type": "koral:token",
- "wrap": {
- "@type": "koral:term",
- "foundry": "mate",
- "layer" : "lemma",
- "key":"der",
- "match": "match:eq"
- }
- },
- "meta":{
- "startPage":1,
- "count": 10,
- "context":{
- "left":["char",90],
- "right":["char",90]
- }
- },
- "collections": [
- {
- "@type": "koral:meta-filter",
- "@id": "korap-filter#id-1223232",
- "@value": {
- "@type": "koral:group",
- "relation": "or",
- "@field": "koral:field#ID",
- "operands": [
- {
- "@type": "koral:term",
- "@value": "WPD_AAA.00001"
- },
- {
- "@type": "koral:term",
- "@value": "WPD_AAA.00002"
- }
- ]
- }
- },
- {
- "@type": "koral:meta-filter",
- "@id": "korap-filter#id-1223232",
- "@value": {
- "@type": "koral:group",
- "relation": "or",
- "@field": "koral:field#ID",
- "operands": [
- {
- "@type": "koral:term",
- "@value": "WPD_AAA.00003"
- },
- {
- "@type": "koral:group",
- "relation": "and",
- "@field": "koral:field#tokens",
- "operands": [
- {
- "@type": "koral:term",
- "@value": "s:die"
- },
- {
- "@type": "koral:term",
- "@value": "s:Schriftzeichen"
- }
-
- ]
- }
- ]
- }
- }
+ "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query": {
+ "@type": "koral:token",
+ "wrap": {
+ "@type": "koral:term",
+ "foundry": "mate",
+ "layer" : "lemma",
+ "key":"der",
+ "match": "match:eq"
+ }
+ },
+ "meta":{
+ "startPage":1,
+ "count": 10,
+ "context":{
+ "left":["char",90],
+ "right":["char",90]
+ }
+ },
+ "collection" : {
+ "@type": "koral:docGroup",
+ "operation": "operation:and",
+ "operands": [
+ {
+ "@type": "koral:docGroup",
+ "operation": "operation:or",
+ "operands": [
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00001",
+ "type": "type:string"
+ },
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00002",
+ "type": "type:string"
+ }
+ ]
+ },
+ {
+ "@type": "koral:docGroup",
+ "operation": "operation:or",
+ "operands": [
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00003",
+ "type": "type:string"
+ },
+ {
+ "@type": "koral:docGroup",
+ "operation": "operation:and",
+ "operands": [
+ {
+ "@type": "koral:doc",
+ "key": "tokens",
+ "match": "match:eq",
+ "value": "s:die",
+ "type": "type:string"
+ },
+ {
+ "@type": "koral:doc",
+ "key": "tokens",
+ "match": "match:eq",
+ "value": "s:Schriftzeichen",
+ "type": "type:string"
+ }
+ ]
+ }
+ ]
+ }
]
+ },
+ "collections": [
+ {
+ "@type": "koral:meta-filter",
+ "@id": "korap-filter#id-1223232",
+ "@value": {
+ "@type": "koral:group",
+ "relation": "or",
+ "@field": "koral:field#ID",
+ "operands": [
+ {
+ "@type": "koral:term",
+ "@value": "WPD_AAA.00001"
+ },
+ {
+ "@type": "koral:term",
+ "@value": "WPD_AAA.00002"
+ }
+ ]
+ }
+ },
+ {
+ "@type": "koral:meta-filter",
+ "@id": "korap-filter#id-1223232",
+ "@value": {
+ "@type": "koral:group",
+ "relation": "or",
+ "@field": "koral:field#ID",
+ "operands": [
+ {
+ "@type": "koral:term",
+ "@value": "WPD_AAA.00003"
+ },
+ {
+ "@type": "koral:group",
+ "relation": "and",
+ "@field": "koral:field#tokens",
+ "operands": [
+ {
+ "@type": "koral:term",
+ "@value": "s:die"
+ },
+ {
+ "@type": "koral:term",
+ "@value": "s:Schriftzeichen"
+ }
+
+ ]
+ }
+ ]
+ }
+ }
+ ]
}
diff --git a/src/test/resources/queries/metaquery8-filtered.jsonld b/src/test/resources/queries/metaquery8-filtered.jsonld
index 9e7ee8a..1a3ed3c 100644
--- a/src/test/resources/queries/metaquery8-filtered.jsonld
+++ b/src/test/resources/queries/metaquery8-filtered.jsonld
@@ -1,61 +1,107 @@
{
- "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
- "query": {
- "@type": "koral:token",
- "wrap": {
- "@type": "koral:term",
- "foundry": "mate",
- "layer" : "lemma",
- "key":"der",
- "match": "match:eq"
- }
- },
- "meta":{
- "startPage":1,
- "count": 10,
- "context":{
- "left":["char",90],
- "right":["char",90]
- }
- },
- "collections": [
- {
- "@type": "koral:meta-filter",
- "@id": "korap-filter#id-1223232",
- "@value": {
- "@type": "koral:group",
- "relation": "or",
- "@field": "koral:field#ID",
- "operands": [
- {
- "@type": "koral:term",
- "@value": "WPD_AAA.00001"
- },
- {
- "@type": "koral:term",
- "@value": "WPD_AAA.00002"
- }
- ]
- }
- },
- {
- "@type": "koral:meta-filter",
- "@id": "korap-filter#id-1223232",
- "@value": {
- "@type": "koral:group",
- "relation": "or",
- "@field": "koral:field#ID",
- "operands": [
- {
- "@type": "koral:term",
- "@value": "WPD_AAA.00003"
- },
- {
- "@type": "koral:term",
- "@value": "WPD_AAA.00002"
- }
- ]
- }
- }
+ "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query": {
+ "@type": "koral:token",
+ "wrap": {
+ "@type": "koral:term",
+ "foundry": "mate",
+ "layer" : "lemma",
+ "key":"der",
+ "match": "match:eq"
+ }
+ },
+ "meta":{
+ "startPage":1,
+ "count": 10,
+ "context":{
+ "left":["char",90],
+ "right":["char",90]
+ }
+ },
+ "collection" : {
+ "@type": "koral:docGroup",
+ "operation": "operation:and",
+ "operands": [
+ {
+ "@type": "koral:docGroup",
+ "operation": "operation:or",
+ "operands": [
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00001",
+ "type": "type:string"
+ },
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00002",
+ "type": "type:string"
+ }
+ ]
+ },
+ {
+ "@type": "koral:docGroup",
+ "operation": "operation:or",
+ "operands": [
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00003",
+ "type": "type:string"
+ },
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00002",
+ "type": "type:string"
+ }
+ ]
+ }
]
+ },
+ "collections": [
+ {
+ "@type": "koral:meta-filter",
+ "@id": "korap-filter#id-1223232",
+ "@value": {
+ "@type": "koral:group",
+ "relation": "or",
+ "@field": "koral:field#ID",
+ "operands": [
+ {
+ "@type": "koral:term",
+ "@value": "WPD_AAA.00001"
+ },
+ {
+ "@type": "koral:term",
+ "@value": "WPD_AAA.00002"
+ }
+ ]
+ }
+ },
+ {
+ "@type": "koral:meta-filter",
+ "@id": "korap-filter#id-1223232",
+ "@value": {
+ "@type": "koral:group",
+ "relation": "or",
+ "@field": "koral:field#ID",
+ "operands": [
+ {
+ "@type": "koral:term",
+ "@value": "WPD_AAA.00003"
+ },
+ {
+ "@type": "koral:term",
+ "@value": "WPD_AAA.00002"
+ }
+ ]
+ }
+ }
+ ]
}
diff --git a/src/test/resources/queries/metaquery8.jsonld b/src/test/resources/queries/metaquery8.jsonld
index f2417f0..e3a2a57 100644
--- a/src/test/resources/queries/metaquery8.jsonld
+++ b/src/test/resources/queries/metaquery8.jsonld
@@ -1,42 +1,41 @@
{
- "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
- "query": {
- "@type": "koral:token",
- "wrap": {
- "@type": "koral:term",
- "foundry": "mate",
- "layer" : "lemma",
- "key":"der",
- "match": "match:eq"
- }
- },
- "meta":{
- "startPage":1,
- "count": 10,
- "context":{
- "left":["char",90],
- "right":["char",90]
- }
- },
- "collections": [
- {
- "@type": "koral:meta-filter",
- "@id": "korap-filter#id-1223232",
- "@value": {
- "@type": "koral:group",
- "relation": "or",
- "@field": "koral:field#ID",
- "operands": [
- {
- "@type": "koral:term",
- "@value": "WPD_AAA.00001"
- },
- {
- "@type": "koral:term",
- "@value": "WPD_AAA.00002"
- }
- ]
- }
- }
+ "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query": {
+ "@type": "koral:token",
+ "wrap": {
+ "@type": "koral:term",
+ "foundry": "mate",
+ "layer" : "lemma",
+ "key":"der",
+ "match": "match:eq"
+ }
+ },
+ "meta":{
+ "startPage":1,
+ "count": 10,
+ "context":{
+ "left":["char",90],
+ "right":["char",90]
+ }
+ },
+ "collection" : {
+ "@type" : "koral:docGroup",
+ "operation": "operation:or",
+ "operands": [
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00001",
+ "type": "type:string"
+ },
+ {
+ "@type": "koral:doc",
+ "key": "ID",
+ "match": "match:eq",
+ "value": "WPD_AAA.00002",
+ "type": "type:string"
+ }
]
+ }
}