1
votes

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)
1
What error do you get? Where is this code from? Are you sure you copied it correctly? Have you looked at the documentation to see what methods should be available? Are there different versions with different methods? Have you read this question? - jonrsharpe

1 Answers

7
votes

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