Summary of pyltp installation process

I stepped on a lot of pits during the installation of pyltp. Here is a summary of the pit process to prevent everyone from stepping on the pit:

The first step: install pyltp

Look at other blogs here and give two methods: one is to directly pip , and the other is to use git clone pyltp 's github, and then python setup,py installinstall it. But these two methods will report errors, so you can install directly using wheel:
pyltp-0.2.1-cp35-cp35m-win_amd64.whl
pyltp-0.2.1-cp36-cp36m-win_amd64.whl

After the download is complete, enter the downloaded directory of whl pip install wheel文件名to install it.

After this is installed, you can pass the following tests:

from pyltp import SentenceSplitter
sents = SentenceSplitter.split('元芳你怎么看?我就趴窗口上看呗!')  # 分句
print('\n'.join(sents))

Step 2: Download the ltp model

ltp download address

Download the zip of the model through the download address. I downloaded the 3.4.0 version, and the python version is 3.6. After downloading, be sure to save the path of the model in a pure English path, otherwise the model will not be loaded.

Common errors

一. error: Microsoft Visual C++ 14.0 is required. Get it with “Build Tools for Visual Studio”

Win will prompt that you need a C++ environment. The solution is: download
from the official website. After entering the official website, select "Redistributable Components and Generation Tools" and
Insert picture description here
select "Microsoft Generation Tools 2015 Update 3" to download and install.
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_29027865/article/details/106771588