Demo entry 6741310

NER

   

Submitted by anonymous on May 15, 2018 at 08:05
Language: Python 3. Code size: 551 Bytes.

# 路径指定部分
# 要使用的模型目录的路径
LTP_DATA_DIR = '../pyltp/model/ltp-data-v3.3.1/'   
# 用于分词的模型             
cws_model_path = os.path.join(LTP_DATA_DIR, 'cws.model')       
# 用于词性标注的模型
pos_model_path = os.path.join(LTP_DATA_DIR, 'pos.model')        
# 用于NER的模型
ner_model_path = os.path.join(LTP_DATA_DIR, 'ner.model')        

# 初始化实例并加载模型 注意SentenceSplitter不需要初始化
segmentor = Segmentor()
segmentor.load(cws_model_path)
postagger = Postagger()
postagger.load(pos_model_path)
recognizer = NamedEntityRecognizer() 
recognizer.load(ner_model_path)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).