{"record":{"id":"91900a07549a239c","repo":"stanfordnlp/CoreNLP","slug":"unknown-argument-args-argindex-91900a","errorCode":null,"errorMessage":"Unknown argument \" + args[argIndex]","messagePattern":"Unknown argument \" \\+ args\\[argIndex\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/sentiment/ReadSentimentDataset.java","lineNumber":447,"sourceCode":"        if (numClasses == 2) {\n          trainFilename = args[argIndex + 1] + \"/train-binary.txt\";\n          devFilename = args[argIndex + 1] + \"/dev-binary.txt\";\n          testFilename = args[argIndex + 1] + \"/test-binary.txt\";\n        } else if (numClasses == 3) {\n          trainFilename = args[argIndex + 1] + \"/train-3class.txt\";\n          devFilename = args[argIndex + 1] + \"/dev-3class.txt\";\n          testFilename = args[argIndex + 1] + \"/test-3class.txt\";\n        } else {\n          trainFilename = args[argIndex + 1] + \"/train.txt\";\n          devFilename = args[argIndex + 1] + \"/dev.txt\";\n          testFilename = args[argIndex + 1] + \"/test.txt\";\n        }\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-numClasses\")) {\n        // already been processed\n        argIndex += 2;\n      } else {\n        throw new IllegalArgumentException(\"Unknown argument \" + args[argIndex]);\n      }\n    }\n\n    // Sentence file is formatted\n    //   w1|w2|w3...\n    List<List<String>> sentences = Generics.newArrayList();\n    for (String line : IOUtils.readLines(tokensFilename, \"utf-8\")) {\n      String[] sentence = line.split(\"\\\\|\");\n      sentences.add(Arrays.asList(sentence));\n    }\n\n    // Split and read the phrase ids file.  This file is in the format\n    //   w1 w2 w3 ... | id\n    Map<List<String>, Integer> phraseIds = Generics.newHashMap();\n    for (String line : IOUtils.readLines(dictionaryFilename, \"utf-8\")) {\n      String[] pieces = line.split(\"\\\\|\");\n      String[] sentence = pieces[0].split(\" \");\n      Integer id = Integer.valueOf(pieces[1]);","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/sentiment/ReadSentimentDataset.java#L429-L465","documentation":"IllegalArgumentException from ReadSentimentDataset.main when an unrecognized command-line flag is encountered; only the documented options (input directory, output directory, numClasses, splits, etc.) are accepted.","triggerScenarios":"Running ReadSentimentDataset with a misspelled flag (e.g. '-sentamentLabels'), an unsupported option, or leftover positional garbage in the command line.","commonSituations":"Outdated documentation or scripts referencing flags that were renamed/removed, copy-paste errors in training scripts.","solutions":["Check accepted flags in ReadSentimentDataset.java main and correct the command line","Remove or correct the unknown token in your script","Match exact casing; flags are compared with equalsIgnoreCase so spelling, not case, is the issue"],"exampleFix":"// before\n-readSentimentDataset -dictionary dict.txt -unknownFlag x\n// after\n-readSentimentDataset -dictionary dict.txt -sentimentLabels labels.txt","handlingStrategy":"validation","validationCode":"Set<String> known = Set.of(\"-dictionary\",\"-sentimentLabels\",\"-trainPath\",\"-devPath\",\"-testPath\",\"-model\",\"-numClasses\");\nfor (String a : args) if (a.startsWith(\"-\") && !known.contains(a.toLowerCase())) throw new IllegalArgumentException(\"Unknown argument \" + a);","typeGuard":null,"tryCatchPattern":"try { ReadSentimentDataset.main(args); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unknown argument\")) { printUsage(); } else throw e; }","preventionTips":["Match flag names to the source exactly","Diff old scripts against current tool flags after upgrading CoreNLP"],"tags":["cli","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-17T15:17:12.973Z"}