stanfordnlp/CoreNLP · error · IllegalArgumentException
Unknown argument
Error message
Unknown argument ${pieces[arg]} What it means
Distsim parses a cluster-file configuration string where the first token is the file path and remaining tokens are options (mapdigits, casedDistSim). Any unrecognized option token throws this IllegalArgumentException. It is a strict argument validation for the distsim config line.
Solutions
- Check the config string token-by-token and remove or correct any option that is not exactly 'mapdigits' or 'casedDistSim'
- Remember options are flag-style: pass only the bare word, not option=value
- Compare against the exact strings in Distsim.java (equalsIgnoreCase of 'mapdigits' and 'casedDistSim')
- Verify the first token is the path to the actual distsim cluster file so no path words get parsed as options
Example fix
// before String distsim = "/path/clusters.tsv;mapDigits=true"; // after (exact accepted tokens, comma/space separated per parser) String distsim = "/path/clusters.tsv mapdigits casedDistSim";
Defensive patterns
Strategy: validation
Validate before calling
Set<String> allowed = new HashSet<>(Arrays.asList("mapdigits", "casedDistSim"));
for (String tok : configString.split("[ ,]+")) {
if (!allowed.contains(tok)) {
throw new IllegalArgumentException("Invalid distsim option: " + tok);
}
} Try / catch
try {
new Distsim(distsimConfig);
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Unknown argument ")) {
// fix the option token named in the message
} else { throw e; }
} Prevention
- Use only the exact option tokens 'mapdigits' and 'casedDistSim'; they are flags, not key=value pairs
- Keep the distsim file path as the first token, options after
- Copy option names from Distsim.java rather than from memory
- Unit-test config strings before long training runs
When it happens
Trigger: Passing a distsim configuration string (e.g. in tagger training properties via distsim/suffix features) whose token list contains an option other than 'mapdigits' or 'casedDistSim', e.g. distsim=/path/file.txt,unknownopt=true.
Common situations: Copy-pasting option names from older documentation or another tool; typos like 'mapDigits=true' or 'casedistsim=true' variants that don't exactly match; passing key=value style options that this parser does not understand.
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
- TaggedFileRecord argument
- At least two of lang (" + lang + "), openClassTags (length…
- Unsupported inference type: " + flags.crfType
- Unknown inference type: " + flags.inferenceType + ". Your…
- no prior specified
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/4a0eeef5b3962322.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/tagger/maxent/Distsim.java:55
private static final Pattern digits = Pattern.compile("[0-9]");
/**
* The Extractor argument extraction keeps ; together, so we use
* that to delimit options. Actually, the only option supported is
* mapdigits, which tells the Distsim to try mapping [0-9] to 0 and
* requery for an unknown word with digits.
*/
public Distsim(String path) {
String[] pieces = path.split(";");
String filename = pieces[0];
for (int arg = 1; arg < pieces.length; ++arg) {
if (pieces[arg].equalsIgnoreCase("mapdigits")) {
mapdigits = true;
} else if (pieces[arg].equalsIgnoreCase("casedDistSim")) {
casedDistSim = true;
} else {
throw new IllegalArgumentException("Unknown argument " + pieces[arg]);
}
}
// should work better than String.intern()
// interning the strings like this means they should be serialized
// in an interned manner, saving disk space and also memory when
// loading them back in
Interner<String> interner = new Interner<>();
lexicon = Generics.newHashMap();
// todo [cdm 2016]: Note that this loads file with default file encoding rather than specifying it
for (String word : ObjectBank.getLineIterator(new File(filename))) {
String[] bits = word.split("\\s+");
String w = bits[0];
if ( ! casedDistSim) {
w = w.toLowerCase();
}
lexicon.put(w, interner.intern(bits[1]));
}View on GitHub (pinned to 1b7edd19c4)