离线安装 nltk_data

自然语言处理练习时,经常使用nltk模块,需要使用nltk_data的数据,nltk_data可以直接使用
nltk.download()直接下载安装。然而,nltk_data体积比较大,很难下载,离线安装时一个比较好的选择。
1、首先python安装nltk模块。
2、下载nltk_data离线文件,网上有资源,百度下载即可,nltk_data.tar.gz。
3、查询nltk搜索的目录

import nltk
nltk.data.find(".")

4、nltk_data文件放到第3步搜索的目录下
解压nltk_data.tar.gz文件,得到文件夹nltk_data,并将nltk_data移动到第3步搜索的目录下
5、测试

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

参考
https://blog.csdn.net/zhangcucmb/article/details/80824231

posted @ 2018-11-17 14:39  偶然相遇  阅读(6237)  评论(0)    收藏  举报