总结:只有jieba,cutword,baidu lac成功将色盲色弱成功分对,这两个库字典应该是最全的
hanlp[持续更新中]
https://github.com/hankcs/HanLP/blob/doc-zh/plugins/hanlp_demo/hanlp_demo/zh/tok_stl.ipynb
import hanlp
# hanlp.pretrained.tok.ALL # 语种见名称最后一个字段或相应语料库
tok = hanlp.load(hanlp.pretrained.tok.COARSE_ELECTRA_SMALL_ZH)
# coarse和fine模型训练自9970万字的大型综合语料库,覆盖新闻、社交媒体、金融、法律等多个领域,是已知范围内全世界最大的中文分词语料库
# tok.dict_combine = './data/dict.txt'
print(tok(['身高1.60米以上,无色盲色弱具体要求见我校招生章程']))
pkuseg[不再维护了]
https://github.com/lancopku/pkuseg-python
下载最新模型
import pkuseg
c = pkuseg.pkuseg(model_name=r'C:\Users\ymzy\.pkuseg\default_v2') #指定模型路径加载,如果只写模型名称,会报错[Errno 2] No such file or directory: 'default_v2\\unigram_word.txt'
# c = pkuseg.pkuseg(user_dict=dict_path,model_name=r'C:\Users\ymzy\.pkuseg\default_v2') #, postag = True
print(c.cut('身高1.60米以上,无色盲色弱具体要求见我校招生章程'))
jieba[不再维护了]
https://github.com/fxsjy/jieba
HMM中文分词原理
import jieba
# jieba.load_userdict(file_name)
sentence = '身高1.60米以上,无色盲色弱具体要求见我校招生章程'
#jieba分词有三种不同的分词模式:精确模式、全模式和搜索引擎模式:
seg_list = jieba.cut(sentence, cut_all=True) #全模式
print("Full Mode:" + "/".join(seg_list))
seg_list = jieba.cut(sentence, cut_all=False) #精确模式
print("Default Mode:" + "/".join(seg_list))
seg_list = jieba.cut(sentence, HMM=False) #不使用HMM模型
print("/".join(seg_list))
seg_list = jieba.cut(sentence, HMM=True) #使用HMM模型
print("/".join(seg_list))
cutword[202401最新]
https://github.com/liwenju0/cutword
from cutword import Cutter
cutter = Cutter(want_long_word=True)
res = cutter.cutword("身高1.60米以上,无色盲色弱具体要求见我校招生章程")
print(res)
lac【不再维护】
https://github.com/baidu/lac
from LAC import LAC
# 装载分词模型
seg_lac = LAC(mode='seg')
seg_lac.load_customization('./dictionary/dict.txt', sep=None)
texts = [u"身高1.60米以上,无色盲色弱具体要求见我校招生章程"]
seg_result = seg_lac.run(texts)
print(seg_result)