{"record":{"id":"9c466375117b32df","repo":"stanfordnlp/CoreNLP","slug":"this-version-of-the-parser-does-not-support-non-tr-9c4663","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/ChineseMaxentLexicon.java","lineNumber":268,"sourceCode":"  }\n\n  /**\n   * Add the given sentence to the statistics counted.  Can\n   * be called multiple times with different sentences.\n   */\n  @Override\n  public void train(List<TaggedWord> sentence, double weight) {\n    featExtractor.train(sentence, weight);\n    for (TaggedWord word : sentence) {\n      datumCounter.incrementCount(word, weight);\n      tagsForWord.add(word.word(), word.tag());\n    }\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    IntCounter<String> tagCounter = new IntCounter<>();\n\n    WeightedDataset data = new WeightedDataset(datumCounter.size());\n","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/ChineseMaxentLexicon.java#L250-L286","documentation":"ChineseMaxentLexicon.trainUnannotated is an explicit stub that refuses non-tree training data, same as the ChineseLexiconAndWordSegmenter variant. The parser interface allows feeding raw unannotated sentences with a weight, but this lexicon never implemented it and throws UnsupportedOperationException as a TODO.","triggerScenarios":"Calling trainUnannotated(List<TaggedWord>, double) on a ChineseMaxentLexicon, directly or via a training framework configured to use unannotated/raw data.","commonSituations":"Semi-supervised Chinese parsing experiments that mix treebank data with raw corpora hit this immediately; the feature is simply unimplemented for this lexicon class.","solutions":["Use only annotated treebank data (call train(...) instead)","Subclass ChineseMaxentLexicon and implement trainUnannotated to accumulate raw-sentence statistics","Choose a different lexicon/unknown word model that supports unannotated training"],"exampleFix":"// before\nmaxentLexicon.trainUnannotated(rawSentences, 1.0); // throws\n// after\nmaxentLexicon.train(annotatedTrees);","handlingStrategy":"validation","validationCode":"if (!annotatedOnly && lexicon instanceof ChineseMaxentLexicon) throw new IllegalArgumentException(\"ChineseMaxentLexicon does not support unannotated training\");","typeGuard":"boolean supportsUnannotated(Object lex) { return !(lex instanceof ChineseMaxentLexicon); }","tryCatchPattern":"try { lexicon.trainUnannotated(raw, w); } catch (UnsupportedOperationException e) { fallbackToAnnotatedTraining(); }","preventionTips":["Restrict this lexicon to annotated treebank training","Grep the Lexicon interface implementation for TODO stubs before designing semi-supervised pipelines"],"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"}