Python+NLTK environment construction under Windows7 platform

1 Installation

Development environment: windows 7 64 bit + 32 Python 2.7.12 bit

 

A statement: Since the installation steps given by NLTK 's official website mention "Install Python 3.4: http://www.python.org/ downloads (avoid the 64-bit versions) ", that is, tell everyone not to download 64 - bit versions python , so I'm using the 32 -bit version 3.3.2 .

 

1 Install python , the installation path is D:\mysoftware\Python27 , and configure the environment variables

  After path add: ;D:\mysoftware\Python27

 

2 Install Numpy , download the corresponding python 3.3 version, I downloaded numpy-1.9.2-win32-superpack-python2.7.exe

 

3 Install pip

pip is used to install subsequent packages. Before installing pip, make sure that Python and easy_install are installed.

If python is successfully installed, easy_install is located in the scripts folder of the Python installation directory, for example, D:\mysoftware\Python27\Scripts.

Enter the Scripts path in the Python installation directory and execute

easy_install.exe pip

The following figure appears, indicating that the pip installation was successful.

Check the pip version, enter pip --version, and press Enter to appear:

pip 8.1.1 from d:\mysoftware\python27\lib\site-packages (python 2.7)

Add the pip path to the environment variable path, so that it can be found directly from cmd.

4 Install nltk

Install with pip:

pip install nltk

5 Install PyYAML

pip install PyYAML

 

 

7 These are all installed, and then run the Python IDE environment:

 

Then, the Python Launcher will pop up the following interface, it is recommended that you choose to install all the Packages, so as to avoid installation again and again in the future, and also provide a stable environment for your subsequent development. The Status of some packages shows "out of date", you can ignore it, it basically does not affect your use and development.

 

Modify the download directory, click download to download, the download speed is very slow, and sometimes an error is reported.

The best way is to download it from the package network disk packaged with @V_can

Download address 1: https://pan.baidu.com/s/1slP4wfr

Cloud disk secret: znx7

Download address 2: https://pan.baidu.com/share/init?shareid=100987267&uk=2720665201

Cloud disk password: 4cp3

There are two ways to join this data.

Method 1: Unzip nltk_data.zip to the python root directory :

Method 2 : Put a path yourself and configure the environment variable NLTK_DATA

 

 

2 NLTK test

To test whether the environment is installed, please follow the steps below (all done in the python console, which is the kind of IDE that inputs one line and outputs one line):
In[4]:from nltk.book import *
# Only import nltk will cause an error, but There are many blogs that write this, and I am also a hen
. After that, the following display will appear:
*** 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
Continue to test the input:
In[5]: text1
will output:
Out[5]:
<Text: Moby Dick by Herman Melville 1851>
Test the input again:
In[6] : text1.concordance("monstrous")
output:
Displaying 11 of 11 matches:
ong the former , one was of a most monstrous size . ...
ok, there are so many demonstrations here, at this point, the NLP environment is installed , after debugging, you can use it for your own experiments.

 

3 Reference URL

http://www.jianshu.com/p/9c48e8edc7aa

http://blog.csdn.net/huyoo/article/details/12188573

http://blog.csdn.net/u010784534/article/details/48847697

http://blog.csdn.net/sinat_28224453/article/details/51462935

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325639857&siteId=291194637