{"record":{"id":"ffd4912d52c3ffb7","repo":"stanfordnlp/CoreNLP","slug":"this-version-of-the-parser-does-not-support-non-tr-ffd491","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/ChineseLexiconAndWordSegmenter.java","lineNumber":128,"sourceCode":"  public void train(Tree tree, double weight) {\n    train(tree.taggedYield(), weight);\n  }\n\n  @Override\n  public void train(List<TaggedWord> sentence) {\n    train(sentence, 1.0);\n  }\n\n  @Override\n  public void train(List<TaggedWord> sentence, double weight) {\n    chineseLexicon.train(sentence, weight);\n    wordSegmenter.train(sentence);\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  @Override\n  public void finishTraining() {\n    chineseLexicon.finishTraining();\n    wordSegmenter.finishTraining();\n  }\n","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/ChineseLexiconAndWordSegmenter.java#L110-L146","documentation":"ChineseLexiconAndWordSegmenter.trainUnannotated is a required interface method (from the Lexicon API) that should train the segmenter on unannotated (non-treebank) sentences. This implementation is an explicit stub that punts on the feature and throws UnsupportedOperationException whenever the parser framework feeds raw, non-tree training data to the Chinese lexicon/segmenter.","triggerScenarios":"Calling trainUnannotated(List<TaggedWord>, double) directly, or running a training pipeline that uses unannotated/raw training data (e.g. unsupervised or semi-supervised training options) with the Chinese lexicon and word segmenter.","commonSituations":"Developers attempting semi-supervised training on raw Chinese text (e.g. -train2 or unannotated-data options) discover this lexicon variant never implemented the feature; it is a known TODO in the source.","solutions":["Restrict training data to annotated treebank trees so trainUnannotated is never invoked","Switch to a lexicon implementation that supports unannotated training, or extend ChineseLexiconAndWordSegmenter to implement trainUnannotated by delegating to wordSegmenter training","Use an older/newer Stanford NLP release or the BaseLexicon path that handles raw data differently"],"exampleFix":"// before\nlexicon.trainUnannotated(rawSentences, 1.0); // throws UnsupportedOperationException\n// after\nlexicon.train(treebankSentences); // only annotated trees are supported","handlingStrategy":"validation","validationCode":"if (data instanceof List && !isAnnotatedTreebank(data)) { throw new IllegalArgumentException(\"trainUnannotated unsupported; use annotated trees\"); }","typeGuard":"boolean supportsUnannotated(Object lex) { return !(lex instanceof ChineseLexiconAndWordSegmenter); }","tryCatchPattern":"try { lexicon.trainUnannotated(sentences, w); } catch (UnsupportedOperationException e) { log.warn(\"Non-tree training unsupported, skipping\"); }","preventionTips":["Only feed treebank-annotated trees to Chinese lexicon training","Check library source/interface docs before assuming unannotated training works"],"tags":["java","parser","unsupported-operation","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"}