您的位置:首页 > 编程语言 > Python开发

Python 结巴分词停止词及自定义词库

2017-08-28 17:50 567 查看
# 自定义词库

f='g:/'+I[i]+'.txt'

jieba.load_userdict(f)

# 停止词

stopwords='G:/g/data/word/chinese_stopword.txt'

stop_single_words=[]  

with open(stopwords,'r') as f:  

    for line in f:  

        content=line.strip()  

        stop_single_words.append(content.decode('utf8'))  

# 分词时去除停止词

word_cut=table_x.ABSTRACT_ZH[[j,k]].apply(lambda s: [i for i in list(jieba.cut(s)) if i not in stop_single_words])

                        

                    
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python jieba