您的位置:首页 > 编程语言 > Python开发

windows环境下搭建python+nltk开发环境

2016-04-06 21:53 387 查看
在windows 32-bit 下的安装步骤如下:

1、Install Python

2、Install Numpy (optional)

3、Install NLTK

4、Install PyYAML

5、Test installation: Start>Python27, then type import nltk

===============================================================================================

1、首先,安装python 2.7

  详见http://blog.sina.com.cn/s/blog_8af1069601019opa.html

===============================================================================================

2、安装Numpy(可选操作)

  http://sourceforge.net/projects/numpy/files/NumPy/1.6.2/numpy-1.6.2-win32-superpack-python2.7.exe/download

  -》直接下载

  -》双击运行,下一步下一步点击。





  -》安装完成。

===============================================================================================

3、安装NLTK。

  https://pypi.python.org/pypi/nltk

  -》nltk-2.0.4.win32.exe
(md5)(Python 2.5 or higher)

  -》双击运行,一次点击下一步





  -》安装完成

===============================================================================================

4、安装PyYAML。

  http://pyyaml.org/wiki/PyYAML

  -》Download and Installation-》Windows installers:

  -》http://pyyaml.org/download/pyyaml/PyYAML-3.10.win32-py2.7.exe (for Python 2.7)

  -》双击运行





  -》完成。

===============================================================================================

5、NLTK数据源下载。

  -》在python IDLE中键入:

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

   会输出:showing info http://nltk.github.com/nltk_data/
   并出现图:

   

 

  -》选择all,设定好下载路径Download Directory(例如设定D:\nltk_data)。

    然后点击Download,系统就开始下载NLTK的数据包了,下载的时间比较漫长,大家要耐心等待。

  -》或者也可以到NLTK Corpora:http://nltk.org/nltk_data/ 来手动下载。

    这个页面下的文档就是上图包含的所有的内容

   



  -》下载数据完成。

===============================================================================================

6、来一个简单的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
===============================================================================================
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nltk