安装 nltk 后,我导入 nltk,然后使用 nltk.download() 但是当我尝试使用此“从 nltk.book import *”时,它显示属性错误。from nltk.corpus import * 和 from nltk import * 工作正常
我是自然语言处理的新手,所以我对此不太了解,请帮忙
from nltk.book import * * NLTK Book 的介绍性示例 *
加载 text1, ..., text9 和 sent1, ..., sent9
键入文本或句子的名称以查看它。
输入:'texts()' 或 'sents()' 列出材料。
回溯(最近一次通话最后):
文件“”,第 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)
_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()
_check_regexp self._regexp = compile_regexp_to_noncapturing(self._pattern, self._flags) 中的文件“C:\Program Files (x86)\Python 3.5\lib\site-packages\nltk\tokenize\regexp.py”,第 121 行
文件“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:无法设置属性