{"record":{"id":"73806b816d4d3d2b","repo":"stanfordnlp/CoreNLP","slug":"this-version-of-the-parser-does-not-support-non-tr","errorCode":null,"errorMessage":"This version of the parser does not support non-tree training data","messagePattern":"This version of the parser does not support non-tree training data","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/lexparser/ChineseCharacterBasedLexicon.java","lineNumber":93,"sourceCode":"  @Override\n  public void train(Collection<Tree> trees, double weight) {\n    for (Tree tree : trees) {\n      train(tree, weight);\n    }\n  }\n\n  /**\n   * TODO: make this method do something with the weight\n   */\n  @Override\n  public void train(Tree tree, double weight) {\n    trainingSentences.add(tree.taggedYield());\n  }\n\n  @Override\n  public void trainUnannotated(List<TaggedWord> sentence, double weight) {\n    // TODO: for now we just punt on these\n    throw new UnsupportedOperationException(\"This version of the parser does not support non-tree training data\");\n  }\n\n  @Override\n  public void incrementTreesRead(double weight) {\n    throw new UnsupportedOperationException();\n  }\n\n  @Override\n  public void train(TaggedWord tw, int loc, double weight) {\n    throw new UnsupportedOperationException();\n  }\n\n\n  @Override\n  public void train(List<TaggedWord> sentence, double weight) {\n    trainingSentences.add(sentence);\n  }\n","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/ChineseCharacterBasedLexicon.java#L75-L111","documentation":"ChineseCharacterBasedLexicon only trains on parse trees; trainUnannotated (used when the parser reads raw, unannotated sentences for semi-supervised/unsupervised training) is explicitly unimplemented and throws UnsupportedOperationException.","triggerScenarios":"Training a Chinese character-based lexicon with a training pipeline that feeds unannotated/tagged-only sentences, i.e. any path calling Lexicon.trainUnannotated(sentence, weight).","commonSituations":"Using -unannotatedSentences style options or semi-supervised training loops with a character-based Chinese model; copying training code from a word-based lexicon setup to the character-based one.","solutions":["Train only on treebank trees (train(Collection<Tree>) / train(Tree, weight)) with this lexicon","Use a word-based lexicon (e.g. ChineseLexicon / ChineseTreebankParserParams default) if you need unannotated training","Guard training code: only call trainUnannotated when the lexicon supports it (feature-check by type)","Upgrade/patch the lexicon to implement training from tagged sentences if semi-supervision is required"],"exampleFix":"// before\nlexicon.trainUnannotated(sentence, 1.0);\n// after\nif (!(lexicon instanceof ChineseCharacterBasedLexicon)) {\n  lexicon.trainUnannotated(sentence, 1.0);\n}","handlingStrategy":"type-guard","validationCode":"if (lexicon instanceof ChineseCharacterBasedLexicon) {\n  // train only on trees\n  lexicon.train(trees, 1.0);\n}","typeGuard":"boolean supportsUnannotatedTraining(Lexicon l) {\n  return !(l instanceof ChineseCharacterBasedLexicon);\n}","tryCatchPattern":"try { lexicon.trainUnannotated(sents, 1.0); } catch (UnsupportedOperationException e) { log.warn(\"Lexicon cannot use unannotated data; ignoring \" + sents.size() + \" sentences\"); }","preventionTips":["Only feed treebank trees to the character-based lexicon","Use a word-based lexicon for semi-supervised training","Feature-check the Lexicon implementation before calling optional-training APIs"],"tags":["parser","unsupported-operation","training","chinese-nlp"],"backgroundTag":"unsupported-operation","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"}