首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >斯坦福核心NLP无根分析树

斯坦福核心NLP无根分析树
EN

Stack Overflow用户
提问于 2014-09-09 17:48:51
回答 1查看 990关注 0票数 1

我使用斯坦福大学的CoreNLP来获取句子的依赖树。我遇到的问题是,对于一些句子,树没有根节点。这个是可能的吗?

Here,有一个类似的例子,在这个例子中,问题是用打印方法检测出来的(也就是说,有一个根,但不知怎么没有被打印出来)。

然而,在我的例子中,这句话根本没有根。这是我的试炼句:“(温迪哥是)我们去看电影的原因:通过眼睛、心脏、心灵被喂饱。”

我使用以下代码打印依赖项:

代码语言:javascript
复制
SemanticGraph dependencies = sentence.get(CollapsedCCProcessedDependenciesAnnotation.class);
out.println(dependencies.toString("plain"));

这是输出:

代码语言:javascript
复制
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)

一旦我尝试手动打印根节点,使用以下代码:

代码语言:javascript
复制
IndexedWord root = dependencies.getFirstRoot();
out.printf("ROOT(root-0, %s-%d)%n", root.word(), root.index());

我收到以下错误消息:

代码语言:javascript
复制
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.

问题如下:

  1. 是否每个句子都必须在其依赖树中有一个根节点?
  2. 一个句子能有多个根节点吗?如果是,那它怎么会是一棵树呢?

谢谢,

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-19 21:26:46

看起来这是一个错误,原因是解析器错误地生成了一个只包含右括号的形容词词组,它发送了依赖项(右括号变成了调控器,但随后作为标点符号被删除)。

好像已经有人修好了。当前版本(在github中)给出了下面的依赖项。因此,我们本周发布的新版本(2015年4月)有望为你解决问题.

代码语言:javascript
复制
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)
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25750878

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档