当前位置:   article > 正文

NLTK:离线安装punkt_怎么下载nklt中的punkt

怎么下载nklt中的punkt

NLTK 3.5 documentation

官方文档给出了各种安装方法,其中,提到了命令行安装指导:

Command line installation

The downloader will search for an existing nltk_data directory to install NLTK data. If one does not exist it will attempt to create one in a central location (when using an administrator account) or otherwise in the user’s filespace. If necessary, run the download command from an administrator account, or using sudo. The recommended system location is C:\nltk_data (Windows); /usr/local/share/nltk_data (Mac); and /usr/share/nltk_data (Unix). You can use the -d flag to specify a different location (but if you do this, be sure to set the NLTK_DATA environment variable accordingly).

Run the command python -m nltk.downloader all. To ensure central installation, run the command sudo python -m nltk.downloader -d /usr/local/share/nltk_data all.

Windows: Use the “Run…” option on the Start menu. Windows Vista users need to first turn on this option, using Start -> Properties -> Customize to check the box to activate the “Run…” option.

Test the installation: Check that the user environment and privileges are set correctly by logging in to a user account, starting the Python interpreter, and accessing the Brown Corpus (see the previous section).

 Windows 系统下可使用 python -m nltk.downloader -d C:\Users\Cui\AppData\Roaming\nltk_data 将 data 安装到指定目录。

一、问题

但是再安装 punkt 时遇到一些问题:

  1. >>> import nltk
  2. >>> nltk.download('punkt')
  3. [nltk_data] Error loading punkt: <urlopen error [WinError 10054]
  4. [nltk_data] 远程主机强迫关闭了一个现有的连接。>
  5. False

这里给出 离线安装 punkt 的方法。

二、解决

1、手动下载 NLTK 数据集

这里直接附上别人的博客《解决nltk download(‘punkt‘) 连接尝试失败》

异可在官网下载:NLTK Corpora

2、安装 punkt

把下载好的语料包 punkt.zip 解压到 nltk_data/tokenizers/ 中。

注:因为 punkt 属于 tokenizers 所以需要新建 tokenizers 文件夹。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/377582
推荐阅读
相关标签
  

闽ICP备14008679号