python自然语言处理:NLTK+Ubuntu+Eclipse环境配置

来源:互联网 发布:网络硬盘录像机多少钱 编辑:程序博客网 时间:2024/06/07 02:23

配置环境

  1. 安装eclipse
  2. 添加pydev插件
    这里写图片描述
  3. 安装完提示重启eclipse
  4. 首先通过下面的命令安装pip,pip是Python的一个安装和管理扩展库的工具
    sudo apt-get install python-pip
  5. 安装Python开发环境,方便今后编译其他扩展库
    sudo apt-get install python-dev
    安装missing的包
    apt-get update –fix-missing

  6. 安装nltk
    sudo apt-get install python-nltk

  7. 安装numpy
    sudo apt-get install python-numpy
  8. 安装python-matplotlib
    sudo apt-get install python-matplotlib
  9. 安装prover9
    sudo apt-get install prover9
  10. 安装python-scipy
    sudo apt-get install python-scipy
  11. 配置dev 解释器,选择auto-config
    这里写图片描述

安装nltk data

官网的安装教程是很简单的,但是在大陆的网速是让人崩溃的
http://www.nltk.org/data.html
所幸的是,github上有人指出它实际下载的位置是:
http://www.nltk.org/nltk_data/
然后我按照错误提示
Resource ‘corpora/brown’ not found. Please use the NLTK
Downloader to obtain the resource: >>> nltk.download().
Searched in:
- ‘/home/hadoop/nltk_data’
- ‘/usr/share/nltk_data’
- ‘/usr/local/share/nltk_data’
- ‘/usr/lib/nltk_data’
- ‘/usr/local/lib/nltk_data’
创建了一个文件夹 /usr/share/nltk_data
随后将网站上下载的zip解压到nltk_data中的corpora文件夹下:
hadoop@lucy-desktop:/usr/share/nltk_data/corpora$ ls
brown

再运行:

>>> from nltk.corpus import brown>>> brown.words()['The', 'Fulton', 'County', 'Grand', 'Jury', 'said', ...]

就是可以的了。

有没有一键安装的方法呢?
根据这个讨论,应该也是有的:
https://github.com/nltk/nltk/issues/565
在github上
https://github.com/nltk/nltk_data/tree/gh-pages

Apart from individual data packages, you can download the entire collection (using “all”), or just the data required for the examples and exercises in the book (using “book”), or just the corpora and no grammars or trained models (using “all-corpora”).

下载后目录内容为:
这里写图片描述
找到tools文件夹:
执行
sudo ./download.sh all
就安装了整个collection 在 /usr/share目录下


参考文献:
ubuntu12.04 Eclipse Python下的nltk环境搭建
http://blog.csdn.net/caicai1617/article/details/21322645

MOOC上公开课:
https://class.coursera.org/nlangp-001/lecture

更具体的:
哪些公开课上关于NLP的?
https://www.quora.com/What-is-the-best-natural-language-processing-MOOC

1 0
原创粉丝点击