PrintTree - 没有为MWE定义头规则 - 版本3.5.2的Bug

时间:2015-07-16 15:20:14

标签: java stanford-nlp

当我尝试打印我使用RNN解析器解析的句子的树时,当句子中存在MWE依赖关系时,它会崩溃。它与最新版本的Stanford NLP(3.5.2)崩溃,但与之前的版本(3.5.1)没有碰撞。

这是我得到的错误:

java.lang.IllegalArgumentException: No head rule defined for MWE using class edu.stanford.nlp.trees.SemanticHeadFinder in (MWE (VBG according) (TO to))
    at edu.stanford.nlp.trees.AbstractCollinsHeadFinder.determineNonTrivialHead(AbstractCollinsHeadFinder.java:242)
    at edu.stanford.nlp.trees.SemanticHeadFinder.determineNonTrivialHead(SemanticHeadFinder.java:437)
    at edu.stanford.nlp.trees.AbstractCollinsHeadFinder.determineHead(AbstractCollinsHeadFinder.java:189)
    at edu.stanford.nlp.trees.TreeGraphNode.percolateHeads(TreeGraphNode.java:315)
    at edu.stanford.nlp.trees.TreeGraphNode.percolateHeads(TreeGraphNode.java:313)
    at edu.stanford.nlp.trees.TreeGraphNode.percolateHeads(TreeGraphNode.java:313)
    at edu.stanford.nlp.trees.TreeGraphNode.percolateHeads(TreeGraphNode.java:313)
    at edu.stanford.nlp.trees.TreeGraphNode.percolateHeads(TreeGraphNode.java:313)
    at edu.stanford.nlp.trees.TreeGraphNode.percolateHeads(TreeGraphNode.java:313)
    at edu.stanford.nlp.trees.TreeGraphNode.percolateHeads(TreeGraphNode.java:313)
    at edu.stanford.nlp.trees.TreeGraphNode.percolateHeads(TreeGraphNode.java:313)
    at edu.stanford.nlp.trees.TreeGraphNode.percolateHeads(TreeGraphNode.java:313)
    at edu.stanford.nlp.trees.GrammaticalStructure.<init>(GrammaticalStructure.java:183)
    at edu.stanford.nlp.trees.UniversalEnglishGrammaticalStructure.<init>(UniversalEnglishGrammaticalStructure.java:92)
    at edu.stanford.nlp.trees.UniversalEnglishGrammaticalStructure.<init>(UniversalEnglishGrammaticalStructure.java:71)
    at edu.stanford.nlp.trees.UniversalEnglishGrammaticalStructureFactory.newGrammaticalStructure(UniversalEnglishGrammaticalStructureFactory.java:29)
    at edu.stanford.nlp.trees.UniversalEnglishGrammaticalStructureFactory.newGrammaticalStructure(UniversalEnglishGrammaticalStructureFactory.java:5)
    at edu.stanford.nlp.trees.TreePrint.printTreeInternal(TreePrint.java:652)
    at edu.stanford.nlp.trees.TreePrint.printTree(TreePrint.java:264)
    at edu.stanford.nlp.trees.TreePrint.printTree(TreePrint.java:226)

有没有办法用最新版本解决这个问题,还是只是一个将在下一个版本中修复的错误?

提前致谢!

编辑:

以下是我使用的代码:

String paragrah = "Whatever text that contains MWE dependency.";
LexicalizedParser lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishRNN.ser.gz");
TreebankLanguagePack tlp = new PennTreebankLanguagePack();
TreePrint tp = new TreePrint("wordsAndTags,typedDependencies", tlp);
DocumentPreprocessor processor = new DocumentPreprocessor(new StringReader(paragraph));
for (List<HasWord> sentence : processor) {
    Tree parse = lp.apply(sentence);
    tp.printTree(parse, pw);
}

0 个答案:

没有答案