{"record":{"id":"dc8accaf8c6c95ef","repo":"stanfordnlp/CoreNLP","slug":"unknown-argument-dc8acc","errorCode":null,"errorMessage":"Unknown argument ","messagePattern":"Unknown argument ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/sentiment/SentimentTraining.java","lineNumber":177,"sourceCode":"      } else if (args[argIndex].equalsIgnoreCase(\"-gradientcheck\")) {\n        runGradientCheck = true;\n        argIndex++;\n      } else if (args[argIndex].equalsIgnoreCase(\"-trainpath\")) {\n        trainPath = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-devpath\")) {\n        devPath = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-model\")) {\n        modelPath = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-filterUnknown\")) {\n        filterUnknown = true;\n        argIndex++;\n      } else {\n        int newArgIndex = op.setOption(args, argIndex);\n        if (newArgIndex == argIndex) {\n          throw new IllegalArgumentException(\"Unknown argument \" + args[argIndex]);\n        }\n        argIndex = newArgIndex;\n      }\n    }\n\n    // read in the trees\n    List<Tree> trainingTrees = SentimentUtils.readTreesWithGoldLabels(trainPath);\n    log.info(\"Read in \" + trainingTrees.size() + \" training trees\");\n    if (filterUnknown) {\n      trainingTrees = SentimentUtils.filterUnknownRoots(trainingTrees);\n      log.info(\"Filtered training trees: \" + trainingTrees.size());\n    }\n\n    List<Tree> devTrees = null;\n    if (devPath != null) {\n      devTrees = SentimentUtils.readTreesWithGoldLabels(devPath);\n      log.info(\"Read in \" + devTrees.size() + \" dev trees\");\n      if (filterUnknown) {","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/sentiment/SentimentTraining.java#L159-L195","documentation":"SentimentTraining's main() parses its own args first (e.g. -train, -test, -filterUnknown) and then delegates the rest to Options.setOption. If that call consumes no arguments, the current token is unrecognized and an IllegalArgumentException naming the token is thrown.","triggerScenarios":"Passing a flag that neither SentimentTraining's arg loop nor the training Options object recognizes, e.g. a typo like -traiFile, or an option belonging to a different tool (such as pipeline flags) at SentimentTraining.java:177.","commonSituations":"Copy-pasting command lines between Stanford NLP tools (SentimentPipeline and SentimentTraining accept different flags), typos, or removed/renamed training options across CoreNLP versions.","solutions":["Remove or correct the unrecognized argument in the command line.","Check the tool's usage: only training flags (-train, -test, -dev, -model, -filterUnknown, etc.) plus Options-settable flags are accepted.","Verify against the CoreNLP version in use — option names change between releases.","Prefix generic Options flags correctly (many need a prefix, e.g. -trainTrees vs plain flags)."],"exampleFix":"// before\njava edu.stanford.nlp.sentiment.SentimentTraining -train train.txt -dev dev.txt -model model.ser.gz -threads 4 -unknownFlag\n// after\njava edu.stanford.nlp.sentiment.SentimentTraining -train train.txt -dev dev.txt -model model.ser.gz -trainTrees -threads 4","handlingStrategy":"validation","validationCode":"// whitelist known flags before invoking the trainer\nSet<String> known = Set.of(\"-train\",\"-test\",\"-dev\",\"-model\",\"-filterUnknown\",\"-trainTrees\",\"-threads\");\nfor (String a : args) if (a.startsWith(\"-\") && !known.contains(a)) throw new IllegalArgumentException(\"unknown flag: \" + a);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy command lines only between identical tools (SentimentTraining vs SentimentPipeline flags differ).","Verify flags against the CoreNLP version's docs.","Run with a small dataset first to surface arg errors early."],"tags":["java","cli","stanford-corenlp","argument-parsing"],"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"}