gpt4 book ai didi

nltk - python33如何使用nltk3?

转载 作者:行者123 更新时间:2023-12-03 06:02:08 26 4
gpt4 key购买 nike

我成功安装了 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?

最佳答案

首先安装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', '.']

关于nltk - python33如何使用nltk3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22327732/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com