from datasets import load_dataset from googletrans import Translator def main(): translator = Translator() raw_ds = load_dataset('SetFit/amazon_massive_intent_ru-RU') 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='russian').text translations.append(translation) dset = dset.add_column("label_text_ru", translations) dset.to_json(f"{split}.jsonl") if __name__ == "__main__": main()