安装lac
python -m pip install LAC
简单脚本demo,输出词频权重大于1以及分词结果大于1个关键词的结果, rank_result[2][x],rank_result[0][x]就这两个可以自己修改
from LAC import LAC lac = LAC(mode='rank') def fenci_word(word): rank_result = lac.run(word) fenci = [] rank = [] #print(rank_result) for x in range(0,len(rank_result[0])): if rank_result[2][x] > 1: if len(rank_result[0][x]) > 1 : #print(rank_result[0][x],rank_result[2][x]) # print(rank_result[2][x]) fenci.append(rank_result[0][x]) return fenci if __name__ == '__main__': with open('word.txt',encoding='utf8') as w_list: for w in w_list: w = w.strip() fenci = fenci_word(w) print(','.join(fenci)) # print(fenci_word('应届生简历表格行政人事通用简约简历'))