{"record":{"id":"4bed675f6e44a63f","repo":"stanfordnlp/CoreNLP","slug":"sentiment-analysis-is-not-implemented-for-spanish","errorCode":null,"errorMessage":"Sentiment analysis is not implemented for Spanish","messagePattern":"Sentiment analysis is not implemented for Spanish","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/simple/SpanishDocument.java","lineNumber":83,"sourceCode":"  protected SpanishDocument(Properties props, String text) {\n    super(props, text);\n  }\n\n\n  /**\n   * No lemma annotator for Spanish -- set the lemma to be the word.\n   *\n   * @see Document#runLemma(Properties)\n   */\n  @Override\n  protected Document runLemma(Properties props) {\n    return mockLemma(props);\n  }\n\n\n  @Override\n  protected Document runSentiment(Properties props) {\n    throw new IllegalArgumentException(\"Sentiment analysis is not implemented for Spanish\");\n  }\n\n\n  @Override\n  protected Document runDepparse(Properties props) {\n    throw new IllegalArgumentException(\"Dependency parsing is not implemented for Spanish\");\n  }\n\n\n  @Override\n  public Map<Integer, CorefChain> coref(Properties props) {\n    throw new IllegalArgumentException(\"Coreference is not implemented for Spanish\");\n  }\n\n}\n","sourceCodeStart":65,"sourceCodeEnd":99,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/simple/SpanishDocument.java#L65-L99","documentation":"SpanishDocument.runSentiment is an explicit stub: the Stanford CoreNLP Spanish pipeline has no sentiment model, so calling any sentiment API on a Spanish document throws IllegalArgumentException. This is an intentional unsupported-feature signal, not a bug.","triggerScenarios":"Calling sentiment(), runSentiment(props), or Document APIs that trigger the sentiment annotator on a SpanishDocument instance.","commonSituations":"Generic pipeline code that runs sentiment on all documents regardless of language; switching an English pipeline to Spanish while reusing the same analysis code; user requests for sentiment on Spanish text via the simple API.","solutions":["Do not call sentiment analysis on SpanishDocument; skip it for Spanish text","Use an English Document/model for sentiment if acceptable, or apply a language-appropriate sentiment tool","Wrap the call in a language check: only run sentiment when document language supports it","Contribute/plug in a Spanish sentiment annotator via a custom Document subclass"],"exampleFix":"// before\nDocument d = new SpanishDocument(text);\nd.sentiment(); // throws\n// after\nif (!(d instanceof SpanishDocument)) {\n  d.sentiment();\n}","handlingStrategy":"fallback","validationCode":"if (doc instanceof SpanishDocument) { /* skip sentiment */ }","typeGuard":"boolean supportsSentiment(Document d) { return !(d instanceof SpanishDocument); }","tryCatchPattern":"try {\n  doc.sentiment();\n} catch (IllegalArgumentException e) {\n  // mark sentiment unsupported for this language\n}","preventionTips":["Branch analysis steps on document language","Keep a capability matrix of supported annotators per language","Handle missing sentiment results downstream instead of assuming presence"],"tags":["java","nlp","spanish","unsupported-feature","sentiment"],"backgroundTag":"operation-not-supported","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}