import re
import string
def clean_text(s):
"""
This function cleans the text a bit
:param s: string
:return: cleaned string
"""
# split by all whitespaces
s = s.split()
# join tokens by single space
s = " ".join(s)
# remove all punctuations using regex and string module
s = re.sub(f'[{re.escape(string.punctuation)}]', '', s)
return s
相关文章
- 02-13matplotlib.pyplot.text
- 02-13Sublime Text2 快捷键汇总
- 02-13CV学习笔记(十九):文本数据集生成(text_renderer)
- 02-13RocketMq发送消息出现com.alibaba.rocketmq.client.exception.MQBrokerException: CODE: 2 DESC: [TIMEOUT_CLEAN_QUEUE]broker busy, start flow control for a while, period in queue: 201ms, size of queue: 1
- 02-13sublime text3全局设置
- 02-13sublime text 3 扩展插件SideBarEnhancements用法教程
- 02-13简单字符串处理 hdu1062 Text Reverse
- 02-13分享一个Sublime_Text-3211的注册码
- 02-13NX二次开发-设置尺寸的附加尺寸UF_DRF_set_appended_text
- 02-13NX二次开发-UFUN工程图表格注释写入文本内容UF_TABNOT_set_cell_text