NLTK关系提取示例不起作用 [英] NLTK Example for Relation Extraction Does not work

查看:173
本文介绍了NLTK关系提取示例不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在涉及关系提取的本节之前,我已经通读了nltk书的各个部分.有人可以帮我理解为什么下面的代码不起作用吗?似乎没有方法show_raw_rtuple()

I have gotten through parts of the nltk book until this section on relation extracting. Can someone help me understand why the code below does not work? There does not seem to be the method show_raw_rtuple()

IN = re.compile(r'.*\bin\b(?!\b.+ing)')
for doc in nltk.corpus.ieer.parsed_docs('NYT_19980315'):
    for rel in nltk.sem.extract_rels('ORG', 'LOC', doc,
                                    corpus='ieer', pattern = IN):
        print nltk.sem.show_raw_rtuple(rel)

推荐答案

这取决于您的NLTK版本.在NLTK 2.x上,这应该可以工作:

This depends on your version of NLTK. On NLTK 2.x this should work:

 print nltk.sem.relextract.show_raw_rtuple(rel)

在NLTK 3.x上,show_raw_rtuple()似乎已被rtuple()取代:

On NLTK 3.x show_raw_rtuple() seems to have been replaced by rtuple():

 print(nltk.sem.relextract.rtuple(rel))

这篇关于NLTK关系提取示例不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆