use of annis.model.QueryNode in project ANNIS by korpling.
the class JoinListener method enterTokenArityTerm.
@Override
public void enterTokenArityTerm(AqlParser.TokenArityTermContext ctx) {
QueryNode target = nodeByRef(ctx.left);
Preconditions.checkArgument(target != null, errorLHS("token-arity") + ": " + ctx.getText());
target.setTokenArity(annisRangeFromARangeSpec(ctx.rangeSpec()));
}
use of annis.model.QueryNode in project ANNIS by korpling.
the class JoinListener method enterRangePrecedence.
@Override
public void enterRangePrecedence(AqlParser.RangePrecedenceContext 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_PRECEDENCE());
left.addOutgoingJoin(addParsedLocation(ctx, new Precedence(right, range.getMin(), range.getMax(), segmentationName)));
}
}
use of annis.model.QueryNode in project ANNIS by korpling.
the class JoinListener method enterIndirectPrecedence.
@Override
public void enterIndirectPrecedence(AqlParser.IndirectPrecedenceContext ctx) {
QueryNode left = relationChain.get(relationIdx);
QueryNode right = relationChain.get(relationIdx + 1);
String segmentationName = getLayerName(ctx.NAMED_PRECEDENCE());
if (precedenceBound > 0) {
left.addOutgoingJoin(addParsedLocation(ctx, new Precedence(right, 1, precedenceBound, segmentationName)));
} else {
left.addOutgoingJoin(addParsedLocation(ctx, new Precedence(right, segmentationName)));
}
}
use of annis.model.QueryNode in project ANNIS by korpling.
the class JoinListener method enterNonBindingRelation.
@Override
public void enterNonBindingRelation(AqlParser.NonBindingRelationContext ctx) {
int numOfReferences = ctx.REF().size();
relationIdx = 0;
relationChain.clear();
relationChain.ensureCapacity(numOfReferences);
for (int i = 0; i < numOfReferences; i++) {
QueryNode n = nodeByRef(ctx.REF(i).getSymbol());
if (n == null) {
throw new AnnisQLSemanticsException(AnnisParserAntlr.getLocation(ctx.getStart(), ctx.getStop()), "invalid reference to '" + ctx.REF(i).getText() + "'");
}
relationChain.add(i, n);
}
}
use of annis.model.QueryNode in project ANNIS by korpling.
the class JoinListener method join.
/**
* Automatically create a join from a node and a join class.
*
* This will automatically get the left and right hand refs
* and will construct a new join specified by the type using reflection.
*
* It will also add an parsed location to the join.
*
* @node
* @type00
*/
private void join(ParserRuleContext ctx, Class<? extends Join> type) {
QueryNode left = relationChain.get(relationIdx);
QueryNode right = relationChain.get(relationIdx + 1);
try {
Constructor<? extends Join> c = type.getConstructor(QueryNode.class);
Join newJoin = c.newInstance(right);
left.addOutgoingJoin(addParsedLocation(ctx, newJoin));
} catch (NoSuchMethodException ex) {
log.error(null, ex);
} catch (InstantiationException ex) {
log.error(null, ex);
} catch (IllegalAccessException ex) {
log.error(null, ex);
} catch (InvocationTargetException ex) {
log.error(null, ex);
}
}
Aggregations