如何使用nltk3 for python33?

时间:2014-03-11 13:51:24

标签: nltk python-3.3

我成功安装了NLTK 2.0.4,但当我尝试下载NLTK软件包时,即

nltk.download('stopwords')

它不起作用,所以我试图为python 3安装NLTK的更新版本,但是它给出了这个错误:

>>> 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

有没有办法为python33安装NLTK?

1 个答案:

答案 0 :(得分:3)

首先安装python3-pip然后用它来安装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', '.']