【问题和解决】NLTK7.6节nltk.sem遇到的问题
生活随笔
收集整理的這篇文章主要介紹了
【问题和解决】NLTK7.6节nltk.sem遇到的问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Traceback (most recent call last):
File "<pyshell#155>", line 3, in <module>
print nltk.sem.show_raw_rtuple(rel,Icon=True,rcon=True)
AttributeError: 'module' object has no attribute 'show_raw_rtuple'
經過查詢NLTK.sem的文檔,發現這些函數都在更深的地方。也就是
nltk.sem.relextract中。
詳情請參考:
http://nltk.googlecode.com/svn/trunk/doc/api/nltk.sem.relextract-module.html
在7.6關系抽取中,有這樣一段代碼
>>>IN = re.compile(r'.*\bin\b(?!\b.+ing)') >>>for docin 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) [ORG: 'WHYY'] 'in' [LOC: 'Philadelphia'] [ORG: 'McGlashan &Sarrail']'firm in' [LOC: 'San Mateo'] [ORG: 'Freedom Forum']'in' [LOC: 'Arlington'] [ORG: 'Brookings Institution'] ', the research group in' [LOC: 'Washington'] [ORG: 'Idealab'] ', a self-described businessincubator basedin' [LOC: 'Los Angeles'] [ORG: 'Open Text']', basedin' [LOC: 'Waterloo'] [ORG: 'WGBH'] 'in' [LOC: 'Boston'] [ORG: 'Bastille Opera']'in' [LOC: 'Paris'] 255 [ORG: 'Omnicom'] 'in' [LOC: 'New York'] [ORG: 'DDB Needham']'in' [LOC: 'New York'] [ORG: 'Kaplan ThalerGroup']'in' [LOC: 'New York'] [ORG: 'BBDO South']'in' [LOC: 'Atlanta'] [ORG: 'Georgia-Pacific'] 'in' [LOC: 'Atlanta']其中有一句是
nltk.sem.show_raw_rtuple(rel),但是運行出現了錯誤,提示沒有此方法。經過查詢NLTK.sem的文檔,發現這些函數都在更深的地方。也就是
nltk.sem.relextract中。
詳情請參考:
http://nltk.googlecode.com/svn/trunk/doc/api/nltk.sem.relextract-module.html
轉載于:https://www.cnblogs.com/createMoMo/archive/2013/05/15/3080074.html
總結
以上是生活随笔為你收集整理的【问题和解决】NLTK7.6节nltk.sem遇到的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 畅想(2)-计算机发展与教育的关系
- 下一篇: hdu 2483