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

来源:互联网 发布:java用什么软件编程 编辑:程序博客网 时间:2024/06/06 20:50

转载请标明出处:
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.

奥特曼超人杜锦阳

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

import nltknltk.download()

弹出界面:

奥特曼超人杜锦阳

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

奥特曼超人杜锦阳

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

*** Introductory Examples for the NLTK Book ***Loading text1, ..., text9 and sent1, ..., sent9Type the name of the text or sentence to view it.Type: 'texts()' or 'sents()' to list the materials.text1: Moby Dick by Herman Melville 1851text2: Sense and Sensibility by Jane Austen 1811text3: The Book of Genesistext4: Inaugural Address Corpustext5: Chat Corpustext6: Monty Python and the Holy Grailtext7: Wall Street Journaltext8: Personals Corpustext9: 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



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