stanfordnlp/CoreNLP · error · IllegalArgumentException

Please specify -model, either SENTIMENT, DVPARSER…

Error message

Please specify -model, either SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF

What it means

ConvertModels.main parses the -model property into the Model enum; a missing or unrecognized value throws IllegalArgumentException('Please specify -model, either SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF').

Solutions

  1. Add -model with one of SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF
  2. Correct the spelling of the -model value
  3. Check the Model enum in ConvertModels.java for the exact accepted names

Example fix

// before
... -stage NEW -input in.gz -output out.gz
// after
... -stage NEW -model COREF -input in.gz -output out.gz
Defensive patterns

Strategy: validation

Validate before calling

java.util.Set<String> valid = java.util.Set.of("SENTIMENT","DVPARSER","EMBEDDING","COREF","FASTCOREF");
if (model == null || !valid.contains(model.trim().toUpperCase(java.util.Locale.ROOT))) {
  throw new IllegalArgumentException("-model must be one of " + valid);
}

Try / catch

try {
  ConvertModels.main(args);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("-model")) {
    System.err.println("Accepted -model values: SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF");
    System.exit(2);
  }
  throw e;
}

Prevention

When it happens

Trigger: Running main without -model, or with a value not in {SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF}.

Common situations: Choosing the wrong converter invocation for the model type, typos like 'COREFMODEL', or following outdated docs that predate some enum entries.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/neural/ConvertModels.java:386

   * <br>
   *
   * @author <a href=horatio@gmail.com>John Bauer</a>
   */
  public static void main(String[] args) throws IOException, ClassNotFoundException, InstantiationException, NoSuchMethodException {
    Properties props = StringUtils.argsToProperties(args);

    final Stage stage;
    try {
      stage = Stage.valueOf(props.getProperty("stage").toUpperCase(Locale.ROOT));
    } catch (IllegalArgumentException | NullPointerException e) {
      throw new IllegalArgumentException("Please specify -stage, either OLD or NEW");
    }

    final Model modelType;
    try {
      modelType = Model.valueOf(props.getProperty("model").toUpperCase(Locale.ROOT));
    } catch (IllegalArgumentException | NullPointerException e) {
      throw new IllegalArgumentException("Please specify -model, either SENTIMENT, DVPARSER, EMBEDDING, COREF, FASTCOREF");
    }

    if (!props.containsKey("input")) {
      throw new IllegalArgumentException("Please specify -input");
    }

    if (!props.containsKey("output")) {
      throw new IllegalArgumentException("Please specify -output");
    }

    String inputPath = props.getProperty("input");
    String outputPath = props.getProperty("output");

    if (modelType == Model.SENTIMENT) {
      if (stage == Stage.OLD) {
        SentimentModel model = SentimentModel.loadSerialized(inputPath);
        ObjectOutputStream out = IOUtils.writeStreamFromString(outputPath);
        writeSentiment(model, out);

View on GitHub (pinned to 1b7edd19c4)