stanfordnlp/CoreNLP · error · IllegalArgumentException

Please specify either -file, -fileList or -stdin

Error message

Please specify either -file, -fileList or -stdin

What it means

SentimentPipeline's main() requires exactly one input source: -file, -fileList, or -stdin. The library throws this IllegalArgumentException when the count of provided input-source options is zero, i.e. the user gave no way to obtain the text to annotate.

Solutions

  1. Add exactly one of -file <path>, -fileList <file-of-paths>, or -stdin to the command line.
  2. Check flag spelling/case: options are matched exactly (-file, -fileList, -stdin).
  3. If piping input, remember -stdin must be explicitly given; the tool never defaults to stdin.

Example fix

// before
java edu.stanford.nlp.sentiment.SentimentPipeline -model model.ser.gz
// after
java edu.stanford.nlp.sentiment.SentimentPipeline -model model.ser.gz -file input.txt
Defensive patterns

Strategy: validation

Validate before calling

// Java: validate args before invoking SentimentPipeline.main
Set<String> provided = new HashSet<>(Arrays.asList(args));
long count = (provided.contains("-file")?1:0)+(provided.contains("-fileList")?1:0)+(provided.contains("-stdin")?1:0);
if (count == 0) throw new IllegalArgumentException("provide exactly one of -file, -fileList, -stdin");

Prevention

When it happens

Trigger: Running java edu.stanford.nlp.sentiment.SentimentPipeline with none of -file, -fileList, or -stdin on the command line (count==0 in main at SentimentPipeline.java:339).

Common situations: Users forget the input flag entirely, mis-spell it (e.g. -File, --file), or pass options via a properties file assuming input is configured there when it must be a CLI flag.

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/62fccbe99bbdb9b0. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/sentiment/SentimentPipeline.java:339

      pipelineProps.setProperty("parse.buildgraphs", "false");
      pipelineProps.setProperty("enforceRequirements", "false");
      tokenizerProps = new Properties();
      tokenizerProps.setProperty("annotators", "tokenize, ssplit");
    }

    if (stdin && tokenizerProps != null) {
      tokenizerProps.setProperty(StanfordCoreNLP.NEWLINE_SPLITTER_PROPERTY, "true");
    }

    int count = 0;
    if (filename != null) count++;
    if (fileList != null) count++;
    if (stdin) count++;
    if (count > 1) {
      throw new IllegalArgumentException("Please only specify one of -file, -fileList or -stdin");
    }
    if (count == 0) {
      throw new IllegalArgumentException("Please specify either -file, -fileList or -stdin");
    }

    StanfordCoreNLP tokenizer = (tokenizerProps == null) ? null : new StanfordCoreNLP(tokenizerProps);
    StanfordCoreNLP pipeline = new StanfordCoreNLP(pipelineProps);

    if (filename != null) {
      // Process a file.  The pipeline will do tokenization, which
      // means it will split it into sentences as best as possible
      // with the tokenizer.
      List<Annotation> annotations = getAnnotations(tokenizer, inputFormat, filename, filterUnknown);
      for (Annotation annotation : annotations) {
        pipeline.annotate(annotation);

        for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
          System.out.println(sentence);
          outputTree(System.out, sentence, outputFormats);
        }
      }

View on GitHub (pinned to 1b7edd19c4)