{"record":{"id":"eace6d4f6d4e280b","repo":"stanfordnlp/CoreNLP","slug":"unknown-argument","errorCode":null,"errorMessage":"Unknown argument: ","messagePattern":"Unknown argument: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/lexparser/AddTaggerToParser.java","lineNumber":33,"sourceCode":"    String outputFile = null;\n\n    double weight = 1.0;\n    \n    for (int argIndex = 0; argIndex < args.length; ) {\n      if (args[argIndex].equalsIgnoreCase(\"-tagger\")) {\n        taggerFile = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-input\")) {\n        inputFile = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-output\")) {\n        outputFile = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-weight\")) {\n        weight = Double.valueOf(args[argIndex + 1]);\n        argIndex += 2;\n      } else {\n        throw new IllegalArgumentException(\"Unknown argument: \" + args[argIndex]);\n      }\n    }\n\n    LexicalizedParser parser = LexicalizedParser.loadModel(inputFile);\n    MaxentTagger tagger = new MaxentTagger(taggerFile);\n    parser.reranker = new TaggerReranker(tagger, parser.getOp());\n    parser.saveParserToSerialized(outputFile);\n  }\n}\n","sourceCodeStart":15,"sourceCodeEnd":43,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/AddTaggerToParser.java#L15-L43","documentation":"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.","triggerScenarios":"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).","commonSituations":"Copy-pasting option lists between Stanford parser tools; typo like '-inputFile' instead of the exact supported flag; quoting mistakes leaving stray tokens in args.","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"],"exampleFix":"// before\njava AddTaggerToParser -model parser.ser.gz -tagger tagger.ser.gz -output out.ser.gz\n// after\njava AddTaggerToParser -input parser.ser.gz -taggerFile tagger.ser.gz -output out.ser.gz","handlingStrategy":"validation","validationCode":"// validate flags before invoking\nSet<String> allowed = Set.of(\"-input\", \"-output\", \"-weight\");\nfor (int i = 0; i < args.length; i += 2) {\n  if (!allowed.contains(args[i].toLowerCase())) {\n    throw new IllegalArgumentException(\"Unsupported flag for AddTaggerToParser: \" + args[i]);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  AddTaggerToParser.main(args);\n} catch (IllegalArgumentException e) {\n  System.err.println(\"Bad flag: \" + e.getMessage() + \" — allowed: -input, -output, -weight\");\n  System.exit(2);\n}","preventionTips":["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"],"tags":["java","cli","argument-parsing","stanford-parser"],"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"}