stanfordnlp/CoreNLP · error · java.lang.IllegalArgumentException
Unknown argument
Error message
Unknown argument ${args[argIndex]} What it means
CacheParseHypotheses.main() throws this IllegalArgumentException when an unrecognized argument is passed to its option parser. The tool only accepts flags such as -model, -output, and -numThreads; anything else is rejected.
Solutions
- Restrict arguments to the supported flags: -model, -output, -numThreads
- Fix the typo in the offending argument
- Ensure every flag's value is present and properly quoted
Example fix
// before java CacheParseHypotheses -model parser.gz -cacheFile out // after java CacheParseHypotheses -model parser.gz -output out
Defensive patterns
Strategy: validation
Validate before calling
Set<String> allowed = Set.of("-model", "-output", "-numThreads");
for (String a : args) if (a.startsWith("-") && !allowed.contains(a)) throw new IllegalArgumentException("unsupported flag: " + a); Try / catch
try { CacheParseHypotheses.main(args); } catch (IllegalArgumentException e) { System.err.println("Bad arguments: " + e.getMessage()); System.exit(1); } Prevention
- Only pass -model, -output, -numThreads to CacheParseHypotheses
- Always supply -model (required, checked immediately after parsing)
- Validate your command line with a dry-run wrapper before running the tool
When it happens
Trigger: Running CacheParseHypotheses with an unsupported flag, or a flag whose value was quoted incorrectly so the parser lands on the wrong token.
Common situations: Passing options borrowed from other dvparser main classes that this tool does not implement; typos in flag names like -model; missing values causing misalignment of the arg loop.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- Unknown argument
- Bad arguments after
- Must supply either a base parser model with -parser or a…
- Need to either train a new model, run the gradient check or…
- Expected a LexicalizedParser with a Reranker attached
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/14feb6dc8de85038.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/dvparser/CacheParseHypotheses.java:229
continue;
}
if (args[argIndex].equalsIgnoreCase("-output")) {
output = args[argIndex + 1];
argIndex += 2;
continue;
}
if (args[argIndex].equalsIgnoreCase("-treebank")) {
Pair<String, FileFilter> treebankDescription = ArgUtils.getTreebankDescription(args, argIndex, "-treebank");
argIndex = argIndex + ArgUtils.numSubArgs(args, argIndex) + 1;
treebanks.add(treebankDescription);
continue;
}
if (args[argIndex].equalsIgnoreCase("-numThreads")) {
numThreads = Integer.parseInt(args[argIndex + 1]);
argIndex += 2;
continue;
}
throw new IllegalArgumentException("Unknown argument " + args[argIndex]);
}
if (parserModel == null) {
throw new IllegalArgumentException("Need to supply a parser model with -model");
}
if (output == null) {
throw new IllegalArgumentException("Need to supply an output filename with -output");
}
if (treebanks.isEmpty()) {
throw new IllegalArgumentException("Need to supply a treebank with -treebank");
}
log.info("Writing output to " + output);
log.info("Loading parser model " + parserModel);
log.info("Writing " + dvKBest + " hypothesis trees for each tree");
LexicalizedParser parser = LexicalizedParser.loadModel(parserModel, "-dvKBest", Integer.toString(dvKBest));
CacheParseHypotheses cacher = new CacheParseHypotheses(parser);View on GitHub (pinned to 1b7edd19c4)