stanfordnlp/CoreNLP · error · java.lang.IllegalArgumentException
Bad arguments after
Error message
Bad arguments after ${flag} What it means
ArgUtils.getWeightedTreebankDescription() throws this IllegalArgumentException when the argument array following the description flag is malformed — the expected path/filter/optional-weight pattern could not be parsed. It signals that the command-line token layout for a treebank description is invalid.
Solutions
- Check the description syntax: path, filter, and optionally a weight argument after the flag
- Quote arguments containing spaces so the shell passes them as single tokens
- Inspect the parsed token sequence around the flag to find the unexpected token
Example fix
// before -train treebank (missing filter/weight) // after -train /data/treebank "" 1.0
Defensive patterns
Strategy: validation
Validate before calling
if (args.length < argIndex + 2) { throw new IllegalArgumentException("treebank description needs path and filter after " + flag); } Try / catch
try { desc = ArgUtils.getWeightedTreebankDescription(args, argIndex, flag); } catch (IllegalArgumentException e) { System.err.println("Bad treebank description: " + e.getMessage()); System.exit(1); } Prevention
- Quote arguments containing spaces in the shell
- Verify the description syntax (path, filter, optional weight) against the documentation
- Print full argv when debugging flag parsing failures
When it happens
Trigger: Passing a malformed treebank description on the command line, e.g. a missing path or filter after the flag, or leftover unrecognized tokens where the weight should be (when hasWeight is set the parser consumes one extra arg and finds garbage).
Common situations: Typos in the treebank description syntax; quoting mistakes in the shell that split or drop tokens; copying an example with a different flag arity.
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
- Unknown argument
- Unknown argument:
- Unknown argument " + args[argIndex]
- Unknown argument " + args[argIndex]
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/44c65c9ad196a58a.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/common/ArgUtils.java:84
filter = new NumberRangesFileFilter(args[argIndex], true);
}
argIndex++;
} else if (numSubArgs == 3) {
try {
int low = Integer.parseInt(args[argIndex]);
int high = Integer.parseInt(args[argIndex + 1]);
filter = new NumberRangeFileFilter(low, high, true);
argIndex += 2;
} catch (NumberFormatException e) {
// maybe it's a ranges expression?
filter = new NumberRangesFileFilter(args[argIndex++], true);
}
}
if (hasWeight) {
argIndex++;
}
} else {
throw new IllegalArgumentException("Bad arguments after " + flag);
}
return Triple.makeTriple(path, filter, weight);
}
}
View on GitHub (pinned to 1b7edd19c4)