|
|
import datasets |
|
|
|
|
|
_LANGUAGE_PAIRS = { |
|
|
"en_de": "data/en_de.parquet", |
|
|
"en_es": "data/en_es.parquet", |
|
|
"en_fr": "data/en_fr.parquet", |
|
|
"en_it": "data/en_it.parquet", |
|
|
"en_ko": "data/en_ko.parquet", |
|
|
"en_nl": "data/en_nl.parquet", |
|
|
"en_pt": "data/en_pt.parquet", |
|
|
"en_ru": "data/en_ru.parquet", |
|
|
"en_zh": "data/en_zh.parquet", |
|
|
} |
|
|
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
|
|
|
|
|
class Spite(datasets.GeneratorBasedBuilder): |
|
|
VERSION = VERSION |
|
|
|
|
|
BUILDER_CONFIGS = [ |
|
|
datasets.BuilderConfig( |
|
|
name=lang_pair, |
|
|
version=VERSION, |
|
|
description=f"Training data for language pair: {lang_pair}", |
|
|
) |
|
|
for lang_pair in _LANGUAGE_PAIRS |
|
|
] |
|
|
|
|
|
DEFAULT_CONFIG_NAME = "en_de" |
|
|
|
|
|
def _info(self): |
|
|
return datasets.DatasetInfo( |
|
|
description="Pseudolabeled speech translation dataset", |
|
|
features=datasets.Features({ |
|
|
"src": datasets.Value("string"), |
|
|
"mt": datasets.Value("string"), |
|
|
'cometqe_22': datasets.Value("float64"), |
|
|
'xcomet_xl': datasets.Value("float64"), |
|
|
'blaser2_src': datasets.Value("float64"), |
|
|
'audio_length': datasets.Value("float64"), |
|
|
"example_id": datasets.Value("string"), |
|
|
"index": datasets.Value("int64") |
|
|
|
|
|
}), |
|
|
supervised_keys=None, |
|
|
) |
|
|
|
|
|
def _split_generators(self, dl_manager): |
|
|
parquet_path = dl_manager.download(_LANGUAGE_PAIRS[self.config.name]) |
|
|
|
|
|
return [ |
|
|
datasets.SplitGenerator( |
|
|
name=datasets.Split.TRAIN, |
|
|
gen_kwargs={"filepath": parquet_path}, |
|
|
) |
|
|
] |
|
|
|
|
|
def _generate_examples(self, filepath): |
|
|
import pyarrow.parquet as pq |
|
|
|
|
|
table = pq.read_table(filepath) |
|
|
for idx, row in enumerate(table.to_pylist()): |
|
|
yield idx, row |
|
|
|