use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.
the class TestSpanWithinQueryJSON method testTokenContainSentence.
@Test
public void testTokenContainSentence() throws QueryException {
exception.expectMessage("Token cannot contain another token or element.");
String filepath = getClass().getResource("/queries/position/token-contain-sentence.json").getFile();
SpanQueryWrapper sqwi = getJSONQuery(filepath);
SpanQuery sq = sqwi.toQuery();
}
use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.
the class TestElementDistanceIndex method jsonQuery.
public static SpanQueryWrapper jsonQuery(String jsonFile) {
SpanQueryWrapper sqwi;
try {
String json = getString(jsonFile);
sqwi = new KrillQuery("tokens").fromKoral(json);
} catch (QueryException e) {
fail(e.getMessage());
sqwi = new QueryBuilder("tokens").seg("???");
}
return sqwi;
}
use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.
the class TestElementDistanceIndex method testCase5.
/**
* Test query from json
*/
@Test
public void testCase5() throws Exception {
ki = new KrillIndex();
ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"), true);
ki.commit();
String jsonPath = URLDecoder.decode(getClass().getResource("/queries/cosmas1.json").getFile(), "UTF-8");
SpanQueryWrapper sqwi = jsonQuery(jsonPath);
kr = ki.search(sqwi.toQuery(), (short) 10);
assertEquals((long) 3, kr.getTotalResults());
assertEquals(14, kr.getMatch(0).startPos);
assertEquals(19, kr.getMatch(0).endPos);
assertEquals(30, kr.getMatch(1).startPos);
assertEquals(33, kr.getMatch(1).endPos);
}
use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.
the class TestFieldDocument method jsonQuery.
public static SpanQueryWrapper jsonQuery(String jsonFile) {
SpanQueryWrapper sqwi;
try {
String json = getString(jsonFile);
sqwi = new KrillQuery("tokens").fromKoral(json);
} catch (QueryException e) {
fail(e.getMessage());
sqwi = new QueryBuilder("tokens").seg("???");
}
;
return sqwi;
}
use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.
the class TestFieldDocument method queryJSONBsp18.
@Test
public void queryJSONBsp18() throws Exception {
// Construct index
KrillIndex ki = new KrillIndex();
// Indexing test files
for (String i : new String[] { "00001", "00002", "00003", "00004", "00005", "00006", "02439" }) {
FieldDocument fd = ki.addDoc(getClass().getResourceAsStream("/wiki/" + i + ".json.gz"), true);
}
;
ki.commit();
String jsonPath = URLDecoder.decode(getClass().getResource("/queries/bsp18.jsonld").getFile(), "UTF-8");
// {1:der} \w0:5 nicht
SpanQueryWrapper sqwi = jsonQuery(jsonPath);
Result kr = ki.search(sqwi.toQuery(), 0, (short) 5, true, (short) 2, false, (short) 5);
assertEquals(1, kr.getTotalResults());
assertEquals("... bezeichnen, sofern [[{1:der} schwedische Buchstabe „Å“ nicht]] verfügbar ist im SI-Einheitensystem ist ...", kr.getMatch(0).getSnippetBrackets());
}
Aggregations