stanfordnlp/CoreNLP · error · RuntimeException
No test treebank path specified...
Error message
No test treebank path specified...
What it means
During testing in ChineseLexiconAndWordSegmenter.main, a test treebank path is required. When -testTreebank/-testPath was not given and no training treebank path exists to fall back on, main throws RuntimeException telling the user to specify a test treebank path. If a train path exists, it is reused with just a log message instead.
Solutions
- Pass the test treebank path explicitly, e.g. -testTreebank /path/to/testTreebank or -testPath ...
- Or include a -train option with a valid treebankPath so the code can default testPath to the train path
- Verify the option spelling matches what main() parses
Example fix
// before java ... -testFilter 0-100 // after java ... -testTreebank /path/to/testTreebank -testFilter 0-100
Defensive patterns
Strategy: validation
Validate before calling
boolean hasTestPath = argList.contains("-testPath") || argList.contains("-testTreebank"); boolean hasTrainPath = argList.contains("-train"); if (!hasTestPath && !hasTrainPath) throw new IllegalArgumentException("specify test treebank path"); Try / catch
try { main(args); } catch (RuntimeException e) { if (e.getMessage().startsWith("No test treebank path")) { args = add(args, "-testPath", defaultTestPath); main(args); } } Prevention
- Always set -testTreebank/-testPath explicitly for test runs
- Or include -train so the train path can be reused as the test path
When it happens
Trigger: Running main() with a test filter configured but neither testPath nor treebankPath set — i.e., testing was requested without ever supplying a path to the test treebank and no train path is available.
Common situations: Running a test-only invocation (no -train) but forgetting -testTreebank path; misspelled path option so it was never parsed; scripting that builds arguments dynamically and drops the test path.
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
- Error: -train option must have treebankPath as first…
- 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…
- -labels is required
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/fee7d280f5ccdaa0.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/lexparser/ChineseLexiconAndWordSegmenter.java:572
serializedInputFileOrUrl = args[argIndex];
argIndex++;
}
try {
cs = new ChineseLexiconAndWordSegmenter(serializedInputFileOrUrl, op);
} catch (IllegalArgumentException e) {
log.info("Error loading segmenter, exiting...");
System.exit(0);
}
}
// the following has to go after reading parser to make sure
// op and tlpParams are the same for train and test
TreePrint treePrint = op.testOptions.treePrint(tlpParams);
if (testFilter != null) {
if (testPath == null) {
if (treebankPath == null) {
throw new RuntimeException("No test treebank path specified...");
} else {
log.info("No test treebank path specified. Using train path: \"" + treebankPath + "\"");
testPath = treebankPath;
}
}
testTreebank = tlpParams.testMemoryTreebank();
testTreebank.loadPath(testPath, testFilter);
}
op.trainOptions.sisterSplitters = Generics.newHashSet(Arrays.asList(tlpParams.sisterSplitters()));
// at this point we should be sure that op.tlpParams is
// set appropriately (from command line, or from grammar file),
// and will never change again. We also set the tlpParams of the
// LexicalizedParser instance to be the same object. This is
// redundancy that we probably should take out eventually.
//
// -- RogerView on GitHub (pinned to 1b7edd19c4)