| """MTet dataset.""" | |
| import json | |
| import datasets | |
| _CITATION = """\ | |
| @article{mTet2022, | |
| author = {Chinh Ngo, Hieu Tran, Long Phan, Trieu H. Trinh, Hieu Nguyen, Minh Nguyen, Minh-Thang Luong}, | |
| title = {MTet: Multi-domain Translation for English and Vietnamese}, | |
| journal = {https://github.com/vietai/mTet}, | |
| year = {2022}, | |
| } | |
| """ | |
| _DESCRIPTION = """\ | |
| MTet (Multi-domain Translation for English-Vietnamese) dataset contains roughly 4.2 million English-Vietnamese pairs of | |
| texts, ranging across multiple different domains such as medical publications, religious texts, engineering articles, | |
| literature, news, and poems. | |
| This dataset extends our previous SAT (Style Augmented Translation) dataset (v1.0) by adding more high-quality | |
| English-Vietnamese sentence pairs on various domains. | |
| """ | |
| _HOMEPAGE = "https://github.com/vietai/mTet" | |
| _LICENSE = "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)" | |
| _URLS = { | |
| "en": "https://storage.googleapis.com/vietai_public/best_vi_translation/v2/train.en", | |
| "vi": "https://storage.googleapis.com/vietai_public/best_vi_translation/v2/train.vi", | |
| } | |
| class Mtet(datasets.GeneratorBasedBuilder): | |
| """MTet dataset.""" | |
| VERSION = datasets.Version("1.0.0") | |
| def _info(self): | |
| return datasets.DatasetInfo( | |
| description=_DESCRIPTION, | |
| features=datasets.Features({"translation": datasets.features.Translation(languages=["en", "vi"])}), | |
| homepage=_HOMEPAGE, | |
| license=_LICENSE, | |
| citation=_CITATION, | |
| ) | |
| def _split_generators(self, dl_manager): | |
| data_paths = dl_manager.download(_URLS) | |
| return [ | |
| datasets.SplitGenerator( | |
| name=datasets.Split.TRAIN, | |
| gen_kwargs={ | |
| "data_paths": data_paths, | |
| }, | |
| ), | |
| ] | |
| def _generate_examples(self, data_paths): | |
| with open(data_paths["en"], encoding="utf-8") as f_en, open(data_paths["vi"], encoding="utf-8") as f_vi: | |
| for key, (sentence_en, sentence_vi) in enumerate(zip(f_en, f_vi)): | |
| yield key, {"translation": {"en": sentence_en.strip(), "vi": sentence_vi.strip()}} | |