简体   繁体   中英

NLTK Example for Relation Extraction Does not work

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)

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

 print nltk.sem.relextract.show_raw_rtuple(rel)

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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