Search in sources :

Example 1 with SpanRelationWrapper

use of de.ids_mannheim.korap.query.wrap.SpanRelationWrapper in project Krill by KorAP.

the class KrillQuery method _operationRelationFromJson.

private SpanQueryWrapper _operationRelationFromJson(JsonNode operands, JsonNode relation) throws QueryException {
    if (operands.size() < 2) {
        throw new QueryException(705, "Number of operands is not acceptable");
    }
    SpanQueryWrapper operand1 = this._fromKoral(operands.get(0), true);
    SpanQueryWrapper operand2 = this._fromKoral(operands.get(1), true);
    RelationDirection direction;
    if (operand1.isEmpty() && !operand2.isEmpty()) {
        // "<:";
        direction = RelationDirection.LEFT;
    } else {
        // ">:"
        direction = RelationDirection.RIGHT;
    }
    if (!relation.has("@type")) {
        throw new QueryException(701, "JSON-LD group has no @type attribute");
    }
    if (relation.get("@type").asText().equals("koral:relation")) {
        SpanRelationWrapper spanRelationWrapper;
        SpanQueryWrapper relationTermWrapper;
        if (!relation.has("wrap")) {
            throw new QueryException(718, "Missing relation term.");
        } else {
            relationTermWrapper = _termFromJson(relation.get("wrap"), false, direction);
            spanRelationWrapper = new SpanRelationWrapper(relationTermWrapper, operand1, operand2);
        }
        spanRelationWrapper.setDirection(direction);
        return spanRelationWrapper;
    } else {
        throw new QueryException(713, "Query type is not supported");
    }
// if (relation.has("boundary")){
// _operationRepetitionFromJson(relation, operands);
// }
// else{
// 
// }
}
Also used : QueryException(de.ids_mannheim.korap.util.QueryException) SpanRelationWrapper(de.ids_mannheim.korap.query.wrap.SpanRelationWrapper) RelationDirection(de.ids_mannheim.korap.constants.RelationDirection) SpanQueryWrapper(de.ids_mannheim.korap.query.wrap.SpanQueryWrapper)

Aggregations

RelationDirection (de.ids_mannheim.korap.constants.RelationDirection)1 SpanQueryWrapper (de.ids_mannheim.korap.query.wrap.SpanQueryWrapper)1 SpanRelationWrapper (de.ids_mannheim.korap.query.wrap.SpanRelationWrapper)1 QueryException (de.ids_mannheim.korap.util.QueryException)1