NLTK data路径设置
来源:互联网 发布:java web 反编译 编辑:程序博客网 时间:2024/05/17 12:21
安装nltk后用这个命令:from nltk.book import *
按照正常的,应该出现以下:
>>> from nltk.book import *
*** 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
>>>
但是我出现的是这个:
>>> from nltk.book import *
*** 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.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from nltk.book import *
File "C:\Python26-B\lib\site-packages\nltk\book.py", line 22, in <module>
text1 = Text(gutenberg.words(*melville-moby_dick.txt*))
File "C:\Python26-B\lib\site-packages\nltk\corpus\util.py", line 99, in __getattr__
self.__load()
File "C:\Python26-B\lib\site-packages\nltk\corpus\util.py", line 64, in __load
except LookupError: raise e
LookupError:
**********************************************************************
Resource u*corpora/gutenberg* not found. Please use the NLTK
Downloader to obtain the resource: >>> nltk.download()
Searched in:
- *C:\\Users\\XXXXXX/nltk_data*
- *C:\\nltk_data*
- *D:\\nltk_data*
- *E:\\nltk_data*
- *C:\\Python26-B\\nltk_data*
- *C:\\Python26-B\\lib\\nltk_data*
- *C:\\Users\\XXXXX\\AppData\\Roaming\\nltk_data*
**********************************************************************
按照正常的,应该出现以下:
>>> from nltk.book import *
*** 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
>>>
但是我出现的是这个:
>>> from nltk.book import *
*** 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.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from nltk.book import *
File "C:\Python26-B\lib\site-packages\nltk\book.py", line 22, in <module>
text1 = Text(gutenberg.words(*melville-moby_dick.txt*))
File "C:\Python26-B\lib\site-packages\nltk\corpus\util.py", line 99, in __getattr__
self.__load()
File "C:\Python26-B\lib\site-packages\nltk\corpus\util.py", line 64, in __load
except LookupError: raise e
LookupError:
**********************************************************************
Resource u*corpora/gutenberg* not found. Please use the NLTK
Downloader to obtain the resource: >>> nltk.download()
Searched in:
- *C:\\Users\\XXXXXX/nltk_data*
- *C:\\nltk_data*
- *D:\\nltk_data*
- *E:\\nltk_data*
- *C:\\Python26-B\\nltk_data*
- *C:\\Python26-B\\lib\\nltk_data*
- *C:\\Users\\XXXXX\\AppData\\Roaming\\nltk_data*
**********************************************************************
>>>
看下面的目录就明白了,下载nltk_data时我更改了路径,而默认的搜索路径中没有我的nltk_data路径。
在 http://www.datatang.com/data/16932 中找了如下内容:
If you did not install the data to one of the above central locations, you will need to set the NLTK_DATA environment variable to specify the location of the data. (On a Windows machine, do right click on "My Computer", select Properties > Advanced > Environment Variables > User Variables > New...)
所以在电脑属性环境变量中增加 NLTK_DATA ,设置自己的路径后,重新打开Python 问题即解决。
0 0
- NLTK data路径设置
- nltk在python中的安装,以及nltk的data库
- Python: ubuntu 下安装nltk以及载入 nltk-data
- NLTK
- nltk
- 路径设置
- Android获取文件夹路径 /data/data/
- Android获取文件夹路径 /data/data/
- Android获取文件夹路径 /data/data/
- Android获取文件夹路径 /data/data/
- Android获取文件夹路径 /data/data/
- Android获取文件夹路径 /data/data/
- Android获取内部文件夹路径(/data/data/)
- 关于Android获取文件夹路径 /data/data/
- Android获取文件夹路径 /data/data/
- Android获取文件夹路径 /data/data/
- Android文件夹路径/data/data/包名/
- Core Data属性设置
- 从Essential Matrix估计R,T
- gcc 编译unset LIBRARY_PATH CPATH C_INCLUDE_PATH PKG_CONFIG_PATH CPLUS_INCLUDE_PATH INCLUDE
- IOS 调试lldb命令常用----po
- 广聚能源
- g++编译链接文件基础中的基础
- NLTK data路径设置
- mybatis实战教程(mybatis in action),mybatis入门到精通
- iOS开发UI篇—0408控制器的三种创建方式
- json的解析和序列化
- 如何获得当前运行模块在进程地址空间的位置
- 程序员的想法
- 链表中环的入口结点
- Linux下静态库文件和动态库文件的生成和使用
- C++模板实现事件处理器中的“通用成员函数指针”的调用(一)