File size: 498 Bytes
960bf13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from datasets import load_dataset
import re
ds = load_dataset("test.csv")

def prepro(datapoint):
    pattern = "\s([0-9]\.){0,1}[0-9]{0,3}(?=\Z)"
    text = datapoint["Embedded_text"].replace("\n", " ")
    for i in range(3):
        text = re.sub(pattern, "", text)
    text = text.replace("Diesen Thread anzeigen", "").replace("  ", " ").replace("  ", " ")
    datapoint["text"] = text
    del datapoint["Embedded_text"]
    return datapoint
ds_f = ds.map(prepro)
ds_f.to_parquet("test.parquet")