日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

nltkdata路径设置linux,NLTK data路径设置

發布時間:2024/9/27 linux 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 nltkdata路径设置linux,NLTK data路径设置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

安裝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 "", line 1, in

from nltk.book import *

File "C:\Python26-B\lib\site-packages\nltk\book.py", line 22, in

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 問題即解決。

總結

以上是生活随笔為你收集整理的nltkdata路径设置linux,NLTK data路径设置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。