解决NLTK包下载出错问题及nltk测试

官方下载地址

http://www.nltk.org/nltk_data/

安装NLTK-Data

你可以作死的尝试

>>>import nltk
>>>nltk.download()

先点击Refresh,刷新下,之后选中all-corpora点击左下角下载就好,至于路径 

要么在C盘中,要么在Python的根目录下!C盘根目录最靠谱!

这是官方正统下载方式,但是肯定会出错的!不仅下的慢,而且下一半就出错!

这里才是正确的下载方式:最好的方法是用使用@V_can打包好的的包网盘下载下载地址1:云盘密码znx7,下来的包nltk_data.zip 解压到C盘根目录下,这样是最保险的,防止找不到包。下载地址2:云盘密码4cp3

 
 

NLTK测试

In[4]:from nltk.book import *
# 只输入import nltk 会出错的,但却有很多博客上都这么写,我也母鸡

之后会出现如下显示:

*** 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

继续测试输入:

In[5]:text1

会输出:

Out[5]: 
<Text: Moby Dick by Herman Melville 1851>

再测试输入:

In[6]: text1.concordance("monstrous")

输出:

Displaying 11 of 11 matches:
ong the former , one was of a most monstrous size . ...

ok,这里就演示那么多,到此,NLP的环境就装好了,调试完毕,可以用于自己的实验了。



  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值