NLP去特殊字符

在自然语言处理中,我们有时对文本进行处理,需要去除一些特殊符号,保留中文,这是在预处理过程中常用到的。分享给你,希望对你有帮助!

1 import re
2 def delete_sysbol(line):
3     cop = re.sub('[^\u4e00-\u9fa5^]', '', line)
4     print(cop)
5     return cop
6 
7 delete_sysbol('woa oi^*&%&(3 na我是中国人*(&*(美好')

 

posted @ 2019-02-28 16:22  今夜无风  阅读(727)  评论(0编辑  收藏  举报