Search in sources :

Example 51 with QueryNode

use of annis.model.QueryNode in project ANNIS by korpling.

the class JoinListener method enterRangeNear.

@Override
public void enterRangeNear(AqlParser.RangeNearContext ctx) {
    QueryNode left = relationChain.get(relationIdx);
    QueryNode right = relationChain.get(relationIdx + 1);
    QueryNode.Range range = annisRangeFromARangeSpec(ctx.rangeSpec());
    if (range.getMin() == 0 || range.getMax() == 0) {
        throw new AnnisQLSemanticsException(AnnisParserAntlr.getLocation(ctx.getStart(), ctx.getStop()), "Distance can't be 0");
    } else if (range.getMin() > range.getMax()) {
        throw new AnnisQLSemanticsException(AnnisParserAntlr.getLocation(ctx.getStart(), ctx.getStop()), "Minimal distance can't be larger than maximal distance");
    } else {
        String segmentationName = getLayerName(ctx.NAMED_NEAR());
        left.addOutgoingJoin(addParsedLocation(ctx, new Near(right, range.getMin(), range.getMax(), segmentationName)));
    }
}
Also used : QueryNode(annis.model.QueryNode) AnnisQLSemanticsException(annis.exceptions.AnnisQLSemanticsException) Near(annis.sqlgen.model.Near)

Example 52 with QueryNode

use of annis.model.QueryNode in project ANNIS by korpling.

the class JoinListener method enterRangeDominance.

@Override
public void enterRangeDominance(AqlParser.RangeDominanceContext ctx) {
    QueryNode left = relationChain.get(relationIdx);
    QueryNode right = relationChain.get(relationIdx + 1);
    String layer = getLayerName(ctx.NAMED_DOMINANCE());
    QueryNode.Range range = annisRangeFromARangeSpec(ctx.rangeSpec());
    if (range.getMin() == 0 || range.getMax() == 0) {
        throw new AnnisQLSemanticsException(AnnisParserAntlr.getLocation(ctx.getStart(), ctx.getStop()), "Distance can't be 0");
    } else if (range.getMin() > range.getMax()) {
        throw new AnnisQLSemanticsException(AnnisParserAntlr.getLocation(ctx.getStart(), ctx.getStop()), "Minimal distance can't be larger than maximal distance");
    }
    left.addOutgoingJoin(addParsedLocation(ctx, new Dominance(right, layer, range.getMin(), range.getMax())));
}
Also used : QueryNode(annis.model.QueryNode) AnnisQLSemanticsException(annis.exceptions.AnnisQLSemanticsException) RightDominance(annis.sqlgen.model.RightDominance) Dominance(annis.sqlgen.model.Dominance) LeftDominance(annis.sqlgen.model.LeftDominance)

Example 53 with QueryNode

use of annis.model.QueryNode in project ANNIS by korpling.

the class JoinListener method enterBindingRelation.

@Override
public void enterBindingRelation(AqlParser.BindingRelationContext ctx) {
    int numOfReferences = ctx.refOrNode().size();
    relationIdx = 0;
    relationChain.clear();
    relationChain.ensureCapacity(numOfReferences);
    for (int i = 0; i < numOfReferences; i++) {
        QueryNode n = node(ctx.refOrNode(i));
        if (n == null) {
            throw new AnnisQLSemanticsException(AnnisParserAntlr.getLocation(ctx.getStart(), ctx.getStop()), "invalid reference to '" + ctx.refOrNode(i).getText() + "'");
        }
        relationChain.add(i, n);
    }
}
Also used : QueryNode(annis.model.QueryNode) AnnisQLSemanticsException(annis.exceptions.AnnisQLSemanticsException)

Example 54 with QueryNode

use of annis.model.QueryNode in project ANNIS by korpling.

the class JoinListener method enterIndirectNear.

@Override
public void enterIndirectNear(AqlParser.IndirectNearContext ctx) {
    QueryNode left = relationChain.get(relationIdx);
    QueryNode right = relationChain.get(relationIdx + 1);
    String segmentationName = getLayerName(ctx.NAMED_NEAR());
    if (precedenceBound > 0) {
        left.addOutgoingJoin(addParsedLocation(ctx, new Near(right, 1, precedenceBound, segmentationName)));
    } else {
        left.addOutgoingJoin(addParsedLocation(ctx, new Near(right, segmentationName)));
    }
}
Also used : QueryNode(annis.model.QueryNode) Near(annis.sqlgen.model.Near)

Example 55 with QueryNode

use of annis.model.QueryNode in project ANNIS by korpling.

the class JoinListener method enterDirectPointing.

@Override
public void enterDirectPointing(AqlParser.DirectPointingContext ctx) {
    QueryNode left = relationChain.get(relationIdx);
    QueryNode right = relationChain.get(relationIdx + 1);
    String label = getLayerName(ctx.POINTING(), 2);
    Join j = new PointingRelation(right, label, 1);
    if (ctx.anno != null) {
        LinkedList<QueryAnnotation> annotations = fromRelationAnnotation(ctx.anno);
        for (QueryAnnotation a : annotations) {
            j.addEdgeAnnotation(a);
        }
    }
    left.addOutgoingJoin(addParsedLocation(ctx, j));
}
Also used : PointingRelation(annis.sqlgen.model.PointingRelation) QueryNode(annis.model.QueryNode) QueryAnnotation(annis.model.QueryAnnotation) Join(annis.model.Join)

Aggregations

QueryNode (annis.model.QueryNode)67 Join (annis.model.Join)12 LinkedList (java.util.LinkedList)11 AnnisQLSemanticsException (annis.exceptions.AnnisQLSemanticsException)10 ArrayList (java.util.ArrayList)8 QueryAnnotation (annis.model.QueryAnnotation)7 Precedence (annis.sqlgen.model.Precedence)7 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 Dominance (annis.sqlgen.model.Dominance)5 PointingRelation (annis.sqlgen.model.PointingRelation)5 TestUtils.uniqueString (annis.test.TestUtils.uniqueString)5 TreeSet (java.util.TreeSet)5 Test (org.junit.Test)5 Identical (annis.sqlgen.model.Identical)4 LeftDominance (annis.sqlgen.model.LeftDominance)4 Near (annis.sqlgen.model.Near)4 RightDominance (annis.sqlgen.model.RightDominance)4 TestUtils.uniqueLong (annis.test.TestUtils.uniqueLong)4 QueryData (annis.ql.parser.QueryData)3