borgholt commited on
Commit
4d5d675
·
verified ·
1 Parent(s): 333e350

Upload lb_data_test.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. lb_data_test.py +79 -0
lb_data_test.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Tuple
2
+ from typing import Generator
3
+
4
+ import datasets
5
+ from datasets import Value
6
+
7
+ _DESCRIPTION = """\
8
+ ...
9
+ """
10
+
11
+ _URL = "..."
12
+
13
+
14
+ class LaboASRConfig(datasets.BuilderConfig):
15
+
16
+ def __init__(
17
+ self,
18
+ do_stuff: bool = False,
19
+ **kwargs,
20
+ ):
21
+ super(LaboASRConfig, self).__init__(version=datasets.Version("0.0.1", ""), **kwargs)
22
+ self.do_stuff = do_stuff
23
+
24
+
25
+ class LaboASR(datasets.GeneratorBasedBuilder):
26
+
27
+ CORTI_DATASET_NAME = "labo"
28
+ DEFAULT_WRITER_BATCH_SIZE = 256
29
+ DEFAULT_CONFIG_NAME = "default"
30
+ BUILDER_CONFIG_CLASS = LaboASRConfig
31
+
32
+ BUILDER_CONFIGS = [
33
+ LaboASRConfig(
34
+ name="default",
35
+ description="Default config.",
36
+ ),
37
+ ]
38
+
39
+ def _info(self):
40
+ features = {
41
+ "transcript": Value("string"),
42
+ "id": Value("string"),
43
+ }
44
+ return datasets.DatasetInfo(
45
+ description=_DESCRIPTION,
46
+ features=datasets.Features(features),
47
+ homepage=_URL,
48
+ )
49
+
50
+ def _split_generators(self, dl_manager):
51
+ return [
52
+ datasets.SplitGenerator(
53
+ name=datasets.Split.TRAIN,
54
+ gen_kwargs={
55
+ "paths": ["1", "2", "3"],
56
+ },
57
+ ),
58
+ datasets.SplitGenerator(
59
+ name=datasets.Split.VALIDATION,
60
+ gen_kwargs={
61
+ "paths": ["4", "5", "6"],
62
+ },
63
+ ),
64
+ ]
65
+
66
+ def _generate_examples(
67
+ self,
68
+ paths: list[str],
69
+ ) -> Generator[Tuple[int, dict], None, None]:
70
+
71
+ for i, p in enumerate(paths):
72
+
73
+ # Yield example
74
+ example = {
75
+ "transcript": "Hello, world!",
76
+ "id": "0000" + p,
77
+ }
78
+
79
+ yield i, example