DIRTY DEMO HACKS
diff --git a/src/test/java/de/ids_mannheim/korap/filter/TestKorapCollection.java b/src/test/java/de/ids_mannheim/korap/filter/TestKorapCollection.java
index bcd9ed3..54864aa 100644
--- a/src/test/java/de/ids_mannheim/korap/filter/TestKorapCollection.java
+++ b/src/test/java/de/ids_mannheim/korap/filter/TestKorapCollection.java
@@ -70,6 +70,7 @@
assertEquals("Documents", 1, kc.numberOf("documents"));
kc.extend( kf.and("textClass", "wissenschaft") );
+
assertEquals("Documents", 3, kc.numberOf("documents"));
assertEquals("Tokens", 1669, kc.numberOf("tokens"));
assertEquals("Sentences", 188, kc.numberOf("sentences"));
@@ -77,6 +78,78 @@
// System.err.println(kr.toJSON());
};
+ @Ignore
+ public void filterExampleAtomic () throws IOException {
+
+ // That's exactly the same test class, but with multiple atomic indices
+
+ // Construct index
+ KorapIndex ki = new KorapIndex();
+ // Indexing test files
+ for (String i : new String[] {"00001", "00002", "00003", "00004", "00005", "00006", "02439"}) {
+ FieldDocument fd = ki.addDocFile(
+ getClass().getResource("/wiki/" + i + ".json.gz").getFile(), true
+ );
+ ki.commit();
+ };
+
+ KorapFilter kf = new KorapFilter();
+
+ // Create Virtual collections:
+ KorapCollection kc = new KorapCollection(ki);
+
+ assertEquals("Documents", 7, kc.numberOf("documents"));
+
+ /*
+ If this is set - everything is fine automatically ...
+ kc.filter(kf.and("corpusID", "WPD"));
+ assertEquals("Documents", 7, kc.numberOf("documents"));
+ */
+
+ // The virtual collection consists of all documents that have the textClass "reisen" and "freizeit"
+ kc.filter( kf.and("textClass", "reisen").and("textClass", "freizeit-unterhaltung") );
+
+ assertEquals("Documents", 5, kc.numberOf("documents"));
+ assertEquals("Tokens", 1678, kc.numberOf("tokens"));
+ assertEquals("Sentences", 194, kc.numberOf("sentences"));
+ assertEquals("Paragraphs", 139, kc.numberOf("paragraphs"));
+
+ // Subset this to all documents that have also the text
+ kc.filter(kf.and("textClass", "kultur"));
+
+ assertEquals("Documents", 1, kc.numberOf("documents"));
+ assertEquals("Tokens", 405, kc.numberOf("tokens"));
+ assertEquals("Sentences", 75, kc.numberOf("sentences"));
+ assertEquals("Paragraphs", 48, kc.numberOf("paragraphs"));
+
+ kc.filter(kf.and("corpusID", "WPD"));
+
+ assertEquals("Documents", 1, kc.numberOf("documents"));
+ assertEquals("Tokens", 405, kc.numberOf("tokens"));
+ assertEquals("Sentences", 75, kc.numberOf("sentences"));
+ assertEquals("Paragraphs", 48, kc.numberOf("paragraphs"));
+
+ // Create a query
+ KorapQuery kq = new KorapQuery("tokens");
+ SpanQuery query = kq.seg("opennlp/p:NN").with("tt/p:NN").toQuery();
+
+ KorapResult kr = kc.search(query);
+ assertEquals(70, kr.totalResults());
+
+ kc.extend( kf.and("textClass", "uninteresting") );
+ assertEquals("Documents", 1, kc.numberOf("documents"));
+
+ kc.extend( kf.and("textClass", "wissenschaft") );
+
+ System.err.println("+++++++++++++++++++++++");
+ assertEquals("Documents", 3, kc.numberOf("documents"));
+ assertEquals("Tokens", 1669, kc.numberOf("tokens"));
+ assertEquals("Sentences", 188, kc.numberOf("sentences"));
+ assertEquals("Paragraphs", 130, kc.numberOf("paragraphs"));
+ // System.err.println(kr.toJSON());
+ };
+
+
@Test
public void filterExample2 () throws IOException {
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 c995068..c62a71a 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
@@ -172,6 +172,14 @@
assertEquals(sqwi.toQuery().toString(), "spanWithin(<tokens:np />, tokens:"+defaultFoundry+"l:Mann)");
};
+ @Test
+ public void queryJSONDemo () throws QueryException {
+ SpanQueryWrapperInterface sqwi = new KorapQuery("tokens").fromJSON("{ \"query\" : { \"@type\" : \"korap:token\", \"@value\" : { \"@type\" : \"korap:term\", \"@value\" : \"base_p:foo\", \"relation\" : \"=\" }}}");
+
+ assertEquals(sqwi.toQuery().toString(), "tokens:base/p:foo");
+ };
+
+
public static String getString (String path) {
StringBuilder contentBuilder = new StringBuilder();
try {
diff --git a/src/test/resources/wiki/readme.txt b/src/test/resources/wiki/readme.txt
index 32fc818..6f60d05 100644
--- a/src/test/resources/wiki/readme.txt
+++ b/src/test/resources/wiki/readme.txt
@@ -3,5 +3,5 @@
00003: kultur,musik
00004: wissenschaft,populaerwissenschaft
00005: freizeit-unterhaltung,reisen
-00006: freizeit-unterhaltung,reisen
-02439: kultur,musik,freizeit-unterhaltung,reisen
+00006: freizeit-unterhaltung,reisen (WPD)
+02439: kultur,musik,freizeit-unterhaltung,reisen (WPD)