stanfordnlp/CoreNLP · error · ParseException
Relation does not allow for named edges
Error message
Relation does not allow for named edges
What it means
This ParseException is thrown by GraphRelation.getRelation(String,String,String,String) in Stanford Semgrex when a named edge (edgeName, the ':name' clause of a relation) is attached to a relation that does not support edge naming. Only directional relations ('>', '<', '>++', '>--', '<++', '<--', '<>') construct relation objects that accept an edgeName; all others (grandparent, sibling, adjacency, alignment, equality) reject it. The message includes the offending relation symbol.
Solutions
- Remove the ':edgeName' suffix from the relation in the pattern (e.g. '<<:dep' -> '<<').
- Use a relation that supports named edges: '>', '<', '<>', '>++', '>--', '<++', '<--'.
- If you call getRelation directly, pass null for edgeName for non-directional relations.
- Check GraphRelation.isKnownRelation and the first switch in getRelation to confirm which relations accept edgeName before attaching one.
Example fix
// before
GraphRelation r = GraphRelation.getRelation("<<", null, name, "dep"); // throws
// after
GraphRelation r = GraphRelation.getRelation("<<", null, name, null); // or use ">" with "dep" Defensive patterns
Strategy: validation
Validate before calling
boolean supportsNamedEdge(String reln) {
return reln.equals(">") || reln.equals("<") || reln.equals("<>")
|| reln.equals(">++") || reln.equals(">--")
|| reln.equals("<++") || reln.equals("<--");
}
// before calling: if (!supportsNamedEdge(reln)) edgeName = null; Type guard
if (edgeName != null && !supportsNamedEdge(reln)) {
throw new IllegalArgumentException("Relation " + reln + " does not support named edges");
} Try / catch
try {
GraphRelation r = GraphRelation.getRelation(reln, type, name, edgeName);
} catch (ParseException e) {
if (e.getMessage().contains("does not allow for named edges")) {
r = GraphRelation.getRelation(reln, type, name, null);
}
} Prevention
- Only append ':name' to directional relations (>, <, <>, >++, >--, <++, <--).
- Validate patterns with GraphRelation.isKnownRelation plus an edge-name capability check before compilation.
- Keep a pattern linter/test corpus of all supported Semgrex operators.
When it happens
Trigger: Calling getRelation(reln, type, name, edgeName) with a non-null edgeName for a relation not in the first switch block, e.g. getRelation("<<", null, name, "myedge") or getRelation("$+", null, name, "e"). Parsing a Semgrex pattern like '<<:dep' or '.:x' where the named-edge syntax is applied to an unsupported operator.
Common situations: Hand-written Semgrex patterns where the user assumes every operator supports ':edgeName' annotation; programmatically built patterns in annotator pipelines that append edge names uniformly to all relations; migrating patterns between Semgrex versions where the set of named-edge-capable relations differs.
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 not handled by getRelation
- Relation does not use numeric arguments
- Unrecognized compound relation
- Invalid txtGraph
- Invalid hypGraph
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/578fdbee71b6a9b9.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/GraphRelation.java:1479
}
switch (reln) {
case ">":
return new GOVERNOR(type, name, edgeName);
case ">++":
return new GOVERNOR_RIGHT(type, name, edgeName);
case ">--":
return new GOVERNOR_LEFT(type, name, edgeName);
case "<":
return new DEPENDENT(type, name, edgeName);
case "<++":
return new DEPENDENT_RIGHT(type, name, edgeName);
case "<--":
return new DEPENDENT_LEFT(type, name, edgeName);
case "<>":
return new CONNECTED(type, name, edgeName);
}
if (edgeName != null) {
throw new ParseException("Relation " + reln + " does not allow for named edges");
}
switch (reln) {
case ">>":
return new GRANDPARENT(type, name);
case "<<":
return new GRANDKID(type, name);
case "==":
return new EQUALS(type, name);
case "$+":
return new RIGHT_IMMEDIATE_SIBLING(type, name);
case "$-":
return new LEFT_IMMEDIATE_SIBLING(type, name);
case "$++":
return new RIGHT_SIBLING(type, name);
case "$--":
return new LEFT_SIBLING(type, name);
case ".":
return new ADJACENT_RIGHT(type, name);View on GitHub (pinned to 1b7edd19c4)