Search in sources :

Example 1 with RelationDirection

use of de.ids_mannheim.korap.constants.RelationDirection in project Krill by KorAP.

the class FocusSpans method setMatch.

private void setMatch(CandidateSpan cs) {
    matchStartPosition = cs.getStart();
    prevStart = matchStartPosition;
    matchEndPosition = cs.getEnd();
    matchDocNumber = cs.getDoc();
    prevDoc = matchDocNumber;
    matchPayload.addAll(cs.getPayloads());
    if (firstSpans instanceof RelationSpans && classNumbers.size() == 1) {
        RelationSpans relationSpans = (RelationSpans) firstSpans;
        RelationDirection direction = relationSpans.getDirection();
        if (classNumbers.get(0) == relationSpans.getTempSourceNum()) {
            if (direction.equals(RelationDirection.RIGHT)) {
                setSpanId(relationSpans.getLeftId());
            } else {
                setSpanId(relationSpans.getRightId());
            }
        } else if (classNumbers.get(0) == relationSpans.getTempTargetNum()) {
            if (direction.equals(RelationDirection.RIGHT)) {
                setSpanId(relationSpans.getRightId());
            } else {
                setSpanId(relationSpans.getLeftId());
            }
        }
        // }
        if (spanId > 0)
            hasSpanId = true;
    } else if (cs.getSpanId() > 0) {
        setSpanId(cs.getSpanId());
        hasSpanId = true;
    }
}
Also used : RelationDirection(de.ids_mannheim.korap.constants.RelationDirection)

Example 2 with RelationDirection

use of de.ids_mannheim.korap.constants.RelationDirection 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)2 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