【发布时间】:2015-10-04 06:06:56
【问题描述】:
安装 nltk 后,我导入 nltk,然后使用 nltk.download(),但是当我尝试使用此“从 nltk.book 导入 *”时,它显示属性错误。 from nltk.corpus import * 和 from nltk import * 工作正常
我是自然语言处理的新手,所以我对此不太了解,请帮助
从 nltk.book 导入 * * NLTK 书籍的介绍性示例 *
正在加载 text1, ..., text9 和 sent1, ..., sent9
键入文本或句子的名称以查看它。
键入:'texts()' 或 'sents()' 列出材料。
Traceback(最近一次调用最后一次):
文件“”,第 1 行,在
from nltk.book import *
文件“C:\Program Files (x86)\Python 3.5\lib\site-packages\nltk\book.py”,行 19、在
text1 = Text(gutenberg.words('melville-moby_dick.txt'))
文件“C:\Program Files (x86)\Python 3.5\lib\site-packages\nltk\text.py”,第 295 行,在 init
tokens = list(tokens)
文件“C:\Program Files (x86)\Python 3.5\lib\site-
packages\nltk\corpus\reader\util.py",第 233 行,在 len
for tok in self.iterate_from(self._toknum[-1]): pass
文件“C:\Program Files (x86)\Python 3.5\lib\site-packages\nltk\corpus\reader\util.py”,第 291 行,在 iterate_from
tokens = self.read_block(self._stream)
文件“C:\Program Files (x86)\Python 3.5\lib\site-packages\nltk\corpus\reader\plaintext.py”,第 117 行,在 _read_word_block words.extend(self._word_tokenizer.tokenize(stream.readline()))
文件“C:\Program Files (x86)\Python 3.5\lib\site-packages\nltk\tokenize\regexp.py”,第 126 行,在 tokenize self._check_regexp()
文件“C:\Program Files (x86)\Python 3.5\lib\site-packages\nltk\tokenize\regexp.py”,第 121 行,在 _check_regexp self._regexp = compile_regexp_to_noncapturing(self._pattern, self._flags)
文件“C:\Program Files (x86)\Python 3.5\lib\site-packages\nltk\internals.py”,第 56 行,在 compile_regexp_to_noncapturing return sre_compile.compile(convert_regexp_to_noncapturing_parsed(sre_parse.parse(pattern)), flags=flags)
文件“C:\Program Files (x86)\Python 3.5\lib\site-packages\nltk\internals.py”,第 52 行,在 convert_regexp_to_noncapturing_parsed parsed_pattern.pattern.groups = 1
AttributeError: 无法设置属性
【问题讨论】:
标签: python nltk python-3.5