{"record":{"id":"1b206b8e9fabd93b","repo":"stanfordnlp/CoreNLP","slug":"sentiment-analysis-is-not-implemented-for-chinese","errorCode":null,"errorMessage":"Sentiment analysis is not implemented for Chinese","messagePattern":"Sentiment analysis is not implemented for Chinese","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/simple/ChineseDocument.java","lineNumber":105,"sourceCode":"  /**\n   * No lemma annotator for Chinese -- 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  /**\n   * No sentiment analysis implemented for Chinese.\n   *\n   * @see Document#runSentiment(Properties)\n   */\n  @Override\n  protected Document runSentiment(Properties props) {\n    throw new IllegalArgumentException(\"Sentiment analysis is not implemented for Chinese\");\n  }\n\n  /**\n   * The Neural Dependency Parser doesn't support Chinese yet, so back off to running the\n   * constituency parser instead.\n   */\n  @Override  // TODO(danqi; from Gabor): remove this method when we have a trained NNDep model\n  Document runDepparse(Properties props) {\n    return runParse(props);\n  }\n}\n","sourceCodeStart":87,"sourceCodeEnd":117,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/simple/ChineseDocument.java#L87-L117","documentation":"ChineseDocument.runSentiment() throws IllegalArgumentException because no sentiment model is available for Chinese in the stanford.nlp.simple API. Calling Document.sentiment() on a Chinese document always reaches this stub and fails by design.","triggerScenarios":"Calling sentiment() on a ChineseDocument, or invoking any operation whose prerequisites route into runSentiment on Chinese text.","commonSituations":"Multilingual pipelines sentiment-scoring documents in every language; assuming the sentiment annotator works for Chinese as it does for English.","solutions":["Skip sentiment for ChineseDocument instances (instanceof check before calling).","Use an English (or otherwise supported) document for sentiment analysis.","Wire an external Chinese sentiment model (e.g. a trained classifier) outside the simple API."],"exampleFix":"// before\nString s = doc.sentiment();\n// after\nif (!(doc instanceof ChineseDocument)) {\n  String s = doc.sentiment();\n}","handlingStrategy":"type-guard","validationCode":"if (doc instanceof edu.stanford.nlp.simple.ChineseDocument) skipSentiment = true;","typeGuard":"boolean supportsSentiment(Document doc) { return !(doc instanceof edu.stanford.nlp.simple.ChineseDocument); }","tryCatchPattern":"try {\n  doc.sentiment();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"not implemented\")) {\n    log.warn(\"Sentiment unavailable for Chinese, skipping\");\n  } else throw e;\n}","preventionTips":["Check ChineseDocument javadoc before adding sentiment to Chinese pipelines.","Use external Chinese sentiment classifiers.","Encode per-language capability flags in pipeline configuration."],"tags":["nlp","unsupported-language","sentiment","chinese"],"backgroundTag":"method-not-implemented","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"}