stanfordnlp/CoreNLP · error · SsurgeonParseException
Relation not specified for AddDep
Error message
Relation not specified for AddDep
What it means
When parsing an AddDep edit, parseEditLine requires the -reln argument giving the GrammaticalRelation for the new dependent edge. If argsBox.reln is null (no -reln flag was supplied), SsurgeonParseException('Relation not specified for AddDep') is thrown.
Solutions
- Add -reln <relation> to the adddep edit line, e.g. -reln obl.
- Use a relation name valid for the chosen language (GrammaticalRelation.valueOf(language, reln) runs next and will fail on bad names).
- Check the argument pairing on the line — a stray quote earlier can offset -flag/-value pairs so -reln is lost.
Example fix
// before adddep -node governor -dep newnode // after adddep -node governor -dep newnode -reln nmod
Defensive patterns
Strategy: validation
Validate before calling
if (line.startsWith("adddep") && !line.matches(".*-reln\\s+\\S+.*"))
throw new IllegalArgumentException("adddep line missing -reln: " + line); Try / catch
try { parseEditLine(line, attrs, lang); } catch (SsurgeonParseException e) { if (e.getMessage().equals("Relation not specified for AddDep")) log.error("Add -reln to: " + line); } Prevention
- Always include -reln on adddep lines
- Use relation names valid for the selected language
- Keep a rule-file lint that checks required flags per op
When it happens
Trigger: An edit line 'adddep -node gov ...' that omits the -reln flag; a -reln value consumed by the wrong pairing in parseArgs (e.g. due to an earlier unmatched quote shifting arg pairs).
Common situations: Writing adddep rules from memory and forgetting -reln; rule templates from other ssurgeon ops (like addnode) that don't need -reln; a malformed argument list silently swallowing the -reln value.
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
- Relation not specified for AddEdge
- SetPhraseHead expected a -headIndex, 0-indexed for the node…
- SetPhraseHead expected a -reln to represent the dependency…
- SplitWord expected -node with the name of the matched node…
- SplitWord expected -exact or -regex with regex to determine…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/46f00417929f2902.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java:615
if (tuples1.length < 1) {
throw new SsurgeonParseException("Error in SsurgeonEdit.parseEditLine: invalid number of arguments");
}
final String command = tuples1[0];
if (command.equalsIgnoreCase(SetRoots.LABEL)) {
String[] names = tuples1[1].split("\\s+");
List<String> newRoots = Arrays.asList(names);
return new SetRoots(newRoots);
} else if (command.equalsIgnoreCase(KillNonRootedNodes.LABEL)) {
return new KillNonRootedNodes();
}
// Parse the arguments based upon the type of command to execute.
final SsurgeonArgs argsBox = parseArgsBox(tuples1.length == 1 ? "" : tuples1[1], attributeArgs);
if (command.equalsIgnoreCase(AddDep.LABEL)) {
if (argsBox.reln == null) {
throw new SsurgeonParseException("Relation not specified for AddDep");
}
GrammaticalRelation reln = GrammaticalRelation.valueOf(language, argsBox.reln);
return new AddDep(argsBox.govNodeName, reln, argsBox.annotations, argsBox.position);
} else if (command.equalsIgnoreCase(AddNode.LABEL)) {
return AddNode.createAddNode(argsBox.nodeString, argsBox.name);
} else if (command.equalsIgnoreCase(AddEdge.LABEL)) {
if (argsBox.reln == null) {
throw new SsurgeonParseException("Relation not specified for AddEdge");
}
GrammaticalRelation reln = GrammaticalRelation.valueOf(language, argsBox.reln);
return new AddEdge(argsBox.govNodeName, argsBox.dep, reln, argsBox.weight);
} else if (command.equalsIgnoreCase(ReattachNamedEdge.LABEL)) {
return new ReattachNamedEdge(argsBox.edge, argsBox.govNodeName, argsBox.dep);
} else if (command.equalsIgnoreCase(DeleteGraphFromNode.LABEL)) {
if (argsBox.nodes.size() != 1) {
throw new SsurgeonParseException("Cannot make a DeleteGraphFromNode out of " + argsBox.nodes.size() + " nodes");
}
return new DeleteGraphFromNode(argsBox.nodes.get(0));View on GitHub (pinned to 1b7edd19c4)