去除字符串中的数字和标点符号和分词

jieba分词

参考博客:https://www.cnblogs.com/jiayongji/p/7119065.html

对scv的一列数据进行分词:

t4 = ' '.join(jieba.cut_for_search(t3)) # 进行分词
t4 = t4.strip()# 去除分词结果前后的空格、\n等字符

去除字符串中的数字和标点符号

remove_digits = str.maketrans('', '', digits) # 去除数字
t1 = t1.translate(remove_digits)
trantab = str.maketrans({key: None for key in string.punctuation}) # 去除标点符号
t2 = t1.translate(trantab)

猜你喜欢

转载自www.cnblogs.com/zhoulonghai/p/12912861.html
今日推荐