refactor(dataset processing): 重构数据集处理流程并添加新功能

This commit is contained in:
2025-07-14 10:57:23 +08:00
parent 7591a231df
commit d8643d11dd
3 changed files with 22 additions and 14 deletions
-13
View File
@@ -1,16 +1,4 @@
from utils import process_dataset
import re
def comprehensive_normalization(text):
replacements = {
'\u2018': "'", '\u2019': "'", '\u0060': "'",
'\u201C': '"', '\u201D': '"',
'\u2013': '-', '\u2014': '--', '\u2212': '-',
'\u00A0': ' ',
'\u2026': '...'
}
pattern = re.compile('|'.join(re.escape(k) for k in replacements))
return pattern.sub(lambda m: replacements[m.group()], text)
if __name__ == "__main__":
@@ -18,5 +6,4 @@ if __name__ == "__main__":
dataset_name="HuggingFaceFW/fineweb",
output_subdir="english-fineweb",
dataset_config="sample-10BT",
normalization_func=comprehensive_normalization
)