NLP初試牛刀,NLTK入門第一篇

以前下載過一個PDF,書名是《用python進行天然語言處理》,挺有意思的,加上NLP和機器學習目前大熱,想趁着暑假涉獵一下。因而開始了入門NLP之旅。python

安裝環境:Ubuntu14.04桌面版,python版本:2.7bash

第一步:安裝nltk,首先要安裝pip工具:sudo apt-get install python-pip,安裝完成後用pip安裝nltk:sudo pip install python-nltk。機器學習

第二步:下載nltk全部的包,在終端中進入python的交互模式,工具

>>> import nltk
>>> nltk.download()
>>> d
>>> all

 

接着就等吧,包很大,我斷斷續續下了兩三天才下完。學習

第三步,安裝numpy和matplotlib工具,主要是用來數據分析和圖形化顯示。下面是引用別人的一部分:spa

安裝numpy相對簡單,如下命令能夠完成
 
$ sudo apt-get install python-numpy
$ sudo apt-get install python-scipy
 
安裝matplotlib相對複雜一些
須要先安裝其依賴的包libpng和freetype
安裝libpng:
$ sudo apt-get install libpng-dev
 
安裝freetype:
 
$ cd ~/Downloads
$ wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.10.tar.gz
$ tar zxvf freetype-2.4.10.tar.gz
$ cd freetype-2.4.10/
$ ./congfigure
$ make
$ sudo make install
 
安裝好pip後就能夠用下面的命令來查找matplotlib和查看其安裝狀態
$ sudo pip search matplotlib
 
安裝matplotlib
$ sudo pip install matplotlib
 
完成上述的步驟,就能夠正式進入NLTK學習啦!
相關文章
相關標籤/搜索