Datasets:
Khushmeet Singh commited on
Commit ·
a4f2eab
1
Parent(s): 3c40130
Fix WMT dataset loading issue and docs update (Re-opened) (#4554)
Browse files* Fix WMT dataset loading issue and docs update
* update wmt datasets readme files
* Change WMT dataset description in wmt_utils.py files
Commit from https://github.com/huggingface/datasets/commit/fedf891a08bfc77041d575fad6c26091bc0fce52
Files changed (2)
- README.md+17-8
- wmt_utils.py+22-18
45 unmodified lines4647484950515253545556575859606162636465666745 unmodified lines### Dataset SummaryTranslate dataset based on the data from statmt.org.Versions exists for the different years using a combination of multiple datasources. The base `wmt_translate` allows you to create your own config to chooseyour own data/language pair by creating a custom `datasets.translate.wmt.WmtConfig`.```config = datasets.wmt.WmtConfig(version="0.0.1",language_pair=("fr", "de"),subsets={datasets.Split.TRAIN: ["commoncrawl_frde"],datasets.Split.VALIDATION: ["euelections_dev2019"],},)builder = datasets.builder("wmt_translate", config=config)```### Supported Tasks and Leaderboards45 unmodified lines4647484950515253545556575859606162636465666768697071727374757645 unmodified lines### Dataset SummaryTranslation dataset based on the data from statmt.org.Versions exist for different years using a combination of datasources. The base `wmt` allows you to create a custom dataset by choosingyour own data/language pair. This can be done as follows:```pythonfrom datasets import inspect_dataset, load_dataset_builderinspect_dataset("wmt15", "path/to/scripts")builder = load_dataset_builder("path/to/scripts/wmt_utils.py",language_pair=("fr", "de"),subsets={datasets.Split.TRAIN: ["commoncrawl_frde"],datasets.Split.VALIDATION: ["euelections_dev2019"],},)# Standard versionbuilder.download_and_prepare()ds = builder.as_dataset()# Streamable versionds = builder.as_streaming_dataset()```### Supported Tasks and Leaderboards
24 unmodified lines252627282930312 unmodified lines34353637383940414243444546474849505152535455606 unmodified lines6626636646656666676686696706716726736746756766776786796806813 unmodified lines68568668768868969069124 unmodified linesimport osimport reimport xml.etree.cElementTree as ElementTreefrom abc import ABC, abstractmethodimport datasets2 unmodified lines_DESCRIPTION = """\Translate dataset based on the data from statmt.org.Versions exists for the different years using a combination of multiple datasources. The base `wmt_translate` allows you to create your own config to chooseyour own data/language pair by creating a custom `datasets.translate.wmt.WmtConfig`.```config = datasets.wmt.WmtConfig(version="0.0.1",language_pair=("fr", "de"),subsets={datasets.Split.TRAIN: ["commoncrawl_frde"],datasets.Split.VALIDATION: ["euelections_dev2019"],},)builder = datasets.builder("wmt_translate", config=config)```"""606 unmodified lines# +++++++++++++++++++++class Wmt(ABC, datasets.GeneratorBasedBuilder):"""WMT translation dataset."""def __init__(self, *args, **kwargs):if type(self) == Wmt and "config" not in kwargs: # pylint: disable=unidiomatic-typecheckraise ValueError("The raw `wmt_translate` can only be instantiated with the config ""kwargs. You may want to use one of the `wmtYY_translate` ""implementation instead to get the WMT dataset for a specific year.")super(Wmt, self).__init__(*args, **kwargs)@property@abstractmethoddef _subsets(self):"""Subsets that make up each split of the dataset."""raise NotImplementedError("This is a abstract method")3 unmodified lines"""Subsets that make up each split of the dataset for the language pair."""source, target = self.config.language_pairfiltered_subsets = {}for split, ss_names in self._subsets.items():filtered_subsets[split] = []for ss_name in ss_names:dataset = DATASET_MAP[ss_name]24 unmodified lines2526272829302 unmodified lines33343536373839404142434445464748495051525354555657585960616263606 unmodified lines6706716726736746756766776786796806816826836843 unmodified lines68868969069169269369469524 unmodified linesimport osimport reimport xml.etree.cElementTree as ElementTreeimport datasets2 unmodified lines_DESCRIPTION = """\Translation dataset based on the data from statmt.org.Versions exist for different years using a combination of datasources. The base `wmt` allows you to create a custom dataset by choosingyour own data/language pair. This can be done as follows:```pythonfrom datasets import inspect_dataset, load_dataset_builderinspect_dataset("wmt15", "path/to/scripts")builder = load_dataset_builder("path/to/scripts/wmt_utils.py",language_pair=("fr", "de"),subsets={datasets.Split.TRAIN: ["commoncrawl_frde"],datasets.Split.VALIDATION: ["euelections_dev2019"],},)# Standard versionbuilder.download_and_prepare()ds = builder.as_dataset()# Streamable versionds = builder.as_streaming_dataset()```"""606 unmodified lines# +++++++++++++++++++++class Wmt(datasets.GeneratorBasedBuilder):"""WMT translation dataset."""BUILDER_CONFIG_CLASS = WmtConfigdef __init__(self, *args, **kwargs):super(Wmt, self).__init__(*args, **kwargs)@propertydef _subsets(self):"""Subsets that make up each split of the dataset."""raise NotImplementedError("This is a abstract method")3 unmodified lines"""Subsets that make up each split of the dataset for the language pair."""source, target = self.config.language_pairfiltered_subsets = {}subsets = self._subsets if self.config.subsets is None else self.config.subsetsfor split, ss_names in subsets.items():filtered_subsets[split] = []for ss_name in ss_names:dataset = DATASET_MAP[ss_name]
README.md+17-8
wmt_utils.py+22-18