stanfordnlp/CoreNLP · error · SsurgeonParseException
Cannot make a DeleteLeaf out of " + argsBox.nodes.size() +…
Error message
Cannot make a DeleteLeaf out of " + argsBox.nodes.size() + " nodes
What it means
DeleteLeaf deletes exactly one leaf node, so parseEditLine requires argsBox.nodes.size() == 1. Any other count (0 or multiple -node flags) raises SsurgeonParseException('Cannot make a DeleteLeaf out of N nodes').
Solutions
- Supply exactly one -node <name> flag for deleteleaf.
- Remove redundant -node flags; issue one deleteleaf edit per leaf to remove.
- Confirm the node name was defined by an earlier pattern named group or addnode/edit in the same rule.
Example fix
// before deleteleaf // after deleteleaf -node child
Defensive patterns
Strategy: validation
Validate before calling
int count = countFlagOccurrences(line, "-node");
if (line.startsWith("deleteleaf") && count != 1)
throw new IllegalArgumentException("deleteleaf needs exactly one -node, got " + count); Try / catch
try { parseEditLine(line, attrs, lang); } catch (SsurgeonParseException e) { if (e.getMessage().startsWith("Cannot make a DeleteLeaf")) log.error("deleteleaf requires exactly one -node: " + line); } Prevention
- Always pass exactly one -node to deleteleaf
- Don't reuse multi-node ops as templates for deleteleaf
- Confirm the named node is a leaf in matched graphs
When it happens
Trigger: A 'deleteleaf' edit line with no -node flag or with two or more -node flags.
Common situations: Copy-pasting delete rules and stacking -node flags; assuming deleteleaf accepts a node list like MergeNodes does; missing the -node flag when writing the rule from scratch.
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
- Cannot make a DeleteGraphFromNode out of " +…
- Cannot make a Lemmatize out of " + argsBox.nodes.size() + "…
- Cannot make an EditNode out of " + argsBox.nodes.size() + "…
- Cannot make a KillAllIncomingEdges out of " +…
- Cannot make a MergeNodes out of fewer than 2 nodes (got " +…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/6698deab6aed337c.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java:636
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));
} else if (command.equalsIgnoreCase(DeleteLeaf.LABEL)) {
if (argsBox.nodes.size() != 1) {
throw new SsurgeonParseException("Cannot make a DeleteLeaf out of " + argsBox.nodes.size() + " nodes");
}
return new DeleteLeaf(argsBox.nodes.get(0));
} else if (command.equalsIgnoreCase(EditNode.LABEL)) {
if (argsBox.nodes.size() != 1) {
throw new SsurgeonParseException("Cannot make an EditNode out of " + argsBox.nodes.size() + " nodes. Please use exactly one -node");
}
return new EditNode(argsBox.nodes.get(0), argsBox.annotations, argsBox.updateMorphoFeatures, argsBox.remove, argsBox.removeMorphoFeatures);
} else if (command.equalsIgnoreCase(Lemmatize.LABEL)) {
if (argsBox.nodes.size() != 1) {
throw new SsurgeonParseException("Cannot make a Lemmatize out of " + argsBox.nodes.size() + " nodes. Please use exactly one -node");
}
return new Lemmatize(argsBox.nodes.get(0), language);
} else if (command.equalsIgnoreCase(MergeNodes.LABEL)) {
if (argsBox.nodes.size() < 2) {
throw new SsurgeonParseException("Cannot make a MergeNodes out of fewer than 2 nodes (got " + argsBox.nodes.size() + ")");
}
return new MergeNodes(argsBox.nodes, argsBox.annotations);
} else if (command.equalsIgnoreCase(RelabelNamedEdge.LABEL)) {View on GitHub (pinned to 1b7edd19c4)