【发布时间】:2015-04-20 05:26:46
【问题描述】:
我正在使用 Stanford CoreNLP 获取句子的依赖树。 我遇到的问题是,对于某些句子,树没有根节点。这可能吗?
Here,有一个类似的示例,其中检测到问题与打印方法有关(即有一个根,但不知何故它没有被打印)。
但是,就我而言,这句话根本没有词根。这是我的测试句子:“(Wendigo 是)我们去电影院的原因:通过眼睛,心脏,思想来喂养。”
我正在使用以下代码打印依赖项:
SemanticGraph dependencies = sentence.get(CollapsedCCProcessedDependenciesAnnotation.class);
out.println(dependencies.toString("plain"));
这是输出:
nsubj(-RRB--4, Wendigo-2)
cop(-RRB--4, is-3)
advmod(go-7, why-5)
nsubj(go-7, we-6)
advcl(-RRB--4, go-7)
det(cinema-10, the-9)
prep_to(go-7, cinema-10)
aux(fed-14, to-12)
auxpass(fed-14, be-13)
parataxis(go-7, fed-14)
det(eye-17, the-16)
prep_through(fed-14, eye-17)
det(heart-20, the-19)
appos(eye-17, heart-20)
det(mind-23, the-22)
appos(heart-20, mind-23)
一旦我尝试使用以下代码手动打印根节点:
IndexedWord root = dependencies.getFirstRoot();
out.printf("ROOT(root-0, %s-%d)%n", root.word(), root.index());
我收到以下错误消息:
Exception in thread "main" java.lang.RuntimeException: No roots in graph:
dep reln gov
--- ---- ---
Wendigo-2 nsubj -RRB--4
is-3 cop -RRB--4
why-5 advmod go-7
we-6 nsubj go-7
go-7 advcl -RRB--4
the-9 det cinema-10
cinema-10 prep_to go-7
to-12 aux fed-14
be-13 auxpass fed-14
fed-14 parataxis go-7
the-16 det eye-17
eye-17 prep_through fed-14
the-19 det heart-20
heart-20 appos eye-17
the-22 det mind-23
mind-23 appos heart-20
Find where this graph was created and make sure you're adding roots.
问题是:
- 每个句子都必须在其依赖树中有一个根节点吗?
- 一个句子可以有多个根节点吗?如果是,那它怎么会是一棵树呢?
谢谢,
【问题讨论】:
标签: dependencies root stanford-nlp