use of de.ids_mannheim.korap.KrillQuery in project Krill by KorAP.
the class TestKrillQueryJSON method queryJSONcomplexSpanOrTerm.
@Test
public void queryJSONcomplexSpanOrTerm() throws QueryException {
// startsWith(<base/s=s>, { lassen | laufen })
try {
String json = getString(getClass().getResource("/queries/bugs/span_or_bug.jsonld").getFile());
KrillQuery kq = new KrillQuery("tokens");
assertEquals(kq.fromKoral(json).toQuery().toString(), "spanStartsWith(<tokens:base/s:s />, spanOr([tokens:s:Er, tokens:s:Sie]))");
} catch (QueryException e) {
fail(e.getMessage());
}
;
}
use of de.ids_mannheim.korap.KrillQuery in project Krill by KorAP.
the class TestKrillQueryJSON method queryJSONunderspecifiedTokenBug.
@Test
public void queryJSONunderspecifiedTokenBug() {
// ((MORPH(APPR) ODER MORPH(APPRART)) /+w1 Urlaub
try {
String json = getString(getClass().getResource("/queries/bugs/underspecified_token.jsonld").getFile());
new KrillQuery("tokens").fromKoral(json);
} catch (QueryException e) {
assertEquals(701, e.getErrorCode());
}
;
}
use of de.ids_mannheim.korap.KrillQuery in project Krill by KorAP.
the class TestSampleIndex method testWildcardsWithJson.
@Test
public void testWildcardsWithJson() throws IOException, QueryException {
SpanQueryWrapper sqwi = getJSONQuery(getClass().getResource("/queries/bugs/cosmas_wildcards_all.jsonld").getFile());
SpanQuery sq = sqwi.toQuery();
kr = sample.search(sq, (short) 10);
assertEquals(4, kr.getMatches().size());
// test krill apply
Krill krill = new Krill();
krill.setSpanQuery(sq);
krill.setIndex(sample);
kr = krill.apply();
assertEquals(4, kr.getMatches().size());
// test krill deserialization
String jsonString = getJsonString(getClass().getResource("/queries/bugs/cosmas_wildcards_all.jsonld").getFile());
krill = new Krill();
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readTree(jsonString);
final KrillQuery kq = new KrillQuery("tokens");
krill.setQuery(kq);
SpanQueryWrapper qw = kq.fromKoral(jsonNode.get("query"));
assertEquals(sqwi.toQuery(), qw.toQuery());
krill.setSpanQuery(qw.toQuery());
kr = krill.apply(sample);
assertEquals(4, kr.getMatches().size());
}
use of de.ids_mannheim.korap.KrillQuery 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.KrillQuery 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;
}
Aggregations