去掉大模型输出中的特殊字符

This commit is contained in:
谢博 2025-02-17 20:12:55 +08:00
parent 70e80418df
commit 1269404b3f

View file

@ -67,8 +67,6 @@ def remove_special_symbols(text):
""" 去除大模型输出内容中的特殊字符 """ """ 去除大模型输出内容中的特殊字符 """
# 用正则匹配所有非字母、非数字、非空白字符 # 用正则匹配所有非字母、非数字、非空白字符
cleaned = re.sub(r'[^\w\s]', '', text, flags=re.UNICODE) cleaned = re.sub(r'[^\w\s]', '', text, flags=re.UNICODE)
# 去除下划线(如果不希望保留)
cleaned = cleaned.replace('_', '')
return cleaned return cleaned
def get_string_no_punctuation_or_emoji(s): def get_string_no_punctuation_or_emoji(s):