python中导入文件进行jieba分词处理,并将结果保存到指定的分词结果文件中。
发布时间
阅读量:
阅读量
以下为具体的代码实现
# -*- encoding=utf-8 -*-
import jieba.analyse
import jieba
import pandas as pd
# 载入自定义词典
jieba.load_userdict('dict.txt')
# 载入自定义停止词
jieba.analyse.set_stop_words('stop_words.txt')
# 去掉中英文状态下的逗号、句号
def clearSen(comment):
comment = comment.strip()
comment = comment.replace('、', '')
comment = comment.replace(',', '。')
comment = comment.replace('《', '。')
comment = comment.replace('》', '。')
comment = comment.replace('~', '')
comment = comment.replace('…', '')
comment = comment.replace('\r', '')
comment =
全部评论 (0)
还没有任何评论哟~
