{"record":{"id":"536e212d44675358","repo":"stanfordnlp/CoreNLP","slug":"unknown-option","errorCode":null,"errorMessage":"Unknown option: ","messagePattern":"Unknown option: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/lexparser/Options.java","lineNumber":179,"sourceCode":"   * <li> <code>-printTT</code> print the training trees in raw, annotated, and annotated+binarized form.  Useful for debugging and other miscellany.\n   * <li> <code>-printAnnotated filename</code> use only in conjunction with -printTT.  Redirects printing of annotated training trees to <code>filename</code>.\n   * <li> <code>-forceTags</code> when the parser is tested against a set of gold standard trees, use the tagged yield, instead of just the yield, as input.\n   * </ul>\n   *\n   * @param flags An array of options arguments, command-line style.  E.g. {\"-maxLength\", \"50\"}.\n   * @param i The index in flags to start at when processing an option\n   * @return The index in flags of the position after the last element used in\n   *      processing this option.\n   * @throws IllegalArgumentException If the current array position cannot be\n   *      processed as a valid option\n   */\n  public int setOption(String[] flags, int i) {\n    int j = setOptionFlag(flags, i);\n    if (j == i) {\n      j = tlpParams.setOptionFlag(flags, i);\n    }\n    if (j == i) {\n      throw new IllegalArgumentException(\"Unknown option: \" + flags[i]);\n    }\n    return j;\n  }\n\n  /**\n   * Set an option in this object, based on a String array in the style of\n   * commandline flags.  The option is only processed with respect to\n   * options directly known by the Options object.\n   * Some options (there are many others; see the source code):\n   * <ul>\n   * <li> <code>-maxLength n</code> set the maximum length sentence to parse (inclusively)\n   * <li> <code>-printTT</code> print the training trees in raw, annotated, and annotated+binarized form.  Useful for debugging and other miscellany.\n   * <li> <code>-printAnnotated filename</code> use only in conjunction with -printTT.  Redirects printing of annotated training trees to <code>filename</code>.\n   * <li> <code>-forceTags</code> when the parser is tested against a set of gold standard trees, use the tagged yield, instead of just the yield, as input.\n   * </ul>\n   *\n   * @param args An array of options arguments, command-line style.  E.g. {\"-maxLength\", \"50\"}.\n   * @param i The index in args to start at when processing an option","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/Options.java#L161-L197","documentation":"Options.setOption resolves a command-line flag first via the lexparser option flags and then via the TreebankLanguagePack params; if neither consumes the flag, it throws IllegalArgumentException('Unknown option: ...'). It guarantees that every training/test flag passed to the parser is actually recognized.","triggerScenarios":"Passing a flag string (e.g., via Options.setOptions, main(), or -props-style command lines) that neither setOptionFlag nor tlpParams.setOptionFlag recognizes, so the returned index equals the input index i.","commonSituations":"Typos in flags (e.g., '-maxLen' instead of '-maxLength'), flags removed or renamed across Stanford Parser versions, or flags that belong to a different parser package.","solutions":["Fix the flag spelling/name in your argument list.","Run the parser with no arguments or consult the lexparser options documentation for valid flags for your version.","If it is a version mismatch, check the release notes and update or remove obsolete flags.","Pass a supported -tlpp / treebank language pack if the flag is language-pack specific."],"exampleFix":"// before\noptions.setOptions(new String[]{\"-maxLen\", \"40\"});\n// after\noptions.setOptions(new String[]{\"-maxLength\", \"40\"});","handlingStrategy":"validation","validationCode":"Set<String> validFlags = Set.of(\"-maxLength\",\"-outputFormat\",\"-tlpp\",\"-writeGrammarFiles\");\nfor (int i = 0; i < args.length; i++) if (args[i].startsWith(\"-\")) assert validFlags.contains(args[i]) : \"Unknown flag: \" + args[i];","typeGuard":null,"tryCatchPattern":"try {\n  options.setOptions(flags);\n} catch (IllegalArgumentException e) {\n  System.err.println(\"Bad parser flag: \" + e.getMessage());\n}","preventionTips":["Copy flags only from the documentation/source of your exact parser version.","Run 'java -cp jar edu.stanford.nlp.parser.lexparser.LexicalizedParser' with no args to see usage.","Add a smoke test that applies your flag list to Options.setOptions in CI.","Keep training scripts and parser jar versions in sync."],"tags":["cli","parser-options","illegal-argument"],"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-17T15:17:12.973Z"}