Python NLTK Wordnet,错误排序(wn.langs())
所以我对这个比较陌生,我需要一些帮助 所以我试图让nltk中的Wordnet使用开放的多语言Wordnet。这是我来到的页面,展示了如何做到这一点 问题是当我尝试排序(wn.langs())时,我得到了这个错误Python NLTK Wordnet,错误排序(wn.langs()),python,nltk,wordnet,Python,Nltk,Wordnet,所以我对这个比较陌生,我需要一些帮助 所以我试图让nltk中的Wordnet使用开放的多语言Wordnet。这是我来到的页面,展示了如何做到这一点 问题是当我尝试排序(wn.langs())时,我得到了这个错误 Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'WordNetCorpusReader' object has no attribut
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'WordNetCorpusReader' object has no attribute 'langs'
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
AttributeError:'WordNetCorpusReader'对象没有属性'langs'
因为我使用的是Python2.7,所以我知道它必须是排序的(wn.langs)
而不是排序的(wn.langs())
,但无论哪种方式都会出现此错误
有人能帮我吗 我追踪到了这一点,我认为这是NLTK版本的问题。你们有什么NLTK版本 如果启动解释器,然后运行
from nltk.corpus import wordnet as wn
sorted(wn.langs())
当我在nltk==2.0.4
下运行此代码时(也使用Python 2.7),我看到了与您相同的错误。所以我检查了源代码,而langs(self)
方法不存在。然而,看看最新的,你可以看到它在那里
假设您正在使用pip(如果您没有,并且如果您使用Windows并遵循“替代说明”),请执行以下操作:
这应该安装nltk==3.0.0
再次运行代码,您将看到
>>> sorted(wn.langs())
[u'als', u'arb', u'cat', u'cmn', u'dan', u'eng', u'eus', u'fas', u'fin', u'fra', u'fre', u'glg', u'heb', u'ind', u'ita', u'jpn', u'nno', u'nob', u'pol', u'por', u'spa', u'tha', u'zsm']
>>> sorted(wn.langs())
[u'als', u'arb', u'cat', u'cmn', u'dan', u'eng', u'eus', u'fas', u'fin', u'fra', u'fre', u'glg', u'heb', u'ind', u'ita', u'jpn', u'nno', u'nob', u'pol', u'por', u'spa', u'tha', u'zsm']