{"record":{"id":"4a0eeef5b3962322","repo":"stanfordnlp/CoreNLP","slug":"unknown-argument-pieces-arg","errorCode":null,"errorMessage":"Unknown argument ${pieces[arg]}","messagePattern":"Unknown argument (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/tagger/maxent/Distsim.java","lineNumber":55,"sourceCode":"\n  private static final Pattern digits = Pattern.compile(\"[0-9]\");\n\n  /**\n   * The Extractor argument extraction keeps ; together, so we use\n   * that to delimit options.  Actually, the only option supported is\n   * mapdigits, which tells the Distsim to try mapping [0-9] to 0 and\n   * requery for an unknown word with digits.\n   */\n  public Distsim(String path) {\n    String[] pieces = path.split(\";\");\n    String filename = pieces[0];\n    for (int arg = 1; arg < pieces.length; ++arg) {\n      if (pieces[arg].equalsIgnoreCase(\"mapdigits\")) {\n        mapdigits = true;\n      } else if (pieces[arg].equalsIgnoreCase(\"casedDistSim\")) {\n        casedDistSim = true;\n      } else {\n        throw new IllegalArgumentException(\"Unknown argument \" + pieces[arg]);\n      }\n    }\n\n    // should work better than String.intern()\n    // interning the strings like this means they should be serialized\n    // in an interned manner, saving disk space and also memory when\n    // loading them back in\n    Interner<String> interner = new Interner<>();\n    lexicon = Generics.newHashMap();\n    // todo [cdm 2016]: Note that this loads file with default file encoding rather than specifying it\n    for (String word : ObjectBank.getLineIterator(new File(filename))) {\n      String[] bits = word.split(\"\\\\s+\");\n      String w = bits[0];\n      if ( ! casedDistSim) {\n        w = w.toLowerCase();\n      }\n      lexicon.put(w, interner.intern(bits[1]));\n    }","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/tagger/maxent/Distsim.java#L37-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nString distsim = \"/path/clusters.tsv;mapDigits=true\";\n// after (exact accepted tokens, comma/space separated per parser)\nString distsim = \"/path/clusters.tsv mapdigits casedDistSim\";","handlingStrategy":"validation","validationCode":"Set<String> allowed = new HashSet<>(Arrays.asList(\"mapdigits\", \"casedDistSim\"));\nfor (String tok : configString.split(\"[ ,]+\")) {\n  if (!allowed.contains(tok)) {\n    throw new IllegalArgumentException(\"Invalid distsim option: \" + tok);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  new Distsim(distsimConfig);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unknown argument \")) {\n    // fix the option token named in the message\n  } else { throw e; }\n}","preventionTips":["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"],"tags":["java","pos-tagger","argument-parsing","config"],"backgroundTag":"invalid-cli-argument","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}