Into the pit python natural language processing

Recently, the most important job in python natural language processing is to configure the environment!
Including: python, IDE, NLTK installation

1.python : First install python. No matter what software is installed, my principle is to install new and not old (the latest version is not very good, it is prone to bugs, so it is best to install the latest stable version), so I installed 3.8. 7. However, python3 has a lot of changes compared to python2 syntax. Many examples in the book need to be debugged by yourself, so it may be easier to install python2. It depends on personal choice.
Installation tutorial (novice): https://www.runoob.com/python/python-install.html
Insert picture description here
2. IDE: If you want to do a project, you must have an integrated development environment, I use pycharm, the interface style is the same as IDEA, Because it was developed by the same company. . The process of building a project is also very similar to IDEA, so it should be very friendly to java players. There are also many good other IDEs, such as Vim and Wing.
For details , see Zhihu : https://www.zhihu.com/question/27359349
pycharm installation tutorial (reproduced from the blog garden): https://www.cnblogs.com/ After installing pycharm in java0011/p/13603696.html
, bind the interpreter to the py interpreter you just downloaded (pycharm comes with an interpreter, you can ignore this step, but in order to facilitate future coding in IDLE, it is best to bind it ), step: File->settings->project->Project Interpreter
Insert picture description here
in the red box, select the python interpreter you just downloaded (see path)

3.NLTK: The last one is py's natural language processing toolkit. It is very simple. Install nltk first, and then download nltk_data in the specified path of your computer. nltk_data is the text data set needed for the experiment. The method in the book, that is, run in IDLE:

pip install nltk #安装nltk
import nltk      #导入nltk
nltk.download()  #下载nltk_data

The link it gives requires fq, so it is recommended to download the "nltk_data" compressed package by yourself.
Download link: https://pan.baidu.com/s/1JeuBy67fl6MOcAJTQhh17g (extraction code: cg6y)
and save it to one of the following paths:
C:\… \nltk_data
C:\nltk_data
D:\nltk_data
E:\nltk_data

I save it in the root directory of Disk D:
Insert picture description here
Then import the data we just downloaded in IDLE:
Run: from nltk.book import *
The following content means successful operation:
Insert picture description here
Let's start our happy journey of NLP!

Guess you like

Origin blog.csdn.net/weixin_42419611/article/details/112404677
Recommended