LTP tool test

tags: Natural language processing  artificial intelligence  nlp

Recently, I am doing some tasks about NLP. LTP provides a series of Chinese natural language processing tools. Users can use these tools to divide Chinese texts, segmentation, word -based marking, syntax analysis, and semantic marking.

Here is mainly rightLanguage Technology PlantForm | LTP)The online document records the test of Python.

Version:

ltp4.1.5.post2

python3.9

One, clause

from ltp import LTP
ltp = LTP()
input_file_dir = R'd: \ Graduation thesis \ Data processing \ text example.txt '
lines = [line.strip() for line in open(input_file_dir, 'r', encoding='utf-8').readlines()]
for line in lines:
    print(line)
    sents = ltp.sent_split(line)
    print(sents)
    exit()

result:

There were no clauses, but a single character.

Word

from ltp import LTP
ltp = LTP()
 input_file_dir = R'd: \ Graduation thesis \ Data processing \ text example.txt '
lines = [line.strip() for line in open(input_file_dir, 'r', encoding='utf-8').readlines()]
for line in lines:
    print(line)
    sents, hidden = ltp.seg([line])
    print(sents)
    exit()

result:

Successful word

Third, word marks

print(line)
sents, hidden = ltp.seg([line])
pos = ltp.pos(hidden)
print(sents)
print(pos)

result

Label correctly

Fourth, naming entity identification

ner = ltp.ner(hidden)
print(sents)
print(ner)
for i in range(len(ner[0])):
    tag, start, end = ner[0][i]
    print(tag, ":", "".join(sents[0][start:end + 1]))

result:

LTP's naming entity recognition can only identify common people's names, place names, and institutional names, which is not applicable to proprietary entities in the professional field.

5. Semantic character labeling

srl = ltp.srl(hidden,keep_empty=False)
print(srl)
for i in range(len(srl[0])):
tag = srl[0][i][0]
for j in range(len(srl[0][i][1])):
    lable_,start,end=srl[0][i][1][j]
    print(sents[0][tag], ":",lable_, "".join(sents[0][start:end + 1]))

result:

Semantic character labeling effect is very good

6. Analysis of dependent clauses

dep = ltp.dep(hidden)

result:

Successful labeling, because there is no sentence, the marking is too long and inaccurate, and you need to divide the sentence in advance.

seven,

  #Svanic dependence analysis (tree)
 sdp1 = ltp.sdp(hidden, mode='tree')
   # Semantic dependence analysis (Figure)
 sdp2 = ltp.sdp(hidden, mode='graph')

result:

 

Intelligent Recommendation

Ltp test suite - pthread_rwlock_rdlock_2-1 analysis record

The test pthread_rwlock_rdlock_2-1.c use case failed. The log is as follows: [83#yuchen@ubuntu ltp]# gcc 2-1.c -o 21 -pthread [84#yuchen@ubuntu ltp]# ./21 main: has priority: 3 main: attempt read lock...

Shell script example (2)-ltp test

Test sched_latency_dl 100 times  ...

LTP Chapter 4 Development_exit() Test Set

LTP series link: Chapter 1 Introduction to LTP and Internal Mechanism Chapter 2 Develop Shell Test Set Chapter 3 Development System Call Test Set Chapter 4 Development _exit() test set Chapter 5 Devel...

LTP (Linux Test Project) User Guide

Article Directory 1. Introduction to ltp-ddt 1.1、ltp 1.2、ltp-ddt 2. Environmental structure 2.1, cross compilation 2.2, file system 3. Test run 1. Introduction to ltp-ddt 1.1、ltp LTP (Linux Test Proje...

LTP Chapter 2 Develop Shell Test Set

LTP series link: Chapter 1 Introduction to LTP and Internal Mechanism Chapter 2 Develop Shell Test Set Chapter 3 Development System Call Test Set Chapter 4 Development _exit() test set Chapter 5 Devel...

More Recommendation

Compilation of LTP (Linux Test Project) for Android

Linux Test Project (GitHub home page is here) (Hereinafter referred to as LTP) A collection of tools containing the Linux kernel and kernel-related features. The purpose of this tool is to improve the...

UOS LTP compile USSTAT test item error

Environmental information Error information Show repeatedly definition the Struct USTAT structure. analyze There is no definition of Struct USTat in a normal environment. If you want to use this struc...

LTP (Linux-TEST-PROJECT) test kit cross-compilation method

1. Download URL 2. Compilation method Manual Strip 3. Compile single use cases After the overall compilation is completed You can directly enter the sub -directory make to compile the code of a single...

Natural language processing tool LTP language cloud calling method

Preface LTP language cloud platform Does not support offline calls; stand byWord segmentation, part-of-speech tagging, named entity recognition, dependency syntax analysis, semantic role tagging;   Do...

LTP (Linux Test Project) study (six) - Analysis: limit chattr command

(Bug found himself before the selection can be more in-depth analysis of the problem on the next course) patch corresponding to commit: 9af831cdf6d2328e6f6fcd85dd1d5523fd8681d3 BUG found Individual le...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top