我有一段时间正在为一个问题苦苦挣扎。假设您有一个类型化依赖项的集合(来自 edu.stanford.nlp.trees.TypedDependency
),并且想要将它们转换为树(来自 edu.stanford.nlp.trees.Tree
)。
例如:
// Suppose you get the typed dependencies from a grammatical structure object
Collection<TypedDependency> atd = gs.allTypedDependencies();
Tree t = null;
现在,我该如何变换对象 atd
进入一棵树(可以存储在 t
)?
最佳答案
这些不是等效类型。类型化依赖定义依赖树 (SemanticGraph
),而 Tree
类表示选区树。虽然实际上有代码可以从选区树生成依赖树,但 CoreNLP 中没有任何代码可以执行相反的操作。据我所知,这实际上是一项不平凡的任务。
我的建议是运行 parse
注释器而不是 depparse
注释器,并以这种方式获取树(请参阅TreeCoreAnnotations.TreeAnnotation
) .
关于java - 将类型化依赖项的集合转换为树,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32583319/