alvp commited on
Commit
0b26238
1 Parent(s): cc69ea9

Update stanzas.py

Browse files
Files changed (1) hide show
  1. stanzas.py +28 -171
stanzas.py CHANGED
@@ -12,7 +12,7 @@
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
- """Multilingual Bibles"""
16
  import csv
17
 
18
  import datasets
@@ -29,184 +29,49 @@ _CITATION = """
29
  """
30
 
31
  _DESCRIPTION = """\
32
- Multilingual Bibles
33
  """
34
 
35
 
36
  _HOMEPAGE = "https://github.com/versae/bibles/"
37
 
38
- BIBLES_BASE_URI = "https://huggingface.co/datasets/versae/bibles/resolve/main"
39
- BIBLES = {
40
- "validation": lambda config: f"{BIBLES_BASE_URI}/{config}_validation.csv",
41
- "test": lambda config: f"{BIBLES_BASE_URI}/{config}_test.csv",
42
- "train": lambda config: f"{BIBLES_BASE_URI}/{config}_train.csv"
43
  }
44
 
45
 
46
- class BiblesConfig(datasets.BuilderConfig):
47
  """BuilderConfig for NorNE."""
48
 
49
  def __init__(self, **kwargs):
50
- """BuilderConfig for Bibles.
51
  Args:
52
  **kwargs: keyword arguments forwarded to super.
53
  """
54
- super(BiblesConfig, self).__init__(**kwargs)
55
 
56
 
57
- class Bibles(datasets.GeneratorBasedBuilder):
58
- """Bibles"""
59
 
60
- BUILDER_CONFIGS = [
61
- BiblesConfig(name="testament", version=datasets.Version("1.0.0"), description="Bibles testament dataset (full set)"),
62
- BiblesConfig(name="genre", version=datasets.Version("1.0.0"), description="Bibles genre dataset (full set)"),
63
- BiblesConfig(name="division", version=datasets.Version("1.0.0"), description="Bibles division dataset (full set)"),
64
- ]
65
 
66
  def _info(self):
67
- if self.config.name == "division":
68
- labels = [
69
- 'Gospel',
70
- 'Historical',
71
- 'Letters',
72
- 'Pentateuch',
73
- 'Prophetic',
74
- 'Revelation',
75
- 'Wisdom'
76
- ]
77
- languages = [
78
- 'ALB',
79
- 'ARA',
80
- 'AZB',
81
- 'BEL',
82
- 'BUL',
83
- 'CEB',
84
- 'CHI',
85
- 'CZE',
86
- 'DAN',
87
- 'ENG',
88
- 'ESP',
89
- 'FIN',
90
- 'FRE',
91
- 'GER',
92
- 'GRC',
93
- 'HAT',
94
- 'HEB',
95
- 'HIN',
96
- 'HUN',
97
- 'ITA',
98
- 'KOR',
99
- 'LAT',
100
- 'MAR',
101
- 'NL_',
102
- 'NOR',
103
- 'POR',
104
- 'RUM',
105
- 'RUS',
106
- 'SCR',
107
- 'SPA',
108
- 'SWE',
109
- 'TAM',
110
- 'TGL',
111
- 'THA',
112
- 'TUR',
113
- 'VIE',
114
- 'XKL',
115
- ]
116
- elif self.config.name == "genre":
117
- labels = [
118
- 'apocalyptic',
119
- 'gospel',
120
- 'historical',
121
- 'law',
122
- 'letter',
123
- 'lyric',
124
- 'prophecy',
125
- 'wisdom'
126
- ]
127
- languages = [
128
- 'ALB',
129
- 'ARA',
130
- 'AZB',
131
- 'BEL',
132
- 'BUL',
133
- 'CEB',
134
- 'CHI',
135
- 'CZE',
136
- 'DAN',
137
- 'ENG',
138
- 'ESP',
139
- 'FIN',
140
- 'FRE',
141
- 'GER',
142
- 'GRC',
143
- 'HAT',
144
- 'HEB',
145
- 'HIN',
146
- 'HUN',
147
- 'ITA',
148
- 'KOR',
149
- 'LAT',
150
- 'MAR',
151
- 'NL_',
152
- 'NOR',
153
- 'POR',
154
- 'RUM',
155
- 'RUS',
156
- 'SCR',
157
- 'SPA',
158
- 'SWE',
159
- 'TAM',
160
- 'TGL',
161
- 'THA',
162
- 'TUR',
163
- 'VIE',
164
- 'XKL',
165
- ]
166
- else: # self.config.name == "testament":
167
- labels = ["new", "old"]
168
- languages = [
169
- 'ALB',
170
- 'ARA',
171
- 'AZB',
172
- 'BEL',
173
- 'BUL',
174
- 'CEB',
175
- 'CHA',
176
- 'CHI',
177
- 'CZE',
178
- 'DAN',
179
- 'ENG',
180
- 'ESP',
181
- 'FIN',
182
- 'FRE',
183
- 'GER',
184
- 'GRC',
185
- 'HAT',
186
- 'HEB',
187
- 'HIN',
188
- 'HUN',
189
- 'ITA',
190
- 'KOR',
191
- 'LAT',
192
- 'MAR',
193
- 'NDS',
194
- 'NL_',
195
- 'NOR',
196
- 'PON',
197
- 'POR',
198
- 'RUM',
199
- 'RUS',
200
- 'SCR',
201
- 'SPA',
202
- 'SWE',
203
- 'TAM',
204
- 'TGL',
205
- 'THA',
206
- 'TUR',
207
- 'VIE',
208
- 'XKL',
209
- ]
210
  self.labels = labels
211
  return datasets.DatasetInfo(
212
  description=_DESCRIPTION,
@@ -214,10 +79,6 @@ class Bibles(datasets.GeneratorBasedBuilder):
214
  {
215
  "text": datasets.Value("string"),
216
  "label": datasets.ClassLabel(names=labels),
217
- "language": datasets.Value("string"),
218
- "year": datasets.Value("int16"),
219
- "century": datasets.Value("string"),
220
- "codebook": datasets.Value("string"),
221
  }
222
  ),
223
  supervised_keys=None,
@@ -226,7 +87,7 @@ class Bibles(datasets.GeneratorBasedBuilder):
226
  )
227
 
228
  def _split_generators(self, dl_manager):
229
- URLS = {key: BIBLES[key](self.config.name) for key in BIBLES.keys()}
230
  downloaded_files = dl_manager.download(URLS)
231
  return [
232
  datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
@@ -238,12 +99,8 @@ class Bibles(datasets.GeneratorBasedBuilder):
238
  with open(filepath, encoding="utf-8") as csv_file:
239
  csv_reader = csv.reader(csv_file, delimiter=",")
240
  next(csv_reader) # skip header
241
- for idx, (text, label, language, year, century, codebook) in enumerate(csv_reader):
242
  yield int(idx), {
243
  "text": text,
244
- "label": self.labels.index(label),
245
- "language": language,
246
- "year": year,
247
- "century": century,
248
- "codebook": codebook,
249
  }
 
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
+ """Stanzas"""
16
  import csv
17
 
18
  import datasets
 
29
  """
30
 
31
  _DESCRIPTION = """\
32
+ Stanzas
33
  """
34
 
35
 
36
  _HOMEPAGE = "https://github.com/versae/bibles/"
37
 
38
+ STANZAS_BASE_URI = "https://huggingface.co/datasets/linhd-postdata/stanzas/resolve/main"
39
+ STANZAS = {
40
+ "validation": f"{STANZAS_BASE_URI}/eval.csv",
41
+ "test": f"{STANZAS_BASE_URI}/test.csv",
42
+ "train": f"{STANZAS_BASE_URI}/train.csv"
43
  }
44
 
45
 
46
+ class StanzasConfig(datasets.BuilderConfig):
47
  """BuilderConfig for NorNE."""
48
 
49
  def __init__(self, **kwargs):
50
+ """BuilderConfig for Stanzas.
51
  Args:
52
  **kwargs: keyword arguments forwarded to super.
53
  """
54
+ super(StanzasConfig, self).__init__(**kwargs)
55
 
56
 
57
+ class Stanzas(datasets.GeneratorBasedBuilder):
58
+ """Stanzas"""
59
 
60
+ StanzasConfig(
61
+ name="default",version=datasets.Version("1.0.0"), description="Stanzas")
 
 
 
62
 
63
  def _info(self):
64
+ labels = ['ovillejo', 'romance', 'octava_real', 'couplet', 'octava',
65
+ 'cuarteta', 'copla_real', 'serventesio', 'haiku', 'cuaderna_vía',
66
+ 'tercetillo', 'cantar', 'sextilla', 'espinela', 'lira',
67
+ 'octavilla', 'chamberga', 'endecha_real', 'romance_arte_mayor',
68
+ 'redondilla', 'septilla', 'silva_arromanzada', 'seguidilla',
69
+ 'cuarteto_lira', 'cuarteto', 'décima_antigua', 'seguidilla_gitana',
70
+ 'seguidilla_compuesta', 'copla_castellana', 'quintilla', 'soleá',
71
+ 'estrofa_manriqueña', 'quinteto', 'terceto', 'sexta_rima',
72
+ 'unknown', 'estrofa_sáfica', 'estrofa_francisco_de_la_torre',
73
+ 'novena', 'sexteto', 'copla_arte_menor', 'copla_arte_mayor',
74
+ 'terceto_monorrimo', 'copla_mixta', 'septeto', 'sexteto_lira']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  self.labels = labels
76
  return datasets.DatasetInfo(
77
  description=_DESCRIPTION,
 
79
  {
80
  "text": datasets.Value("string"),
81
  "label": datasets.ClassLabel(names=labels),
 
 
 
 
82
  }
83
  ),
84
  supervised_keys=None,
 
87
  )
88
 
89
  def _split_generators(self, dl_manager):
90
+ URLS = {key: STANZAS[key] for key in STANZAS.keys()}
91
  downloaded_files = dl_manager.download(URLS)
92
  return [
93
  datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
 
99
  with open(filepath, encoding="utf-8") as csv_file:
100
  csv_reader = csv.reader(csv_file, delimiter=",")
101
  next(csv_reader) # skip header
102
+ for idx, (text, label) in enumerate(csv_reader):
103
  yield int(idx), {
104
  "text": text,
105
+ "label": label,
 
 
 
 
106
  }