stanfordnlp/CoreNLP · error · IllegalArgumentException
Unknown argument:
Error message
Unknown argument:
What it means
AddTaggerToParser.main parses its command-line arguments with a hand-rolled loop that throws IllegalArgumentException for any flag it does not recognize. The message concatenates the offending token so the user can see which argument was rejected.
Solutions
- Use only the supported flags (e.g. -input, -output, -weight); check the source for exact names
- Fix the misspelled flag name in the command line
- Remove arguments intended for other tools
Example fix
// before java AddTaggerToParser -model parser.ser.gz -tagger tagger.ser.gz -output out.ser.gz // after java AddTaggerToParser -input parser.ser.gz -taggerFile tagger.ser.gz -output out.ser.gz
Defensive patterns
Strategy: validation
Validate before calling
// validate flags before invoking
Set<String> allowed = Set.of("-input", "-output", "-weight");
for (int i = 0; i < args.length; i += 2) {
if (!allowed.contains(args[i].toLowerCase())) {
throw new IllegalArgumentException("Unsupported flag for AddTaggerToParser: " + args[i]);
}
} Try / catch
try {
AddTaggerToParser.main(args);
} catch (IllegalArgumentException e) {
System.err.println("Bad flag: " + e.getMessage() + " — allowed: -input, -output, -weight");
System.exit(2);
} Prevention
- Read the arg-parsing loop in AddTaggerToParser before building the command line
- Do not copy flag lists from other LexicalizedParser tools
- Keep tool invocations in scripts with per-tool flag whitelists
When it happens
Trigger: Invoking the tool with a flag other than the supported ones (e.g. -input, -output, -weight variants misspelled, or flags copied from other LexicalizedParser tools such as -model or -taggerFile that this tool does not implement).
Common situations: Copy-pasting option lists between Stanford parser tools; typo like '-inputFile' instead of the exact supported flag; quoting mistakes leaving stray tokens in args.
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 " + args[argIndex]
- Unknown argument " + args[argIndex]
- Unknown argument
- Unknown argument
- Unknown argument
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/eace6d4f6d4e280b.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/lexparser/AddTaggerToParser.java:33
String outputFile = null;
double weight = 1.0;
for (int argIndex = 0; argIndex < args.length; ) {
if (args[argIndex].equalsIgnoreCase("-tagger")) {
taggerFile = args[argIndex + 1];
argIndex += 2;
} else if (args[argIndex].equalsIgnoreCase("-input")) {
inputFile = args[argIndex + 1];
argIndex += 2;
} else if (args[argIndex].equalsIgnoreCase("-output")) {
outputFile = args[argIndex + 1];
argIndex += 2;
} else if (args[argIndex].equalsIgnoreCase("-weight")) {
weight = Double.valueOf(args[argIndex + 1]);
argIndex += 2;
} else {
throw new IllegalArgumentException("Unknown argument: " + args[argIndex]);
}
}
LexicalizedParser parser = LexicalizedParser.loadModel(inputFile);
MaxentTagger tagger = new MaxentTagger(taggerFile);
parser.reranker = new TaggerReranker(tagger, parser.getOp());
parser.saveParserToSerialized(outputFile);
}
}
View on GitHub (pinned to 1b7edd19c4)