stanfordnlp/CoreNLP · error · SsurgeonParseException
SplitWord got a -name parameter which did not have a number…
Error message
SplitWord got a -name parameter which did not have a number for one of the names. Should look like 0=foo,1=bar
What it means
The optional -name argument of SplitWord assigns semgrex node names to split pieces using the format index=name, comma-separated (e.g. 0=foo,1=bar). Each entry must contain a '=' with a numeric index on the left; otherwise the constructor throws SsurgeonParseException telling you the expected format.
Solutions
- Rewrite the -name argument so every entry is index=name with a 0-based integer index, e.g. -name 0=first,1=second
- Remove trailing commas or empty entries from the nodeNames string
- Validate the string in your tooling with a regex like ^\d+=.+(,\d+=.+)*$ before constructing SplitWord
- Also ensure indices are < nodePieces.size(), which is the next check after this one
Example fix
// before
new SplitWord("w", pieces, 0, reln, "foo,1=bar", true);
// after
new SplitWord("w", pieces, 0, reln, "0=foo,1=bar", true); Defensive patterns
Strategy: validation
Validate before calling
if (nodeNames != null && !nodeNames.matches("\\d+=.+(,\\d+=.+)*")) throw new IllegalArgumentException("-name must look like 0=foo,1=bar"); Try / catch
try { SplitWord sw = new SplitWord(node, pieces, headIndex, reln, names, exact); } catch (SsurgeonParseException e) { log.error("Bad -name format: " + e.getMessage()); } Prevention
- Use the exact index=name, comma-separated format for -name
- Strip whitespace and trailing commas from the names string
- Validate -name against ^\d+=.+(,\d+=.+)*$ before construction and check indices < pieces.size()
When it happens
Trigger: Passing a nodeNames string where any comma-separated entry lacks a '=' or has no numeric index before it, e.g. -name foo,1=bar or -name 0foo.
Common situations: Typo in the -name argument (missing '=' or space instead of '='); copy-pasting a name list from another rule with a different format; an extra empty entry from a trailing comma producing a piece without '='.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- No governor given for an AddDep
- No relation given for an AddDep
- SplitWord expected a -headIndex, 0-indexed for the word…
- SplitWord expected a -reln to represent the dependency to…
- SplitWord expected at least two -exact or -regex
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/da1e1fe49367b4ec.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/SplitWord.java:87
}
if (headIndex == null) {
throw new SsurgeonParseException("SplitWord expected a -headIndex, 0-indexed for the word piece to use when chopping up the word");
}
this.headIndex = headIndex;
if (relation == null) {
throw new SsurgeonParseException("SplitWord expected a -reln to represent the dependency to use for the new words");
}
this.relation = relation;
if (nodeNames != null) {
String[] namePieces = nodeNames.split(",");
this.nodeNames = new HashMap<>();
for (String namePiece : namePieces) {
String[] pieces = namePiece.split("=", 2);
if (pieces.length < 2) {
throw new SsurgeonParseException("SplitWord got a -name parameter which did not have a number for one of the names. Should look like 0=foo,1=bar");
}
int idx = Integer.valueOf(pieces[0]);
if (idx >= nodePieces.size()) {
throw new SsurgeonParseException("SplitWord got an index in -name which was larger than the largest possible split piece, " + idx + " (this is 0-indexed)");
}
this.nodeNames.put(idx, pieces[1]);
}
} else {
this.nodeNames = Collections.emptyMap();
}
}
@Override
public String toEditString() {
StringWriter buf = new StringWriter();
buf.write(LABEL);
buf.write("\t");
buf.write("-node " + node + "\t");View on GitHub (pinned to 1b7edd19c4)