|
import neologdn |
|
import MeCab |
|
import re |
|
from transformers.models.whisper.english_normalizer import BasicTextNormalizer |
|
|
|
wakati = MeCab.Tagger("-Owakati") |
|
special_characters = '[\,\γ\γ\οΌ\γ\γ\β¦\οΌ\γ»\!\-\;\:\"\β\%\β\β\οΏ½]' |
|
|
|
|
|
def norm_everything(batch): |
|
batch["sentence"] = neologdn.normalize(batch["sentence"]).strip() |
|
batch["sentence"] = normalizer(batch["sentence"]).strip() |
|
batch["sentence"] = wakati.parse(batch["sentence"]).strip() |
|
batch["sentence"] = re.sub(special_characters,'', batch["sentence"]).strip() |
|
return batch |
|
|
|
ds = ds.map(norm_everything) |