NER study notes - use Ltp

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https: //blog.csdn.net/xuewenstudy/article/details/85028173
        NER (Named Entity Recognition, referred NER) is used to identify the text entities that have special meaning. We need to identify the entity can be divided into three categories (entity class, class time and class numbers) and seven subcategories (name, organization name, place name, time, date, currency, and percentage).

        This article describes the use of named entity recognition Ltp.

1, the mounting assembly Ltp Python

(1) pyltp installation:

pip install pyltp

(Not supported conda-python)

(2) Deploy language model library:

Download link: http: //ltp.ai/download.html

After extracting shown in FIG.

 

cws is the Chinese word segmentation model, ner is named entity recognition model, paeser is parsing model, pos is POS tagging model.

2, named entity recognition Ltp

(1) Code:

import sys
import os
from pyltp import *

sent = "eastern Europe Romania capital Bucharest, is a cosmopolitan city."
words = sent.split ( "")

= Postagger postagger ()
postagger.load ( "D: \\ ltp_data_v3.3.1 the Projects \\ \\ \\ pos.model NLP") # Import speech tagging module
postags = postagger.postag (words)

= NamedEntityRecognizer Recognizer ()
recognizer.load ( "D: \\ ltp_data_v3.3.1 the Projects \\ \\ \\ ner.model NLP") # Import named entity recognition module
netags = recognizer.recognize (words, postags)

for word,postag,netag in zip(words,postags,netags):
    print(word+'/'+postag+'/'+netag)

(2) Run results:

 

Word, speech recognition of the proper name by a "/" separated, "O" denotes a non-proper name, "S-Ns" represents names.

references:

Zheng Jie, "NLP Chinese Natural Language Processing Theory and
Practice" ----------------
Disclaimer: This article is the original article CSDN bloggers "xuewenstudy", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/xuewenstudy/article/details/85028173

 

Guess you like

Origin www.cnblogs.com/jfdwd/p/11468795.html