pyltp库的使用进行文本分析

pyltp目前支持puthon3.6不支持3.7

用python3.7安装了很久都没有安装成功

无奈换成了3.6

 分句

from pyltp import SentenceSplitter
sents = SentenceSplitter.split('元芳你怎么看?我就趴窗口上看呗!')  # 分句
print('
'.join(sents))

切割句子。

 分词

import os
from pyltp import Segmentor
LTP_DATA_DIR='D:Python3.6ltp3.4ltp3.4'
cws_model_path=os.path.join(LTP_DATA_DIR,'cws.model')
segmentor=Segmentor()
segmentor.load(cws_model_path)
words=segmentor.segment('熊高雄你吃饭了吗')
print(type(words))
print('	'.join(words))
segmentor.release()

 来源https://www.jianshu.com/p/f78453f5d1ca

原文地址:https://www.cnblogs.com/zlj843767688/p/12496486.html