File size: 2,580 Bytes
4d5d675 5381182 4d5d675 6810b70 5381182 6810b70 4d5d675 6810b70 5381182 6810b70 4d5d675 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
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):
# Yield example
example = {
"transcript": "Hello, world!",
"id": "0000" + p,
}
yield i, example
|