How to use nltk3 for python33?

匆匆过客 提交于 2019-12-23 16:35:49

问题


I successfully installed NLTK 2.0.4, but when I tried to download the NLTK packages, i.e.

nltk.download('stopwords')

it doesn't work, so I am trying to install an updated version of NLTK for python 3 but it gives this error:

>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Prashant\AppData\Roaming\Python\Python33\site-packages\nltk\_
nit__.py", line 37
    except IOError, ex:
              ^
SyntaxError: invalid syntax

Is there any way to install NLTK for python33?


回答1:


First install python3-pip then use it to install pyyaml

$ sudo apt-get install python3-pip
$ sudo pip3 install pyyaml
$ wget http://www.nltk.org/nltk3-alpha/nltk-3.0a3.tar.gz
$ tar -xzvf nltk-3.0a3.tar.gz
$ cd nltk-3.0a3/
$ sudo python3 setup.py install
$ python3
>>> import nltk
>>> from nltk.corpus import brown
>>> print(brown.sents()[0])
['The', 'Fulton', 'County', 'Grand', 'Jury', 'said', 'Friday', 'an', 'investigation', 'of', "Atlanta's", 'recent', 'primary', 'election', 'produced', '``', 'no', 'evidence', "''", 'that', 'any', 'irregularities', 'took', 'place', '.']


来源:https://stackoverflow.com/questions/22327732/how-to-use-nltk3-for-python33

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!