使用nltk.download()下载错误 [英] downloading error using nltk.download()

查看:207
本文介绍了使用nltk.download()下载错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python尝试NLTK软件包.我尝试使用nltk.download()下载NLTK.我收到了这样的错误消息.如何解决这个问题呢?谢谢.

I am experimenting NLTK package using Python. I tried to downloaded NLTK using nltk.download(). I got this kind of error message. How to solve this problem? Thanks.

我使用的系统是在VMware下安装的Ubuntu. IDE是Spyder.

The system I used is Ubuntu installed under VMware. The IDE is Spyder.

使用nltk.download('all')后,它可以下载一些软件包,但是在下载oanc_masc

After using nltk.download('all'), it can download some packages, but it gets error message when downloading oanc_masc

推荐答案

要下载特定的数据集/模型,请使用nltk.download()函数,例如如果您要下载punkt句子标记器,请使用:

To download a particular dataset/models, use the nltk.download() function, e.g. if you are looking to download the punkt sentence tokenizer, use:

$ python3
>>> import nltk
>>> nltk.download('punkt')

如果不确定所需的数据/模型,可以使用以下数据和模型的基本列表开始:

If you're unsure of which data/model you need, you can start out with the basic list of data + models with:

>>> import nltk
>>> nltk.download('popular')

它将下载受欢迎"资源的列表.

It will download a list of "popular" resources.

请确保您拥有最新版本的NLTK,因为它一直在不断改进并不断得到维护:

Ensure that you've the latest version of NLTK because it's always improving and constantly maintain:

$ pip install --upgrade nltk


已编辑

万一有人从 https://stackoverflow.com/a/38135306从nltk下载较大的数据集的情况下避免出现错误, /610569


EDITED

In case anyone is avoiding errors from downloading larger datasets from nltk, from https://stackoverflow.com/a/38135306/610569

$ rm /Users/<your_username>/nltk_data/corpora/panlex_lite.zip
$ rm -r /Users/<your_username>/nltk_data/corpora/panlex_lite
$ python

>>> import nltk
>>> dler = nltk.downloader.Downloader()
>>> dler._update_index()
>>> dler._status_cache['panlex_lite'] = 'installed' # Trick the index to treat panlex_lite as it's already installed.
>>> dler.download('popular')

如果有人想找到nltk_data目录,请参见 https://stackoverflow.com/a/36383314/610569

And if anyone wants to find nltk_data directory, see https://stackoverflow.com/a/36383314/610569

要配置nltk_data路径,请参见 https://stackoverflow.com/a/22987374/610569

这篇关于使用nltk.download()下载错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆