stanfordnlp/CoreNLP · error · IllegalArgumentException
Unknown argument
Error message
Unknown argument ${args[argIndex]} What it means
A command-line argument parse failure in the ConvertGenderFile static main tool: it only accepts -input and -output flags (each with a value); any other token on the command line triggers this IllegalArgumentException, indicating a typo or unsupported flag.
Solutions
- Only pass -input <file> and -output <file> arguments
- Fix any misspelled flags
- Check the tool's usage/main source for the accepted flag set
Example fix
// before java ConvertGenderFile -in gender.txt -out gender.ser // after java ConvertGenderFile -input gender.txt -output gender.ser
Defensive patterns
Strategy: validation
Validate before calling
List<String> allowed = Arrays.asList("-input", "-output");
for (int i = 0; i < args.length; i += 2) {
if (!allowed.contains(args[i].toLowerCase())) throw new IllegalArgumentException("Unknown arg " + args[i]);
} Try / catch
try {
ConvertGenderFile.main(args);
} catch (IllegalArgumentException e) {
System.err.println("Usage: ConvertGenderFile -input <file> -output <file>");
} Prevention
- Only pass -input and -output flags to ConvertGenderFile
- Keep each flag followed by exactly one value
- Check the tool's main() for the accepted flag list
- Avoid copy-pasting flag sets between different CoreNLP utilities
When it happens
Trigger: Running java edu.stanford.nlp.dcoref.util.ConvertGenderFile with an argument other than -input/-output, e.g. misspelled flags or extra positional arguments.
Common situations: Typo like -in instead of -input; passing flags copied from another CoreNLP tool; adding a stray filename without a flag.
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
- Invalid metricType
- Invalid sub score type
- Must specify input with -input
- Must specify output with -output
- is not a legal LogPrior.
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/c216562647c67606.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/dcoref/util/ConvertGenderFile.java:37
*
* @author John Bauer
*/
public class ConvertGenderFile {
private ConvertGenderFile() {} // static class
public static void main(String[] args) throws IOException {
String input = null;
String output = null;
for (int argIndex = 0; argIndex < args.length; ) {
if (args[argIndex].equalsIgnoreCase("-input")) {
input = args[argIndex + 1];
argIndex += 2;
} else if (args[argIndex].equalsIgnoreCase("-output")) {
output = args[argIndex + 1];
argIndex += 2;
} else {
throw new IllegalArgumentException("Unknown argument " + args[argIndex]);
}
}
if (input == null) {
throw new IllegalArgumentException("Must specify input with -input");
}
if (output == null) {
throw new IllegalArgumentException("Must specify output with -output");
}
Map<List<String>, Gender> genderNumber = Generics.newHashMap();
BufferedReader reader = IOUtils.readerFromString(input);
for (String line; (line = reader.readLine()) != null; ) {
String[] split = line.split("\t");
String[] countStr = split[1].split(" ");
View on GitHub (pinned to 1b7edd19c4)