| from typing import Tuple |
| from typing import Generator |
|
|
| import datasets |
| from datasets import Value |
|
|
| _DESCRIPTION = """\ |
| ... |
| """ |
|
|
| _URL = "..." |
|
|
|
|
| class LaboASRConfig(datasets.BuilderConfig): |
|
|
| def __init__( |
| self, |
| do_stuff: bool = False, |
| **kwargs, |
| ): |
| super(LaboASRConfig, self).__init__(version=datasets.Version("0.0.2", ""), **kwargs) |
| self.do_stuff = do_stuff |
|
|
|
|
| class LaboASR(datasets.GeneratorBasedBuilder): |
|
|
| CORTI_DATASET_NAME = "labo" |
| DEFAULT_WRITER_BATCH_SIZE = 256 |
| DEFAULT_CONFIG_NAME = "default" |
| BUILDER_CONFIG_CLASS = LaboASRConfig |
|
|
| BUILDER_CONFIGS = [ |
| LaboASRConfig( |
| name="default", |
| description="Default config.", |
| ), |
| LaboASRConfig( |
| name="alternative", |
| description="Alternative config.", |
| ), |
| ] |
|
|
| def _info(self): |
| features = { |
| "transcript": Value("string"), |
| "id": Value("string"), |
| } |
| return datasets.DatasetInfo( |
| description=_DESCRIPTION, |
| features=datasets.Features(features), |
| homepage=_URL, |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| |
| if self.config.name == "default": |
| return [ |
| datasets.SplitGenerator( |
| name=datasets.Split.TRAIN, |
| gen_kwargs={ |
| "paths": ["1", "2", "3", "8", "9", "10"], |
| }, |
| ), |
| datasets.SplitGenerator( |
| name=datasets.Split.VALIDATION, |
| gen_kwargs={ |
| "paths": ["4", "5", "6", "7"], |
| }, |
| ), |
| ] |
| elif self.config.name == "alternative": |
| return [ |
| datasets.SplitGenerator( |
| name=datasets.Split.TRAIN, |
| gen_kwargs={ |
| "paths": ["1", "2", "3", "4"], |
| }, |
| ), |
| datasets.SplitGenerator( |
| name=datasets.Split.VALIDATION, |
| gen_kwargs={ |
| "paths": ["5", "6", "7"], |
| }, |
| ), |
| ] |
|
|
| def _generate_examples( |
| self, |
| paths: list[str], |
| ) -> Generator[Tuple[int, dict], None, None]: |
|
|
| for i, p in enumerate(paths): |
|
|
| |
| example = { |
| "transcript": "Hello, world!", |
| "id": "0000" + p, |
| } |
|
|
| yield i, example |
|
|