Dependencies 无根的Stanford Core NLP解析树

Dependencies 无根的Stanford Core NLP解析树,dependencies,root,stanford-nlp,Dependencies,Root,Stanford Nlp,我正在使用StanfordCorenlp获取句子的依赖树。 我遇到的问题是,对于一些句子,树没有根节点。这可能吗 ,有一个类似的示例,其中检测到问题与打印方法有关(即存在根,但不知何故它没有被打印) 然而,就我而言,这个句子根本没有词根。这是我的一个测试句子:“(Wendigo是)我们为什么去看电影:通过眼睛、心脏和大脑来喂养。” 我正在使用以下代码打印依赖项: SemanticGraph dependencies = sentence.get(CollapsedCCProcessedDepen

我正在使用StanfordCorenlp获取句子的依赖树。 我遇到的问题是,对于一些句子,树没有根节点。这可能吗

,有一个类似的示例,其中检测到问题与打印方法有关(即存在根,但不知何故它没有被打印)

然而,就我而言,这个句子根本没有词根。这是我的一个测试句子:“(Wendigo是)我们为什么去看电影:通过眼睛、心脏和大脑来喂养。”

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

SemanticGraph dependencies = sentence.get(CollapsedCCProcessedDependenciesAnnotation.class);
out.println(dependencies.toString("plain"));
IndexedWord root = dependencies.getFirstRoot();
out.printf("ROOT(root-0, %s-%d)%n", root.word(), root.index());
以下是输出:

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)
尝试手动打印根节点后,请使用以下代码:

SemanticGraph dependencies = sentence.get(CollapsedCCProcessedDependenciesAnnotation.class);
out.println(dependencies.toString("plain"));
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.
问题是:

  • 每个句子的依赖关系树中都必须有根节点吗
  • 一个句子可以有多个根节点吗?如果是,那么它将如何成为一棵树呢

  • 谢谢,

    看起来这是一个错误,因为解析器错误地生成了一个只包含右括号的形容词短语成分,这使依赖关系变得混乱(右括号变成了调控器,但随后作为标点符号被删除)

    似乎有人已经解决了这个问题。当前版本(在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)
    

    看起来这是一个错误,因为解析器错误地生成了一个只包含右括号的形容词短语成分,这使依赖项变得混乱(右括号成为调控器,但随后作为标点符号被删除)

    似乎有人已经解决了这个问题。当前版本(在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)