amazon_massive_intent_es-ES / add_translation.py
luketheduke's picture
Upload add_translation.py
93dfb48
raw
history blame contribute delete
770 Bytes
from datasets import load_dataset
from googletrans import Translator
def main():
translator = Translator()
raw_ds = load_dataset('SetFit/amazon_massive_intent_es-ES')
for split, dset in raw_ds.items():
label_text = dset['label_text']
translations = []
progress = 0
for text in label_text:
progress+=1
if progress%1000 == 0:
print(progress)
print(translation)
text = text.replace("_", " ")
translation = translator.translate(text, dest='spanish').text
translations.append(translation)
dset = dset.add_column("label_text_es", translations)
dset.to_json(f"{split}.jsonl")
if __name__ == "__main__":
main()