user3314418
user3314418

Reputation: 3041

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)

Upvotes: 1

Views: 1546

Answers (1)

NamaeNankaIranai
NamaeNankaIranai

Reputation: 96

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))

Upvotes: 7

Related Questions