extract NP-VP-NP from Stanford dependency parse tree

别说谁变了你拦得住时间么 提交于 2019-12-23 15:40:25

问题


I need to extract triplets of the form NP-VP-NP from the dependency parse tree produced as the output of lexalized parsing in Stanford Parser.

Whats the best way to do this. e.g. If the parse tree is as follows:

(ROOT
  (S
    (S
      (NP (NNP Exercise))
      (VP (VBZ reduces)
        (NP (NN stress)))
      (. .))
    (NP (JJ Regular) (NN exercise))
    (VP (VBZ maintains)
      (NP (JJ mental) (NN fitness)))
    (. .)))

I need to extract 2 triplets:

  1. Exercise-reduces-stress and
  2. Regular Exercise-maintains-mental fitness

Any ideas?


回答1:


There are two natural options here. One is to run Semgrex over the dependency tree (side note: what you have in the question is a constituency tree), with a pattern like:

{pos:/V.*/}=verb >/.subj.*/ {}=subject >/.obj/ {}=object

Another option is to use the Stanford Open IE system. This will give you a more broad semantics of '(subject; relation; object)' triples, where the relation does not have to be a verb.



来源:https://stackoverflow.com/questions/33733669/extract-np-vp-np-from-stanford-dependency-parse-tree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!