stanfordnlp/CoreNLP · error · IllegalArgumentException
Coreference is not implemented for French
Error message
Coreference is not implemented for French
What it means
Stanford CoreNLP's FrenchDocument overrides the pipeline annotator hooks but does not implement coreference resolution for French, so Document.coref() throws IllegalArgumentException immediately. The library uses language-specific Document subclasses and only English (and a few others) ship coreference models. This is an explicit unsupported-operation guard, not a bug.
Solutions
- Remove the coref annotator from the pipeline / skip Document.coref() for French text
- Run coreference with the English pipeline only if your data is English
- Use an external French-capable coreference tool (e.g. a neural coref model supporting French) and feed its output into your app
- Wrap coref() in a feature check and degrade gracefully when unsupported
Example fix
// before
Document doc = new Document("...");
Map<Integer, CorefChain> chains = doc.coref();
// after
if (doc instanceof FrenchDocument) {
System.err.println("coref not supported for French");
} else {
Map<Integer, CorefChain> chains = doc.coref();
} Defensive patterns
Strategy: validation
Validate before calling
if (doc instanceof FrenchDocument) {
throw new UnsupportedOperationException("coref not supported for French");
} Type guard
boolean supportsCoref(Document d) {
return !(d instanceof FrenchDocument);
} Try / catch
try {
Map<Integer, CorefChain> chains = doc.coref(props);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("not implemented")) {
chains = Collections.emptyMap();
} else { throw e; }
} Prevention
- Check language support per annotator before building pipelines
- Keep a supported-features matrix for each -language value
- Degrade gracefully: skip coref for unsupported languages
When it happens
Trigger: Calling CorefChain coref(Properties) or any Document/Sentence-level API that triggers coreference (e.g. Document.coref(), Sentence.coref(), or running an annotator pipeline with the 'coref' annotator on a French document).
Common situations: Using StanfordCoreNLP with the coref annotator and -language fr; porting an English coref pipeline to French; assuming all languages supported by the simple API support all annotators.
Related errors
- Coreference is not implemented for German
- allSentences != allWords
- Cannot have these two ordering constraints
- Cannot have these two ordering constraints
- Coreference is not implemented for Arabic
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/b77be8ca0be951a9.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/simple/FrenchDocument.java:88
/**
* No lemma annotator for French -- 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 French");
}
@Override
public Map<Integer, CorefChain> coref(Properties props) {
throw new IllegalArgumentException("Coreference is not implemented for French");
}
}
View on GitHub (pinned to 1b7edd19c4)