stanfordnlp/CoreNLP · error · SsurgeonParseException
RelabelNamedEdge created with no relation!
Error message
RelabelNamedEdge created with no relation!
What it means
SsurgeonParseException from RelabelNamedEdge's constructor when it is created with a null edge name or null relation; a relabel operation must know which named matched edge to modify and what relation to assign.
Solutions
- Pass a valid GrammaticalRelation instance, e.g. UniversalGrammaticalRelations.DIRECT_OBJECT or GrammaticalRelation.valueOf("dobj")
- Fix the -reln argument in the resource line to a valid universal relation short name
- Use the relations from edu.stanford.nlp.trees.UniversalGrammaticalRelations rather than null placeholders
Example fix
// before
new RelabelNamedEdge("myEdge", null);
// after
new RelabelNamedEdge("myEdge", UniversalGrammaticalRelations.NOMINAL_SUBJECT); Defensive patterns
Strategy: validation
Validate before calling
if (relation == null) {
throw new IllegalArgumentException("relabel-named-edge requires a -reln GrammaticalRelation");
} Type guard
boolean isValidRelation(GrammaticalRelation r) { return r != null && r.getShortName() != null; } Try / catch
try {
op = new RelabelNamedEdge(edgeName, relation);
} catch (SsurgeonParseException e) {
log.error("Missing/invalid relation: {}", e.getMessage());
op = new RelabelNamedEdge(edgeName, UniversalGrammaticalRelations.DEPENDENT);
} Prevention
- Reference relations from UniversalGrammaticalRelations constants rather than parsing strings ad hoc
- Validate relation short names in rules against the known UD set
- Fail fast in rule loading tests by constructing every operation once
When it happens
Trigger: new RelabelNamedEdge(edgeName, null), or a relabel-named-edge Ssurgeon resource line with a missing or unparseable -reln argument.
Common situations: Typo in the relation name in a rule file so the parser yields null; constructing the operation from a config where the relation field is absent; using a relation string that cannot resolve to a GrammaticalRelation.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- No governor given for an AddDep
- No relation given for an AddDep
- ReattachNamedEdge created with no edge name!
- ReattachNamedEdge created with both gov and dep missing!
- RelabelNamedEdge created with no edge name!
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/4882ad8a64228aae.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/RelabelNamedEdge.java:34
* <i>that</i> edge is deleted permanently. That way, named
* references to the first edge should still work.
*
* @author John Bauer
*
*/
public class RelabelNamedEdge extends SsurgeonEdit {
public static final String LABEL = "relabelNamedEdge";
protected final String edgeName; // Name of the matched edge in the SemgrexPattern
protected final GrammaticalRelation relation; // Type of relation to add between these edges
public RelabelNamedEdge(String edgeName, GrammaticalRelation relation) {
if (edgeName == null) {
throw new SsurgeonParseException("RelabelNamedEdge created with no edge name!");
}
if (relation == null) {
throw new SsurgeonParseException("RelabelNamedEdge created with no relation!");
}
this.edgeName = edgeName;
this.relation = relation;
}
@Override
public String toEditString() {
StringWriter buf = new StringWriter();
buf.write(LABEL); buf.write("\t");
buf.write(Ssurgeon.EDGE_NAME_ARG);buf.write(" ");
buf.write(edgeName); buf.write("\t");
buf.write(Ssurgeon.RELN_ARG);buf.write(" ");
buf.write(relation.toString()); buf.write("\t");
return buf.toString();View on GitHub (pinned to 1b7edd19c4)