{"record":{"id":"09bcf05498cbcd9d","repo":"stanfordnlp/CoreNLP","slug":"unknown-argument-newargs-argindex","errorCode":null,"errorMessage":"Unknown argument \" + newArgs[argIndex]","messagePattern":"Unknown argument \" \\+ newArgs\\[argIndex\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/sentiment/Evaluate.java","lineNumber":144,"sourceCode":"      } else if (args[argIndex].equalsIgnoreCase(\"-treebank\")) {\n        treePath = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-filterUnknown\")) {\n        filterUnknown = true;\n        argIndex++;\n      } else {\n        remainingArgs.add(args[argIndex]);\n        argIndex++;\n      }\n    }\n    String[] newArgs = new String[remainingArgs.size()];\n    remainingArgs.toArray(newArgs);\n    SentimentModel model = SentimentModel.loadSerialized(modelPath);\n    for (int argIndex = 0; argIndex < newArgs.length;) {\n      int newIndex = model.op.setOption(newArgs, argIndex);\n      if (argIndex == newIndex) {\n        log.info(\"Unknown argument \" + newArgs[argIndex]);\n        throw new IllegalArgumentException(\"Unknown argument \" + newArgs[argIndex]);\n      }\n      argIndex = newIndex;\n    }\n    List<Tree> trees = SentimentUtils.readTreesWithGoldLabels(treePath);\n    if (filterUnknown) {\n      trees = SentimentUtils.filterUnknownRoots(trees);\n    }\n    Evaluate eval = new Evaluate(model);\n    eval.eval(trees);\n    eval.printSummary();\n  }\n\n}\n","sourceCodeStart":126,"sourceCodeEnd":158,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/sentiment/Evaluate.java#L126-L158","documentation":"Evaluate.main loads a serialized SentimentModel then feeds remaining args to model.op.setOption; if setOption consumes nothing (argIndex unchanged), the argument is unrecognized and it throws IllegalArgumentException after logging it. It guards against silently ignoring mistyped options.","triggerScenarios":"Running Evaluate with any flag not understood by RNNOptions.setOption, e.g. a typo like -modle, or an option that belongs to a different sentiment tool.","commonSituations":"Copying command lines from tutorials for a different class; renamed/removed options across CoreNLP versions; quoting mistakes producing stray tokens in args.","solutions":["Fix or remove the unrecognized flag reported in the log message","Check RNNOptions.setOption for the exact supported option names","Verify you are running the intended sentiment entry point (Evaluate vs other mains) for your flags"],"exampleFix":"// before\njava Evaluate -model model.ser.gz -treepath trees.txt -modle ...\n// after\njava Evaluate -model model.ser.gz -treepath trees.txt","handlingStrategy":"try-catch","validationCode":"for (String a : args) {\n  if (a.startsWith(\"-\") && !KNOWN_FLAGS.contains(a)) throw new IllegalArgumentException(\"Unknown flag: \" + a);\n}","typeGuard":null,"tryCatchPattern":"try {\n  Evaluate.main(args);\n} catch (IllegalArgumentException e) {\n  log.error(\"Bad Evaluate option: \" + e.getMessage());\n}","preventionTips":["Keep a whitelist of supported flags per tool version","Re-check flags when upgrading CoreNLP versions","Test command lines in a dry-run script before batch runs"],"tags":["cli","sentiment","arguments"],"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"}