stanfordnlp/CoreNLP · error · SsurgeonParseException
No governor given for an AddDep
Error message
No governor given for an AddDep
What it means
AddDep's constructor requires the name of the governor node to attach the new dependent to. If govNodeName is null, it throws this SsurgeonParseException immediately, since the operation cannot know where to hang the new dependency.
Solutions
- Pass a valid named-node reference as govNodeName — a node name assigned with '=' elsewhere in the associated Semgrex pattern.
- Fix the Ssurgeon rule so the governor attribute is present and matches a node name in the pattern.
- Validate rule elements (gov name non-null, matches pattern names) before constructing AddDep.
- Note the next check in the constructor: relation must also be non-null, so fix both together when auditing the call.
Example fix
// before
new AddDep(null, rel, attrs, "+1"); // throws
// after
String gov = patternNodeName; // e.g. "gov" from {}=gov
new AddDep(gov, rel, attrs, "+1"); Defensive patterns
Strategy: validation
Validate before calling
if (govNodeName == null || govNodeName.isBlank()) throw new IllegalArgumentException("AddDep requires a governor node name"); Try / catch
try { new AddDep(gov, rel, attrs, pos); } catch (SsurgeonParseException e) { throw new IllegalArgumentException("AddDep missing governor", e); } Prevention
- Ensure the gov name matches a node named with '=' in the paired Semgrex pattern
- Validate Ssurgeon rule XML for required gov attribute at load time
- Fail fast in generated-rule builders when a variable is null
When it happens
Trigger: Calling new AddDep(null, relation, attributes, position[, weight]); also occurs when Ssurgeon rule parsing builds an AddDep element without the governor (e.g. missing or misspelled 'gov' attribute in the rule XML).
Common situations: Ssurgeon rule files missing the governor attribute; refactors renaming node variables so the referenced name becomes null; programmatic rule generation that leaves the gov argument unset.
Related errors
- No relation given for an AddDep
- Unknown position in AddDep operation
- 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/e96e57a7b6a8c51e.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/AddDep.java:43
public static final String LABEL = "addDep";
final Map<String, String> attributes;
final GrammaticalRelation relation;
final String govNodeName;
final String position;
final double weight;
public AddDep(String govNodeName, GrammaticalRelation relation, Map<String, String> attributes, String position) {
this(govNodeName, relation, attributes, position, 0.0);
}
public AddDep(String govNodeName, GrammaticalRelation relation, Map<String, String> attributes, String position, double weight) {
if (position != null) {
if (!position.startsWith("-") && !position.startsWith("+")) {
throw new SsurgeonParseException("Unknown position " + position + " in AddDep operation");
}
}
if (govNodeName == null) {
throw new SsurgeonParseException("No governor given for an AddDep");
}
if (relation == null) {
throw new SsurgeonParseException("No relation given for an AddDep");
}
checkIllegalAttributes(attributes);
this.attributes = new TreeMap<>(attributes);
this.relation = relation;
this.govNodeName = govNodeName;
this.position = position;
this.weight = weight;
}
/**
* Emits a parseable instruction string.
*/
@Override
public String toEditString() {View on GitHub (pinned to 1b7edd19c4)