HIT NLP processing tool pyltp installation process

   The installation of pyltp can be described as difficult. pyltp is a natural language processing package of Harbin Institute of Technology. It is used for word segmentation, part-of-speech tagging, and dependency syntax analysis. It is currently one of the best parsers in China.
   However, its word segmentation and other methods and models are written in C++ code, so when using python to call, you need to have VC library, that is, you need to download Visio studio, the version is above 2008, but the version of pyltp and the model version such as word segmentation that needs to be downloaded later, And the VS version, must be consistent.
   I downloaded the latest pyltp version 1.9, which can be downloaded using pip. I must install vs before. I tried it from the 2008 version, and the download was successful until the 2015 version, otherwise an error will be reported: cant find vcvarcall.bat, this is in the path Under C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC. Sometimes it is not automatically added after downloading, and you need to manually add environment variables. After the download is successful, start downloading the ltp_data model file. Address https://pan.baidu.com/share/link?shareid=1988562907&uk=2738088569#list/path=%2F (After downloading, place the directory at will, and you need to manually specify the directory when using it), version 0.1.9 It must match the model of version 3.4, otherwise it will report an error: does not match the C++ signature.
    Now pyltp is installed successfully, enter the test code

# -*- coding: utf-8 -*-
from pyltp import SentenceSplitter
def sentence_splitter(sentence='this is the code of a test clause'):
    sents = SentenceSplitter.split(sentence ) 
    print '\n'.join(sents) #The
test sentence
sentence_splitter()

succeeded~~

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326678216&siteId=291194637