简体   繁体   English

NLTK关系提取示例不起作用

[英]NLTK Example for Relation Extraction Does not work

I have gotten through parts of the nltk book until this section on relation extracting. 在涉及关系提取的这一部分之前,我已经通读了nltk书的各个部分。 Can someone help me understand why the code below does not work? 有人可以帮我理解为什么下面的代码不起作用吗? There does not seem to be the method show_raw_rtuple() 似乎没有方法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)

This depends on your version of NLTK. 这取决于您的NLTK版本。 On NLTK 2.x this should work: 在NLTK 2.x上,这应该起作用:

 print nltk.sem.relextract.show_raw_rtuple(rel)

On NLTK 3.x show_raw_rtuple() seems to have been replaced by rtuple(): 在NLTK 3.x上,show_raw_rtuple()似乎已被rtuple()代替:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM