taiqihe commited on
Commit
13c0897
·
verified ·
1 Parent(s): 8e09a30

initialize dataset

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
.gitattributes CHANGED
@@ -52,3 +52,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
 
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
55
+ *.json filter=lfs diff=lfs merge=lfs -text
56
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
cocoon-gloss.py ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2023 The HuggingFace Datasets Authors and the current dataset script contributor.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """Cocoon datasets that contrain interlinear gloss"""
16
+
17
+ import os
18
+ import json
19
+
20
+ import datasets
21
+
22
+
23
+ _ALL_LANGS = [
24
+ "tvk",
25
+ "kke",
26
+ "ers",
27
+ "sxg",
28
+ "svm",
29
+ "kkt",
30
+ "nee",
31
+ "bej",
32
+ "say",
33
+ "ady",
34
+ "kab",
35
+ "ixc",
36
+ "rmn",
37
+ "swb",
38
+ "nxq",
39
+ "nru",
40
+ ]
41
+ _ALL_CONFIGS = [*_ALL_LANGS, "all"]
42
+
43
+ _DESCRIPTION = ""
44
+ _CITATION = ""
45
+ _HOMEPAGE_URL = ""
46
+
47
+ _BASE_PATH = "data/{langs}/"
48
+ _DATA_URL = _BASE_PATH + "audio/{split}.tar.gz"
49
+ _META_URL = _BASE_PATH + "{split}.json"
50
+
51
+
52
+ class CocoonConfig(datasets.BuilderConfig):
53
+ def __init__(self, name, **kwargs):
54
+ super().__init__(name=name, version=datasets.Version("0.0.0", ""), **kwargs)
55
+
56
+
57
+ class Cocoon(datasets.GeneratorBasedBuilder):
58
+ DEFAULT_WRITER_BATCH_SIZE = 1000
59
+ BUILDER_CONFIGS = [CocoonConfig(name) for name in _ALL_CONFIGS]
60
+
61
+ def _info(self):
62
+ task_templates = None
63
+ langs = _ALL_CONFIGS
64
+ features = datasets.Features(
65
+ {
66
+ "id": datasets.Value("string"),
67
+ "audio": datasets.features.Audio(sampling_rate=16_000),
68
+ "transcription": datasets.Value("string"),
69
+ "language": datasets.Value("string"),
70
+ "speaker": datasets.Value("string"),
71
+ "surface": datasets.Value("string"),
72
+ "underlying": datasets.Value("string"),
73
+ "gloss": datasets.Value("string"),
74
+ "translation": datasets.Value("string"),
75
+ "url": datasets.Value("string"),
76
+ }
77
+ )
78
+
79
+ return datasets.DatasetInfo(
80
+ description=_DESCRIPTION,
81
+ features=features,
82
+ supervised_keys=("audio", "transcription"),
83
+ homepage=_HOMEPAGE_URL,
84
+ citation=_CITATION,
85
+ task_templates=None,
86
+ )
87
+
88
+ # Fleurs
89
+ def _split_generators(self, dl_manager):
90
+ splits = ["train", "dev", "test"]
91
+
92
+ # metadata_path = dl_manager.download_and_extract(_METADATA_URL)
93
+
94
+ if self.config.name == "all":
95
+ data_urls = {
96
+ split: [
97
+ _DATA_URL.format(langs=langs, split=split) for langs in _ALL_LANGS
98
+ ]
99
+ for split in splits
100
+ }
101
+ meta_urls = {
102
+ split: [
103
+ _META_URL.format(langs=langs, split=split) for langs in _ALL_LANGS
104
+ ]
105
+ for split in splits
106
+ }
107
+ else:
108
+ data_urls = {
109
+ split: [_DATA_URL.format(langs=self.config.name, split=split)]
110
+ for split in splits
111
+ }
112
+ meta_urls = {
113
+ split: [_META_URL.format(langs=self.config.name, split=split)]
114
+ for split in splits
115
+ }
116
+
117
+ archive_paths = dl_manager.download(data_urls)
118
+ local_extracted_archives = (
119
+ dl_manager.extract(archive_paths) if not dl_manager.is_streaming else {}
120
+ )
121
+ archive_iters = {
122
+ split: [dl_manager.iter_archive(path) for path in paths]
123
+ for split, paths in archive_paths.items()
124
+ }
125
+
126
+ meta_paths = dl_manager.download(meta_urls)
127
+
128
+ return [
129
+ datasets.SplitGenerator(
130
+ name=datasets.Split.TRAIN,
131
+ gen_kwargs={
132
+ "local_extracted_archives": local_extracted_archives.get(
133
+ "train", [None] * len(meta_paths.get("train"))
134
+ ),
135
+ "archive_iters": archive_iters.get("train"),
136
+ "text_paths": meta_paths.get("train"),
137
+ },
138
+ ),
139
+ datasets.SplitGenerator(
140
+ name=datasets.Split.VALIDATION,
141
+ gen_kwargs={
142
+ "local_extracted_archives": local_extracted_archives.get(
143
+ "dev", [None] * len(meta_paths.get("dev"))
144
+ ),
145
+ "archive_iters": archive_iters.get("dev"),
146
+ "text_paths": meta_paths.get("dev"),
147
+ },
148
+ ),
149
+ datasets.SplitGenerator(
150
+ name=datasets.Split.TEST,
151
+ gen_kwargs={
152
+ "local_extracted_archives": local_extracted_archives.get(
153
+ "test", [None] * len(meta_paths.get("test"))
154
+ ),
155
+ "archive_iters": archive_iters.get("test"),
156
+ "text_paths": meta_paths.get("test"),
157
+ },
158
+ ),
159
+ ]
160
+
161
+ def _generate_examples(self, local_extracted_archives, archive_iters, text_paths):
162
+ assert len(local_extracted_archives) == len(archive_iters) == len(text_paths)
163
+ key = 0
164
+
165
+ if self.config.name == "all":
166
+ langs = _ALL_LANGS
167
+ else:
168
+ langs = [self.config.name]
169
+
170
+ for archive, text_path, local_extracted_path, lang in zip(
171
+ archive_iters, text_paths, local_extracted_archives, langs
172
+ ):
173
+ with open(text_path, encoding="utf-8") as fin:
174
+ data = json.load(fin)
175
+
176
+ for audio_path, audio_file in archive:
177
+ audio_filename = audio_path.split("/")[-1]
178
+ if audio_filename not in data:
179
+ continue
180
+
181
+ result = data[audio_filename]
182
+ extracted_audio_path = (
183
+ os.path.join(local_extracted_path, audio_filename)
184
+ if local_extracted_path is not None
185
+ else None
186
+ )
187
+ result["language"] = lang
188
+ result["audio"] = {"path": audio_path, "bytes": audio_file.read()}
189
+ yield key, result
190
+ key += 1
data/ady/audio/dev.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b81ff4b695683453dc576e1f3c6e4578d83f1373b43e0e799dd68558c196440
3
+ size 2915965
data/ady/audio/test.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c7eb1e72fc592b598fbe4a22264ca7a7e79de1e0877a6f944dbc6772e13f424
3
+ size 4315722
data/ady/audio/train.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28580baf52dea56db04095c5a14669bd8b9119752aaea8a1b0d48d91dd70ad95
3
+ size 64405223
data/ady/dev.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c7bfe853b1239f0a841f9b89346a90b35c07921f1b22fdd457b416c1f33aeece
3
+ size 14401
data/ady/test.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c07d654b67f4a04f48ba9aed7697a354fbda7715f1fad2a957d55479dd2e30b
3
+ size 18512
data/ady/train.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e7ad64b7d67e39f977e1c590aec57935c16fe051d4ed4aefe279ac5ff504562
3
+ size 301028
data/bej/audio/dev.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7cc45d6fb17c0675a6d59c156eb13c3e79895e60a79873ac38d401369107586a
3
+ size 6127893
data/bej/audio/test.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:62a7328d4c261134ec53370149d3d452571c5c77c236db547f9a10ff1b1ffd89
3
+ size 5632884
data/bej/audio/train.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9472edb4fc388b32ad044d5ddf664b0377ca12fd79c1db4e5f424534ef0d8195
3
+ size 100959452
data/bej/dev.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c2586b6d125fc54160f44b2b6a533741bf176f87a742e27f06fe8b60eff1b081
3
+ size 89443
data/bej/test.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c653940804931d2d29c85abd7dcbc4e0a670a3d55b5e20b72daee09f4d991bf
3
+ size 89746
data/bej/train.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1deb878c654501491ecb9b63f4947cf2ce314642d71da079454d0c0d3f26f133
3
+ size 1608943
data/ers/audio/dev.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4b28352b9068de504576471cbd705fe5d042687071816910be6ddecf915374f
3
+ size 18472654
data/ers/audio/test.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e5b98694c52f47f7e89af450202c034ad4c34371baa7e63841783818553fcc6
3
+ size 20038153
data/ers/audio/train.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:72dbde7c19dc19b4605417299729d0a07978b92226c33266ada709db5278a22c
3
+ size 366013815
data/ers/dev.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b8ebd6018f331a0648d02b916e0756504e31f77d9a3eb0c74879ee39cd50867
3
+ size 129693
data/ers/test.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d0ef17fd33e0d401be366253c81af80a839c8de8b8b5855cf8a46159e7e75e5c
3
+ size 136107
data/ers/train.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:346f162269bed76193a74c4441a193522599318e4d6e0c56da29f0bb20992f90
3
+ size 2532854
data/ixc/audio/dev.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b2bf027b552d2030bf397bf5f00b08a8e584418c4abf002e6cab8d54450379e8
3
+ size 2036704
data/ixc/audio/test.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:203fb7df0dd767abd0526ce74b9393220ef6edc09baf9f7dee676c3bb44b8be1
3
+ size 2014508
data/ixc/audio/train.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:14a110432173a2605077e365b6c0960d159cfa52d219b2f32b63f8bfd085a523
3
+ size 39410827
data/ixc/dev.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:405b279080c33d2c2b8012e25be3b6a3cc60303ca26b071545625769825bd417
3
+ size 23004
data/ixc/test.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:693573bd6400a55aadf7e4b88f7a5dcf2364732eaae77f3294cdaebecc87cadc
3
+ size 22193
data/ixc/train.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:86480bc5c8f462e46c938d42fe7c38d8389272178dc114c98fefea4d18be6e00
3
+ size 425895
data/kab/audio/dev.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e89a89a9490e7db5392436204d3f4c15f2713d0bf5b59b3e388ccafcbaf360b3
3
+ size 2725593
data/kab/audio/test.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc9eeb2ce87c79bb019cfd6a501fcdb1499e843e2fa35896f1e537389b732ed
3
+ size 2453082
data/kab/audio/train.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:258f6f2e41df54148fcb65ce03b311353dbcaeaea610d525f57d82266a53310d
3
+ size 46890577
data/kab/dev.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e79d5bb1f7784aa297be2ea33f2566baba801e18d136a4ff9afac901bbc91fbe
3
+ size 20287
data/kab/test.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ee4a5c61e01e69aea3df767a475ccb96fda937625e641ad18f2563456bd338f
3
+ size 18574
data/kab/train.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2b213fae0902d6cf04d509d6ae0714465f55f8821ccf8d6ada9d7d74bfe00dc
3
+ size 366475
data/kke/audio/dev.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ea0c6af56d18d58c73f2045399b3d3f41f14cb989f78e8ebf9b1179e78f8d57
3
+ size 22242189
data/kke/audio/test.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:55c9cb6b200da870dcfa0967fa257e9121368224c537fcb01f856dee7c70cbde
3
+ size 20749034
data/kke/audio/train.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3feb7d9287fb6cac91b455e488a5dfee5185ac1589ceafeee5209d5ed6900f2f
3
+ size 377013366
data/kke/dev.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4a836788169def2146cd509c13dba69f686cace6b7e50384d5d976a083ca0a4
3
+ size 152165
data/kke/test.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d15be3e42819f9450abe2848aa24b597fb74241a681db55051baa6dd3cc3def1
3
+ size 146867
data/kke/train.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:efb8fecfb10b36b5e85ccf062b929b541dde72e4d02fb29f29841d0df3779ead
3
+ size 2735018
data/kkt/audio/dev.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e14acef88a8ba5e921533e55b1167a22f2ffb8d77bfdbaf3946cfd9146aff2f9
3
+ size 8047200
data/kkt/audio/test.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b5fbb429f18f77c43952957cdfdaa7d512567b42b1f0772d7b97be8733eb93f8
3
+ size 8289102
data/kkt/audio/train.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:095d26bcfbde93f477503b22843bcbe1e494e66c07f747c3eacefebe8a7dbea9
3
+ size 151335675
data/kkt/dev.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:90ecba6e250cbe71530d206e5bff77001dd7377d147fb6ea6b42ec66014826a8
3
+ size 30768
data/kkt/test.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d42f7f635af2a8a5bfb371e0a382028206e2b569c127c48a8930f939d1e3e1c9
3
+ size 29380
data/kkt/train.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4eb64d641d3e00b6289d0b87bf88f0a2263c424bc830a86f5c83e01612c37d28
3
+ size 538416
data/nee/audio/dev.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2af87f96bd0cd6ca02a3923198374d911daaaa888970fe0d0ee36443eb7019d6
3
+ size 7666672
data/nee/audio/test.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ed144ed25e3349aacb652a6b9fed9e8f43af477b998172bcd936209b8a9e8f1
3
+ size 7369529
data/nee/audio/train.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a3adcb3277af063f16a49652067223bdaa3cc2624768dfd515b69716f7f9c7d
3
+ size 131937777
data/nee/dev.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a12c8fd9a068f90171b002f0da6da3637e50239c9940f87ca47c7889afcb906e
3
+ size 36182
data/nee/test.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6adfff8f3677c235436075f541a55456973b11b21358c3cc662ef7fa730e366d
3
+ size 33181
data/nee/train.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f02e4a5aa72e41ebcef3c3a88392c6562acad9b5a0005dc628f769cfb6d1d813
3
+ size 622602