stanfordnlp/CoreNLP · error · IllegalArgumentException

Coreference is not implemented for German

Error message

Coreference is not implemented for German

What it means

GermanDocument.coref() throws IllegalArgumentException because coreference resolution is not implemented for German in Stanford CoreNLP's simple API. Any attempt to compute coref chains on a German document fails immediately with this message. It is an intentional unsupported-operation stub.

Solutions

  1. Exclude the 'coref' annotator from German pipelines
  2. Run coreference only on supported languages (English)
  3. Integrate a third-party German coreference system
  4. Guard with instanceof/language checks before calling coref()

Example fix

// before
pipeline = new StanfordCoreNLP(propsWithCoref, "de");
Map<Integer, CorefChain> c = new Document(text).coref();
// after
if (!"en".equals(lang)) {
  Map<Integer, CorefChain> c = Collections.emptyMap(); // coref unsupported
} else {
  Map<Integer, CorefChain> c = new Document(text).coref();
}
Defensive patterns

Strategy: validation

Validate before calling

if (doc instanceof GermanDocument) {
  throw new UnsupportedOperationException("coref not supported for German");
}

Type guard

boolean supportsCoref(Document d) {
  return !(d instanceof GermanDocument);
}

Try / catch

try {
  Map<Integer, CorefChain> chains = doc.coref(props);
} catch (IllegalArgumentException e) {
  chains = Collections.emptyMap();
}

Prevention

When it happens

Trigger: Calling Document.coref(Properties) or Sentence.coref() on a German document, or including the 'coref' annotator in a German StanfordCoreNLP pipeline.

Common situations: Reusing an English coref pipeline config for German; assuming annotator support is uniform across the -language flag values.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/simple/GermanDocument.java:89

   * No lemma annotator for German -- set the lemma to be the word.
   *
   * @see Document#runLemma(Properties)
   */
  @Override
  protected Document runLemma(Properties props) {
    return mockLemma(props);
  }


  @Override
  protected Document runSentiment(Properties props) {
    throw new IllegalArgumentException("Sentiment analysis is not implemented for German");
  }


  @Override
  public Map<Integer, CorefChain> coref(Properties props) {
    throw new IllegalArgumentException("Coreference is not implemented for German");
  }

}

View on GitHub (pinned to 1b7edd19c4)