-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
标点预测 _clean_text()
函数第二个 sub 多余了,因为第一个 sub 已经把所有标点过滤掉了,该函数完全不需要输入 punc_list
测试代码:
import re
def clean_text(text,punc_list):
text = text.lower()
print("text0:",text)
text = re.sub('[^A-Za-z0-9\u4e00-\u9fa5]', '', text)
print("text1:",text)
text = re.sub(f'[{"".join([p for p in punc_list][1:])}]', '',
text)
print("text2:",text)
return text
text = "你好,我是飞桨?的程序员。你好吗!"
punc_list=[',','。','?']
print(clean_text(text,punc_list))
output:
text0: 你好,我是飞桨?的程序员。你好吗!
text1: 你好我是飞桨的程序员你好吗
text2: 你好我是飞桨的程序员你好吗
你好我是飞桨的程序员你好吗
用到的位置:
PaddleSpeech/paddlespeech/cli/text/infer.py
Line 205 in 764fa0a
def _clean_text(self, text): def _clean_text(text, punc_list):
鼓励开发者提交 pr 修改