stanfordnlp/CoreNLP · error · IllegalArgumentException
Sentiment analysis is not implemented for German
Error message
Sentiment analysis is not implemented for German
What it means
GermanDocument overrides runSentiment to throw because no sentiment analysis annotator is wired up for German in the simple API. Calling sentiment on a German Document/Sentence throws IllegalArgumentException. It signals an explicitly unimplemented feature for this language, not a configuration error.
Solutions
- Remove the 'sentiment' annotator for German documents
- Run sentiment only on English documents
- Use a German-specific sentiment library/model and merge results
- Check the document language before calling sentiment() and branch to a fallback
Example fix
// before
Document doc = new Document(germanText);
String s = doc.sentiment();
// after
if (doc.getClass().getSimpleName().startsWith("German")) {
throw new UnsupportedOperationException("German sentiment unavailable");
}
String s = doc.sentiment(); Defensive patterns
Strategy: validation
Validate before calling
if (doc instanceof GermanDocument) {
throw new UnsupportedOperationException("sentiment not supported for German");
} Type guard
boolean supportsSentiment(Document d) {
return !(d instanceof GermanDocument);
} Try / catch
try {
String s = sentence.sentiment();
} catch (IllegalArgumentException e) {
s = null; // unsupported for this language
} Prevention
- Only add the sentiment annotator for English pipelines
- Branch sentiment calls on document language
- Consider external German sentiment models
When it happens
Trigger: Calling Document.runSentiment indirectly via Document.sentiment(), Sentence.sentiment(), or applying the 'sentiment' annotator to German text through StanfordCoreNLP with -language de.
Common situations: Adding the sentiment annotator to a German pipeline; calling sentiment() in a loop over multilingual documents without checking the language; upgrading the simple API and expecting German sentiment support.
Related errors
- No model specified for Sentiment annotator
- No segmenter implemented for
- Sentiment analysis is not implemented for Arabic
- Sentiment analysis is not implemented for Chinese
- Sentiment analysis is not implemented for French
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/400fad17eaaa2b55.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/simple/GermanDocument.java:83
protected GermanDocument(Properties props, String text) {
super(props, text);
}
/**
* 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)