refactor(dataset processing): 重构数据集处理流程并添加新功能
This commit is contained in:
@@ -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
|
||||
)
|
||||
Reference in New Issue
Block a user