use of de.ids_mannheim.korap.KrillCollection in project Krill by KorAP.
the class TestKrill method searchJSON2.
@Test
public void searchJSON2() throws IOException {
// Construct index
KrillIndex ki = new KrillIndex();
// Indexing test files
for (String i : new String[] { "00001", "00002", "00003", "00004", "00005", "00006", "02439", "00012-fakemeta", "00030-fakemeta" /*
"02035-substring",
"05663-unbalanced",
"07452-deep"
*/
}) {
ki.addDoc(getClass().getResourceAsStream("/wiki/" + i + ".json.gz"), true);
}
;
ki.commit();
String json = getJsonString(getClass().getResource("/queries/metaquery4.jsonld").getFile());
Krill ks = new Krill(json);
Result kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 1);
ks = new Krill(json);
// Ignore the collection part of the query!
ks.setCollection(new KrillCollection());
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 5);
json = getJsonString(getClass().getResource("/queries/metaquery5.jsonld").getFile());
ks = new Krill(json);
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 1);
json = getJsonString(getClass().getResource("/queries/metaquery6.jsonld").getFile());
ks = new Krill(json);
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 1);
}
use of de.ids_mannheim.korap.KrillCollection in project Krill by KorAP.
the class TestWPDIndex method testCase4.
/**
* Element distance exclusion
*/
@Test
public void testCase4() throws IOException {
SpanDistanceQuery sq = createElementDistanceQuery("s", "s:weg", "s:fahren", 1, 1, false, true);
ks = new Krill(sq);
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 979);
// 0.8s
// Check if it includes some results
/*
BooleanFilter bf = new BooleanFilter();
bf.or("ID", "WPD_BBB.04463", "WPD_III.00758");
*/
KrillCollection kc = new KrillCollection();
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());
assertEquals(451, kr.getMatch(1).getEndPos());
}
Aggregations