Python NLTK库安装Error:Resource u*corpora/gutenberg* not found.

转载请标明出处:
http://blog.csdn.net/djy1992/article/details/72828734
本文出自:【奥特曼超人的博客】

提起聊天机器人, 想必大家会想起一个优秀的库,NLTK库,这里简化了安装流程并提到大家都会遇到的一个错误。

Resource u*corpora/gutenberg* not found. Please use the NLTKDownloader to obtain the resource: 

运行环境:

WIN+Python 2.7

安装:

 pip install nltk

运行

from nltk.book import *

然后出错:

Resource u*corpora/gutenberg* not found. Please use the NLTKDownloader to obtain the resource.

《Python NLTK库安装Error:Resource u*corpora/gutenberg* not found.》

想起未安装内容库,用命令down下来:

import nltk
nltk.download()

弹出界面:

《Python NLTK库安装Error:Resource u*corpora/gutenberg* not found.》

选择 Download Directory 的时候要注意,默认路径是从这几个地方查找的,这里我放的是: C:\Python27\Lib\nltk_data
需要注意: 安装位置不对也会报错,所以要找到相应的位置进行解压。

《Python NLTK库安装Error:Resource u*corpora/gutenberg* not found.》

我选的是all download,发现太慢,先下载 book 了,反正有个模块调用成功就行 ( 下载会比较慢,你懂的 )。

*** Introductory Examples for the NLTK Book ***
Loading text1, ..., text9 and sent1, ..., sent9
Type the name of the text or sentence to view it.
Type: 'texts()' or 'sents()' to list the materials.
text1: Moby Dick by Herman Melville 1851
text2: Sense and Sensibility by Jane Austen 1811
text3: The Book of Genesis
text4: Inaugural Address Corpus
text5: Chat Corpus
text6: Monty Python and the Holy Grail
text7: Wall Street Journal
text8: Personals Corpus
text9: The Man Who Was Thursday by G . K . Chesterton 1908

测试下命令。

>>> text1
<Text: Moby Dick by Herman Melville 1851>

成功输出,这里输出的是书籍标题 Moby Dick by Herman Melville 1851,证明已经是OK了,这里提供份百度云下载,下载完记得 解压,不然会 报同样的错误无法找到相关内容:

链接: http://pan.baidu.com/s/1kV5dM6N 密码: imde

|| 版权声明:本文为博主杜锦阳原创文章,转载请注明出处。

点赞