python nltk 安装及配置说明

本教程采用pip安装方式,前期需要在本机安装setuptools 及pip

网上铺天盖地的说了很多关于nltk的说明,特别是后期nltk_data 手动下载操作,多数都不好使,这里整理

 

用pip安装nltk , 运行pip install nltk,等一段时间安装完成以后。进入IDLE界面(可以通过windows搜索栏查找,这是python的终端)敲入下面两行代码:

import nltk  
nltk.download()   
  
   随后弹出下面界面(坚持,离成功不远了)
 
  

选择第三项book,然后等待下载安装完成即可。如果由于网络等原因造成无法下载也可以到http://nltk.org/nltk_data/ 来手动下载。

如果手动指定了nltk_data的保存目录,需要添加环境变量
  手动下载的nltk_data-gh-pages包中,真正需要的是该文件夹中的packages,将此文件夹重命名为nltk_data,并添加此目录到系统环境变量
否则会报错:
错误

检测nltk_data是否安装成功:

输入: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
 
按照如上方法即可完成nltk的全部安装,希望对大家有帮助!
 

转载于:https://www.cnblogs.com/fclbky/p/7920810.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值