stanfordnlp/CoreNLP · error · IllegalArgumentException

Must specify input file with -input

Error message

Must specify input file with -input

What it means

BuildBinarizedDataset.main requires an -input argument naming the file of label+phrase lines to binarize. If inputPath is null after argument parsing, it throws IllegalArgumentException immediately, before loading the parser model.

Solutions

  1. Pass -input <file> on the command line
  2. Verify flag spelling and that the path variable in your script is non-empty
  3. Check argument order/quotes so the value is attached to the right flag

Example fix

// before
java BuildBinarizedDataset -parserModel model.gz
// after
java BuildBinarizedDataset -parserModel model.gz -input phrases.txt
Defensive patterns

Strategy: validation

Validate before calling

if (args == null || Arrays.stream(args).noneMatch(a -> a.equals("-input"))) {
  throw new IllegalArgumentException("-input is required");
}

Try / catch

try {
  BuildBinarizedDataset.main(args);
} catch (IllegalArgumentException e) {
  log.error("Usage: BuildBinarizedDataset -input <file> ...");
}

Prevention

When it happens

Trigger: Running BuildBinarizedDataset without -input <path>, or misspelling the flag so it hits the 'Unknown argument' branch and never sets inputPath.

Common situations: Batch scripts where the input path variable is unset; mixing up -input with other flags like -parserModel; omitted flags when adapting example commands.

Understand the failure class

Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/23024f6fe50f2b4d. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/sentiment/BuildBinarizedDataset.java:186

    for (int argIndex = 0; argIndex < args.length; ) {
      if (args[argIndex].equalsIgnoreCase("-input")) {
        inputPath = args[argIndex + 1];
        argIndex += 2;
      } else if (args[argIndex].equalsIgnoreCase("-parserModel")) {
        parserModel = args[argIndex + 1];
        argIndex += 2;
      } else if (args[argIndex].equalsIgnoreCase("-sentimentModel")) {
        sentimentModelPath = args[argIndex + 1];
        argIndex += 2;
      } else {
        log.info("Unknown argument " + args[argIndex]);
        System.exit(2);
      }
    }

    if (inputPath == null) {
      throw new IllegalArgumentException("Must specify input file with -input");
    }

    LexicalizedParser parser = LexicalizedParser.loadModel(parserModel);
    TreeBinarizer binarizer = TreeBinarizer.simpleTreeBinarizer(parser.getTLPParams().headFinder(), parser.treebankLanguagePack());

    if (sentimentModelPath != null) {
      sentimentModel = SentimentModel.loadSerialized(sentimentModelPath);
    }

    String text = IOUtils.slurpFileNoExceptions(inputPath);
    String[] chunks = text.split("\\n\\s*\\n+"); // need blank line to make a new chunk

    for (String chunk : chunks) {
      if (chunk.trim().isEmpty()) {
        continue;
      }
      // The expected format is that line 0 will be the text of the
      // sentence, and each subsequence line, if any, will be a value

View on GitHub (pinned to 1b7edd19c4)