refactor(utils): 更新 comprehensive_normalization 函数
This commit is contained in:
+3
-5
@@ -28,11 +28,9 @@ def fetch_folders(root_dir, filter_func=None):
|
|||||||
|
|
||||||
def comprehensive_normalization(text):
|
def comprehensive_normalization(text):
|
||||||
replacements = {
|
replacements = {
|
||||||
'\u2018': "'", '\u2019': "'", '\u0060': "'",
|
"\\[": "$$", "\\]": "$$", "\\(": "$", "\\)": "$",
|
||||||
'\u201C': '"', '\u201D': '"',
|
'\u2018': "'", '\u2019': "'", '\u0060': "'", '\u201C': '"', '\u201D': '"',
|
||||||
'\u2013': '-', '\u2014': '--', '\u2212': '-',
|
'\u2013': '-', '\u2014': '--', '\u2212': '-', '\u00A0': ' ', '\u2026': '...'
|
||||||
'\u00A0': ' ',
|
|
||||||
'\u2026': '...'
|
|
||||||
}
|
}
|
||||||
pattern = re.compile('|'.join(re.escape(k) for k in replacements))
|
pattern = re.compile('|'.join(re.escape(k) for k in replacements))
|
||||||
return pattern.sub(lambda m: replacements[m.group()], text)
|
return pattern.sub(lambda m: replacements[m.group()], text)
|
||||||
|
|||||||
Reference in New Issue
Block a user