stanfordnlp/CoreNLP · error · ParseException
Relation does not use numeric arguments
Error message
Relation does not use numeric arguments
What it means
This ParseException is thrown by the numeric getRelation(String,String,int,String,String) overload when the relation is a known Semgrex operator but not one of the two numeric-limited relations ('>>' or '<<'). The overload exists specifically for counted grandparent/grandkid relations, so any other known operator passed with a count is rejected as misusing numeric arguments.
Solutions
- Remove the numeric argument, or restrict counts to '>>' and '<<' which are the only relations using them.
- Use '>' / '<' nested twice (or composition) instead of counting other operators.
- If calling getRelation directly, use the two-argument-name overload (reln, type, name, edgeName) for non-numeric relations.
- Check isKnownRelation: only '>>' and '<<' are valid with the int overload.
Example fix
// before
GraphRelation r = GraphRelation.getRelation(">", null, 2, name, null); // throws
// after
GraphRelation r = GraphRelation.getRelation(">", null, name, null); // or use ">>" for counted grandparents Defensive patterns
Strategy: validation
Validate before calling
boolean numericRelation(String reln) {
return reln.equals(">>") || reln.equals("<<");
}
// route before calling:
// if (numericRelation(reln)) use int overload; else use (reln, type, name, edgeName) overload Try / catch
try {
GraphRelation r = GraphRelation.getRelation(reln, type, num, name, null);
} catch (ParseException e) {
if (e.getMessage().contains("does not use numeric arguments")) {
r = GraphRelation.getRelation(reln, type, name, null);
}
} Prevention
- Only pass the int overload for '>>' and '<<'.
- Validate user patterns so digits following an operator are rejected unless the operator is >>/<<.
- Test pattern compilation over the full operator list.
When it happens
Trigger: Calling getRelation("$+", null, 1, name, null), getRelation(".", null, 1, name, null), or getRelation(">", type, 2, name, null) - any known operator other than '>>'/'<<' with the int overload. Parsing patterns that attach a count to a non-countable operator, e.g. writing '>2' or '$+1' in a Semgrex expression.
Common situations: Users guessing syntax and appending numbers to operators to mean 'n hops'; porting patterns from other graph query languages where numeric repetition is generic; typos like '>' with stray digits from template generation.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Relation does not allow for named edges
- Relation not handled by getRelation
- Unrecognized compound relation
- Invalid txtGraph
- Invalid hypGraph
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/9eb04b5546bf0a8f.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/GraphRelation.java:1528
}
}
public static GraphRelation getRelation(String reln,
String type,
int num,
String name,
String edgeName) throws ParseException {
if (edgeName != null) {
throw new ParseException("Relation " + reln + " does not allow for named edges");
}
if (reln == null && type == null)
return null;
if (reln.equals(">>"))
return new LIMITED_GRANDPARENT(type, name, num, num);
else if (reln.equals("<<"))
return new LIMITED_GRANDKID(type, name, num, num);
else if (isKnownRelation(reln))
throw new ParseException("Relation " + reln +
" does not use numeric arguments");
else //error
throw new ParseException("Unrecognized compound relation " + reln + " "
+ type);
}
public static GraphRelation getRelation(String reln,
String type,
int num, int num2,
String name,
String edgeName) throws ParseException {
if (edgeName != null) {
throw new ParseException("Relation " + reln + " does not allow for named edges");
}
if (reln == null && type == null)
return null;
if (reln.equals(">>"))
return new LIMITED_GRANDPARENT(type, name, num, num2);View on GitHub (pinned to 1b7edd19c4)