具体代码如下
# -*- 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 = comment.replace('\t', ' ')
comment = comment.replace('\f', ' ')
comment = comment.replace('/', '')
comment = comment.replace('、', ' ')
comment = comment.re