use of de.ids_mannheim.korap.query.wrap.SpanAlterQueryWrapper in project Krill by KorAP.
the class KrillQuery method _segFromJson.
// Deserialize koral:token
private SpanQueryWrapper _segFromJson(JsonNode json) throws QueryException {
if (!json.has("@type"))
throw new QueryException(701, "JSON-LD group has no @type attribute");
String type = json.get("@type").asText();
if (DEBUG)
log.trace("Wrap new token definition by {}", type);
// Branch on type
switch(type) {
case "koral:term":
// case "match:eq":
return this._termFromJson(json);
case "koral:termGroup":
if (!json.has("operands"))
throw new QueryException(742, "Term group needs operand list");
// Get operands
JsonNode operands = json.get("operands");
SpanSegmentQueryWrapper ssegqw = this.builder().seg();
if (!json.has("relation"))
throw new QueryException(743, "Term group expects a relation");
switch(json.get("relation").asText()) {
case "relation:and":
for (JsonNode operand : operands) {
SpanQueryWrapper part = this._segFromJson(operand);
if (part instanceof SpanAlterQueryWrapper) {
ssegqw.with((SpanAlterQueryWrapper) part);
} else if (part instanceof SpanRegexQueryWrapper) {
ssegqw.with((SpanRegexQueryWrapper) part);
} else if (part instanceof SpanSegmentQueryWrapper) {
ssegqw.with((SpanSegmentQueryWrapper) part);
} else {
throw new QueryException(744, "Operand not supported in term group");
}
;
}
;
return ssegqw;
case "relation:or":
SpanAlterQueryWrapper ssaq = new SpanAlterQueryWrapper(this.field);
for (JsonNode operand : operands) {
ssaq.or(this._segFromJson(operand));
}
;
return ssaq;
}
;
}
;
throw new QueryException(745, "Token type is not supported");
}
use of de.ids_mannheim.korap.query.wrap.SpanAlterQueryWrapper in project Krill by KorAP.
the class TestSpanAlterQuery method spanAlterQuery.
@Test
public void spanAlterQuery() throws QueryException {
SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
ssaquery.or("b");
assertEquals("field:b", ssaquery.toQuery().toString());
}
use of de.ids_mannheim.korap.query.wrap.SpanAlterQueryWrapper in project Krill by KorAP.
the class TestSpanAlterQuery method spanAlterQuery2.
@Test
public void spanAlterQuery2() throws QueryException {
SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
ssaquery.or("b").or("c");
assertEquals("spanOr([field:b, field:c])", ssaquery.toQuery().toString());
}
use of de.ids_mannheim.korap.query.wrap.SpanAlterQueryWrapper in project Krill by KorAP.
the class TestSpanAlterQuery method spanAlterQuery4.
@Test
public void spanAlterQuery4() throws QueryException {
SpanSegmentQueryWrapper segquery = new SpanSegmentQueryWrapper("field", "a", "b", "c");
SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
ssaquery.or("d").or(segquery).or("e");
assertEquals("spanOr([field:d, spanSegment(spanSegment(field:a, field:b), field:c), field:e])", ssaquery.toQuery().toString());
}
use of de.ids_mannheim.korap.query.wrap.SpanAlterQueryWrapper in project Krill by KorAP.
the class TestSpanSegmentAlterQuery method spanAlterQuery2.
@Test
public void spanAlterQuery2() throws QueryException {
SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
ssaquery.or("b").or("c");
assertEquals("spanOr([field:b, field:c])", ssaquery.toQuery().toString());
}
Aggregations