使用Java组合nn标记以形成名词短语

使用Java组合nn标记以形成名词短语,java,nlp,stanford-nlp,Java,Nlp,Stanford Nlp,如何使用Java将所有nn标记组合为短语标记 nsubj(martyrdom-4, Today-1) cop(martyrdom-4, is-2) det(martyrdom-4, the-3) root(ROOT-0, martyrdom-4) nn(Mukherjee-7, Dr-6) prep_of(martyrdom-4, Mukherjee-7) det(founder-9, the-8) dep(tribute-17, founder-9) prep_of(founder-9, J

如何使用Java将所有nn标记组合为短语标记

nsubj(martyrdom-4, Today-1)
cop(martyrdom-4, is-2)
det(martyrdom-4, the-3)
root(ROOT-0, martyrdom-4)
nn(Mukherjee-7, Dr-6)
prep_of(martyrdom-4, Mukherjee-7)
det(founder-9, the-8)
dep(tribute-17, founder-9)

prep_of(founder-9, Jan-11)
nn(body-15, Sangh-12)
nn(body-15, BJP-13)
nn(body-15, parent-14)
dep(tribute-17, body-15)
poss(tribute-17, My-16)
dep(martyrdom-4, tribute-17)
prep_to(tribute-17, him-19)
我想得到一个名词短语:

prep_of(founder-9,Jan-11)
nn(body-15, Sangh-12)
nn(body-15, BJP-13)
nn(body-15, parent-14)

输出应该是------->jan sangh BJP parent

我相信这是斯坦福解析器的依赖链输出。如果是,那么在句子的解析树中应该已经有了名词短语(NP节点)。您可以从解析树中提取最低级别的NP节点,以获得所需的名词短语。例如,对于“今天是Jan Sangh BJP创始人穆克吉博士的殉难日”这句话,解析树应该是:

(ROOT
  (S
    (NP (NNP Today))
    (VP (VBZ is)
      (NP
        (NP (DT the) (NN martyrdom))
        (PP (IN of)
          (NP
            (NP (NNP Dr.) (NNP Mukherjee))
            (, ,)
            (NP
              (NP (NN founder))
              (PP (IN of)
                (NP (NNP Jan) (NNP Sangh) (NNP BJP))))))))
    (. .)))
在该树中,包含专有名词(NNP)的最低级别NPs将为您提供所需名词短语的大部分(所有这些NP都不是您需要的命名实体)。在这种情况下,输出将为:

(NP (NNP Today))
(NP (NNP Dr.) (NNP Mukherjee))
(NP (NNP Jan) (NNP Sangh) (NNP BJP))

相关问题:@KenstonChoi ya有点相同,但您指出的问题是要求依赖关系,而不是名词pharse。我们如何使用java遍历图树