import string
class Preprocessor:
def __init__(self):
pass
@staticmethod
def remove_punctuation(content: str, remove_blank=True, lower=True):
"""
把文本里的符号去除 以及空格
:param content:
:param remove_blank: default True ,去除空格
:param lower: default True ,小写
:return:
"""
# 将空格也去除
punctuation = string.punctuation + ' ' if remove_blank else string.punctuation
content = content.translate(str.maketrans("", "", punctuation))
content = content.lower() if lower else content
return content
去除字符串中的符号
最新推荐文章于 2024-06-13 09:50:09 发布