【问题和解决】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'

在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 &AMP;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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值