PYLTP Local Installation method for natural language processing tool

Source: Internet
Author: User

In the study, it is found that the effect of LTP in Word segmentation and entity recognition is even better than that of CAs Ictclas, and LTP has the function of semantic role labeling (SRL) which is rare in the field of Chinese processing. I used to get through the Ltp-cloud directly in the past, but because of the limited speed, when the corpus is relatively slow to execute. So the recent consideration in their own machine installed, because individuals prefer to use Ython programming, so installed the official release of the PYLTP. During the installation process encountered a lot of problems, I contacted the hit Dr. Liu Yijia and Xu Zixiang classmates, in their patience with the help of the successful installation finally. Thanks to them! Now my installation process to make a summary, so that you also less detours.

1 Preparation Work 1.1 system environment

My environment is Windows Server 2008,python3.2 (32-Bit Edition), development tools for Hbuilder "You may also know that Hbuilder is suitable for web development, but after installing Pydev plug-ins for Hbuilder, you can also write Python programs , because I usually also like to write some PHP Web pages, just a software can meet Me "

1.2 Installing CMake

LTP is written in C + +, PYLTP is also based on its encapsulation, so you need to install Camke. I installed the binary plate Cmake-3.2.2-win32-x86.exe after installation without configuring environment variables.

1.3 Installing VS2008

During the installation of PYLTP, it is necessary to call Cl.exe to finish compiling the source code. The official VS2008 Express version of Microsoft is installed. Once this is installed, you need to add the cl.exe path to the environment variable path (for example, my C:\Program Files (x86) \microsoft Visual Studio 9.0\vc\bin\cl.exe)

2 PYLTP Installation Step 2.1 download PYLTP and unzip to any location

Download page: HTTPS://GITHUB.COM/HIT-SCIR/PYLTP

2.2 Download LTP and unzip to any location

Download page: HTTPS://GITHUB.COM/HIT-SCIR/LTP

2.3 The extracted LTP folder is named LTP, and the whole is copied to PYLTP.

That is, LTP all content as a folder into PYLTP. After extracting PYLTP, there is already an empty folder named LTP in the folder, which can be replaced or overwritten.

2.4 Installing PYLTP

I was in cmd through the Python setup.py install command to implement the installation, the process is slow, patient wait, there will be a lot of warning information later, do not care. After the installation program finishes executing, import PYLTP in Python does not error, indicating that the installation was successful.

The deployment of the core program has been completed, and the official sample has been implemented successfully. I deployed this folder to my own Python project and found it to be very bad when running the example program. After further consultation with the above two students learned that the PYLTP of these model files (in the Ltp_data folder) for testing purposes only, the official model files need to be downloaded from the Internet. See step 2.4.

2.4 Download and deploy the model file

Complete model file: http://pan.baidu.com/share/link?shareid=1988562907&uk=2738088569, I chose the current 3.2.0 version ( Ltp-data-v3.2.0.zip), extract a folder larger than 1G to ensure that the folder name is Ltp_data. As for where to put this folder, after analyzing the official example, find its location arbitrary, but in the Python program must indicate this path. So I put it in the root of my project and make sure that it is tied to the SRC directory where the python source is stored, so that the official example can load the folder without modification.

Note that the official example is based on Python2, and if you and I are also Python3 series, then you need to enclose the statement after print with parentheses

When you're done, you'll find that PYLTP is finally ready to run.

When performing the second function, the POS callout, the console appears with a warning:[WARNING] 2015/04/27 18:50:10 no constraints is loaded. Upon enquiry This is a hint that the custom POS label dictionary is not loaded. The official explanation is that this is due to the fact that the current version of PYLTP does not yet support users to join the local dictionaries.

The next step is to understand how to parse PYLTP's execution results.

PYLTP Local Installation method for natural language processing tool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.