stanfordnlp/CoreNLP · error · RuntimeException

Expected a property " + name + ".model

Error message

Expected a property " + name + ".model

What it means

ChineseSegmenterAnnotator requires a CRF segmentation model. After collecting properties, if no model path was specified via '<name>.model' it throws this RuntimeException instead of loading a null model.

Solutions

  1. Set the model property: props.setProperty("chinesesegmenter.model", "edu/stanford/nlp/models/segmenter/chinese/ctb.gz")
  2. Add the stanford-chinese-corenlp models jar to the classpath so the default model resolves
  3. Verify the property prefix matches the annotator name used in the pipeline

Example fix

// before
props.setProperty("annotators", "segment");
// after
props.setProperty("annotators", "segment");
props.setProperty("segment.model", "edu/stanford/nlp/models/segmenter/chinese/ctb.gz");
Defensive patterns

Strategy: validation

Validate before calling

if (props.getProperty(name + ".model") == null) {
  throw new IllegalArgumentException(name + " requires a .model property");
}

Try / catch

try {
  new ChineseSegmenterAnnotator(name, props);
} catch (RuntimeException e) {
  if (e.getMessage().contains("Expected a property")) {
    // set segment.model and retry
  } else throw e;
}

Prevention

When it happens

Trigger: Creating a ChineseSegmenterAnnotator (or using 'chinesesegmenter' in a pipeline) without setting e.g. 'chinesesegmenter.model', or setting the key under a prefix that doesn't match the annotator name.

Common situations: Missing the stanford-chinese-corenlp models jar; typo in the model property; switching to a custom annotator name without renaming the model property.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/pipeline/ChineseSegmenterAnnotator.java:93

    String model = null;
    // Keep only the properties that apply to this annotator
    Properties modelProps = new Properties();
    String desiredKey = name + '.';
    for (String key : props.stringPropertyNames()) {
      if (key.startsWith(desiredKey)) {
        // skip past name and the subsequent "."
        String modelKey = key.substring(desiredKey.length());
        if (modelKey.equals("model")) {
          model = props.getProperty(key);
        } else {
          modelProps.setProperty(modelKey, props.getProperty(key));
        }
      }
    }
    this.VERBOSE = PropertiesUtils.getBool(props, name + ".verbose", false);
    this.normalizeSpace = PropertiesUtils.getBool(props, name + ".normalizeSpace", false);
    if (model == null) {
      throw new RuntimeException("Expected a property " + name + ".model");
    }
    // don't write very much, because the CRFClassifier already reports loading
    if (VERBOSE) {
      log.info("Loading Segmentation Model ... ");
    }
    try {
      segmenter = CRFClassifier.getClassifier(model, modelProps);
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new RuntimeException(e);
    }

    // If newlines are treated as sentence split, we need to retain them in tokenization for ssplit to make use of them
    tokenizeNewline = (!props.getProperty(StanfordCoreNLP.NEWLINE_IS_SENTENCE_BREAK_PROPERTY, "never").equals("never"))
            || Boolean.valueOf(props.getProperty(StanfordCoreNLP.NEWLINE_SPLITTER_PROPERTY, "false"));

    // record whether or not sentence splitting on two newlines ; if so, need to remove single newlines

View on GitHub (pinned to 1b7edd19c4)