我使用斯坦福大学的CoreNLP来获取句子的依赖树。我遇到的问题是,对于一些句子,树没有根节点。这个是可能的吗?
Here,有一个类似的例子,在这个例子中,问题是用打印方法检测出来的(也就是说,有一个根,但不知怎么没有被打印出来)。
然而,在我的例子中,这句话根本没有根。这是我的试炼句:“(温迪哥是)我们去看电影的原因:通过眼睛、心脏、心灵被喂饱。”
我使用以下代码打印依赖项:
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.问题如下:
谢谢,
发布于 2015-04-19 21:26:46
看起来这是一个错误,原因是解析器错误地生成了一个只包含右括号的形容词词组,它发送了依赖项(右括号变成了调控器,但随后作为标点符号被删除)。
好像已经有人修好了。当前版本(在github中)给出了下面的依赖项。因此,我们本周发布的新版本(2015年4月)有望为你解决问题.
root(ROOT-0, is-3)
nsubj(is-3, Wendigo-2)
advmod(go-7, why-5)
nsubj(go-7, we-6)
advcl(is-3, go-7)
case(cinema-10, to-8)
det(cinema-10, the-9)
nmod:to(go-7, cinema-10)
mark(fed-14, to-12)
auxpass(fed-14, be-13)
parataxis(go-7, fed-14)
case(eye-17, through-15)
det(eye-17, the-16)
nmod: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)https://stackoverflow.com/questions/25750878
复制相似问题