stanfordnlp/CoreNLP · error · RuntimeException
args: treebankPath trainNums testNums
Error message
args: treebankPath trainNums testNums
What it means
The CharacterLevelTagExtender main() requires exactly three command-line arguments: a treebank path, training file numbers, and test file numbers. When the argument count differs from 3, it deliberately aborts with this RuntimeException rather than guessing the caller's intent. It is a usage-guard error thrown before any parsing work begins.
Solutions
- Pass exactly three arguments: treebankPath, trainNums, testNums, e.g. java CharacterLevelTagExtender /data/ctb 001-050 051-100
- Quote any path containing spaces so it counts as one argument
- Check the class's usage comments to confirm the expected invocation
- Wrap the tool in a script that validates argument count before invoking the JVM
Example fix
// before java CharacterLevelTagExtender /data/ctb 100 // after java CharacterLevelTagExtender /data/ctb 001-100 101-150
Defensive patterns
Strategy: validation
Validate before calling
if (args == null || args.length != 3) {
System.err.println("usage: treebankPath trainNums testNums");
System.exit(2);
} Type guard
boolean hasValidArgs(String[] args) { return args != null && args.length == 3; } Prevention
- Quote paths with spaces in shell scripts
- Validate argument count in wrapper scripts before launching the JVM
- Keep the documented usage line in your run scripts
When it happens
Trigger: Running CharacterLevelTagExtender as a Java main class with fewer or more than 3 args, e.g. java edu.stanford.nlp.trees.international.pennchinese.CharacterLevelTagExtender /path/to/treebank 100 (missing testNums), or passing extra flags; a path containing unquoted spaces also splits into extra args and inflates the count.
Common situations: Command-line invocations of the Penn Chinese treebank tooling from shell scripts or docs where arguments were copied incompletely, or where a path containing unquoted spaces splits into multiple args and inflates the count.
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
- Cannot find or open + sentFileName
- Error: No dest file provided in properties or via command…
- Error: No training file provided in properties or via…
- Error: No training file provided in properties or via…
- Error: -train option must have treebankPath as first…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/6d5abf26da5b8b0e.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/trees/international/pennchinese/CharacterLevelTagExtender.java:145
pw.println("NOT EQUAL AFTER UNTRANSFORMATION!!!");
pw.println();
oldTree.pennPrint(pw);
pw.println();
tree.pennPrint(pw);
pw.println("------------------");
}
}
}
/**
* for testing -- CURRENTLY BROKEN!!!
*
* @param args input dir and output filename
* @throws IOException
*/
public static void main(String[] args) throws IOException {
if (args.length != 3) {
throw new RuntimeException("args: treebankPath trainNums testNums");
}
ChineseTreebankParserParams ctpp = new ChineseTreebankParserParams();
ctpp.charTags = true;
// TODO: these options are getting clobbered by reading in the
// parser object (unless it's a text file parser?)
Options op = new Options(ctpp);
op.doDep = false;
op.testOptions.maxLength = 90;
LexicalizedParser lp;
try {
FileFilter trainFilt = new NumberRangesFileFilter(args[1], false);
lp = LexicalizedParser.trainFromTreebank(args[0], trainFilt, op);
try {
String filename = "chineseCharTagPCFG.ser.gz";
log.info("Writing parser in serialized format to file " + filename + " ");View on GitHub (pinned to 1b7edd19c4)