stanfordnlp/CoreNLP · error · SsurgeonParseException
Error in SsurgeonEdit.parseEditLine: invalid number of…
Error message
Error in SsurgeonEdit.parseEditLine: invalid number of arguments
What it means
SsurgeonEdit.parseEditLine first splits the edit line on whitespace and expects at least the operation name. SsurgeonParseException('invalid number of arguments') is thrown when the line splits to nothing usable, i.e. an empty or blank edit line was handed to the parser.
Solutions
- Skip blank lines when feeding lines to parseEditLine (check line.trim().isEmpty() first).
- Verify the rule resource file has no empty rule entries between separators.
- Catch SsurgeonParseException and log which rule line number failed so the empty one can be fixed.
Example fix
// before SsurgeonEdit.parseEditLine(line, attributeArgs, language); // after if (line.trim().isEmpty()) continue; SsurgeonEdit.parseEditLine(line, attributeArgs, language);
Defensive patterns
Strategy: validation
Validate before calling
for (String line : ruleText.split("\n")) {
if (!line.trim().isEmpty()) SsurgeonEdit.parseEditLine(line.trim(), Map.of(), language);
} Try / catch
try { parseLine(line); } catch (SsurgeonParseException e) { if (e.getMessage().contains("invalid number of arguments")) log.warn("Skipping blank rule line"); } Prevention
- Filter blank lines before parsing rule text
- Trim lines read from resource files
- Validate rule files at startup, not at match time
When it happens
Trigger: Calling SsurgeonEdit.parseEditLine (or Ssurgeon processRuleTexts / fromString) with an empty string or whitespace-only line, so editLine.split("\\s+", 2) yields fewer than 1 meaningful element.
Common situations: Rule files with blank lines not filtered before parsing; a resources file read producing empty entries; programmatically building rules with an empty string due to an upstream concatenation bug.
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
- SplitWord got an index in -name which was larger than the…
- Unmatched quote in string to parse
- Parsing Ssurgeon args: unknown flag
- Relation not specified for AddDep
- Relation not specified for AddEdge
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/e1fa099e45684509.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java:598
Class<? extends CoreAnnotation<?>> annotation = AnnotationLookup.toCoreKey(key);
if (annotation == null) {
throw new SsurgeonParseException("Parsing Ssurgeon args: unknown flag " + argsKey);
}
argsBox.annotations.put(key, argsValue);
}
}
return argsBox;
}
/**
* Given a string entry, converts it into a SsurgeonEdit object.
*/
public static SsurgeonEdit parseEditLine(String editLine, Map<String, String> attributeArgs, Language language) {
try {
// Extract the operation name first
final String[] tuples1 = editLine.split("\\s+", 2);
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");
}View on GitHub (pinned to 1b7edd19c4)