AttributeError: cannot set attribute from nltk.book import *

after installing nltk I import nltk and then use nltk.download (), but when I try to use it "from nltk.book import", it shows an attribute error. from nltk.corpus import * and from nltk import * works fine

I am new to natural language processing, so I don’t know much about it, please help

from nltk.book import * * Introductory examples for the NLTK book *

Loading text1, ..., text9 and sent1, ..., sent9

Enter a name for the text or sentence to view it.

Type: "text ()" or "sents ()" to list the materials.

Traceback (last last call):

File "", line 1, in

from nltk.book import *

File "C: \ Program Files (x86) \ Python 3.5 \ lib \ site-packages \ nltk \ book.py", line 19, in

text1 = Text(gutenberg.words('melville-moby_dick.txt'))

File "C: \ Program Files (x86) \ Python 3.5 \ lib \ site-packages \ nltk \ text.py", line 295, in init

tokens = list(tokens)

File "C: \ Program Files (x86) \ Python 3.5 \ lib \ site -

packages \ nltk \ corpus \ reader \ util.py ", line 233, in len

for tok in self.iterate_from(self._toknum[-1]): pass

File "C: \ Program Files (x86) \ Python 3.5 \ lib \ site-packages \ nltk \ corpus \ reader \ util.py", line 291, in iterate_from

tokens = self.read_block(self._stream)

File "C: \ Program Files (x86) \ Python 3.5 \ lib \ site-packages \ nltk \ corpus \ reader \ plaintext.py", line 117, in _read_word_block words.extend (self._word_tokenizer.tokenize (stream.readline ( )))

File "C: \ Program Files (x86) \ Python 3.5 \ lib \ site-packages \ nltk \ tokenize \ regexp.py", line 126, in 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:

+4
1

, . , : https://github.com/nltk/nltk/issues/1135

: https://github.com/nltk/nltk/issues/1106

" , internals.py nltk parsed_pattern.pattern.groups = 1. , sre_parse.py, NLTK groups sre_parse.Pattern. Python 3.5 groups , ( , , ) subpattern. , , 75. , , - , , , , , . -, , , , ".

- .

+3

Source: https://habr.com/ru/post/1610139/


All Articles