use of de.ids_mannheim.korap.KrillQuery in project Krill by KorAP.
the class TestClass method queryJSONpoly1.
@Test
public void queryJSONpoly1() throws QueryException, IOException {
String jsonPath = URLDecoder.decode(getClass().getResource("/queries/poly1.json").getFile(), "UTF-8");
String jsonQuery = readFile(jsonPath);
SpanQueryWrapper sqwi = new KrillQuery("tokens").fromKoral(jsonQuery);
SpanNextQuery sq = (SpanNextQuery) sqwi.toQuery();
// System.out.println(sq.toString());
ki = new KrillIndex();
ki.addDoc(getClass().getResourceAsStream("/wiki/JJJ-00785.json.gz"), true);
ki.addDoc(getClass().getResourceAsStream("/wiki/DDD-01402.json.gz"), true);
ki.commit();
kr = ki.search(sq, (short) 10);
assertEquals(61, kr.getMatch(0).getStartPos());
assertEquals(64, kr.getMatch(0).getEndPos());
assertEquals("... Bruckner (Wien) und Mathis Lussy (Paris). [[{1:Inspiriert} " + "{2:durch die}]] additiven Modelle arabischer Rhythmik (er half ...", kr.getMatch(0).getSnippetBrackets());
assertEquals(31, kr.getMatch(1).getStartPos());
assertEquals(34, kr.getMatch(1).getEndPos());
assertEquals("... des Sendens wird ein unhörbarer Unterton [[{1:mitgesendet}, " + "{2:auf den}]] das angesprochene Funkgerät reagiert. Die Abkürzung ...", kr.getMatch(1).getSnippetBrackets());
}
use of de.ids_mannheim.korap.KrillQuery in project Krill by KorAP.
the class TestClass method queryJSONpoly4.
@Test
public void queryJSONpoly4() throws QueryException, IOException {
String jsonPath = URLDecoder.decode(getClass().getResource("/queries/poly4.json").getFile(), "UTF-8");
String jsonQuery = readFile(jsonPath);
SpanQueryWrapper sqwi = new KrillQuery("tokens").fromKoral(jsonQuery);
SpanQuery sq = sqwi.toQuery();
// System.out.println(sq.toString());
ki = new KrillIndex();
ki.addDoc(getClass().getResourceAsStream("/wiki/SSS-09803.json.gz"), true);
ki.commit();
kr = ki.search(sq, (short) 10);
/*
for (Match km : kr.getMatches()){
System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+km.getSnippetBrackets()
);
}
*/
assertEquals((long) 5315, kr.getTotalResults());
assertEquals(3, kr.getMatch(0).getStartPos());
assertEquals(5, kr.getMatch(0).getEndPos());
// fail("Tests have to be updated");
}
use of de.ids_mannheim.korap.KrillQuery in project Krill by KorAP.
the class TestSpanExpansionIndex method testCase7.
/**
* Skip to
*/
@Test
public void testCase7() throws IOException, QueryException {
KrillIndex ki = new KrillIndex();
ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"), true);
ki.addDoc(getClass().getResourceAsStream("/wiki/00002.json.gz"), true);
ki.commit();
String jsonPath = URLDecoder.decode(getClass().getResource("/queries/poly3.json").getFile(), "UTF-8");
String jsonQuery = readFile(jsonPath);
SpanQueryWrapper sqwi = new KrillQuery("tokens").fromKoral(jsonQuery);
SpanQuery sq = sqwi.toQuery();
// System.out.println(sq.toString());
kr = ki.search(sq, (short) 20);
assertEquals(205, kr.getMatch(0).getStartPos());
assertEquals(208, kr.getMatch(0).getEndPos());
/*
* for (Match km : kr.getMatches()){
* System.out.println(km.getStartPos() +","+km.getEndPos()+" "
* +km.getSnippetBrackets() ); }
*/
}
use of de.ids_mannheim.korap.KrillQuery in project Krill by KorAP.
the class TestKrillQueryJSON method queryJSONinfiniteExpansion.
@Test
public void queryJSONinfiniteExpansion() throws QueryException {
// der []*
try {
String json = getString(getClass().getResource("/queries/bugs/expansion_bug_3.jsonld").getFile());
KrillQuery kq = new KrillQuery("tokens");
assertEquals(kq.fromKoral(json).toQuery().toString(), "focus(254: spanContain(<tokens:base/s:t />, {254: spanExpansion(tokens:s:c, []{0, 4}, right)}))");
} catch (QueryException e) {
fail(e.getMessage());
}
;
}
use of de.ids_mannheim.korap.KrillQuery in project Krill by KorAP.
the class TestKrillQueryJSON method queryJSONdistancesWithRegexes.
@Test
public void queryJSONdistancesWithRegexes() throws QueryException {
// "der" []{2,3} [opennlp/p="NN"]
try {
String json = getString(getClass().getResource("/queries/bugs/distances_with_regex_bug.jsonld").getFile());
KrillQuery kq = new KrillQuery("tokens");
assertEquals(kq.fromKoral(json).toQuery().toString(), "spanDistance(SpanMultiTermQueryWrapper(tokens:/s:der/), SpanMultiTermQueryWrapper(tokens:/opennlp/p:NN/), [(w[3:4], ordered, notExcluded)])");
} catch (QueryException e) {
fail(e.getMessage());
}
;
}
Aggregations