Delete letras-carnaval-cadiz.py
Browse files- letras-carnaval-cadiz.py +0 -63
letras-carnaval-cadiz.py
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
from datasets import DatasetBuilder, SplitGenerator, Split, Features, Value, Sequence, BuilderConfig
|
2 |
-
from datasets.utils.download_manager import DownloadManager
|
3 |
-
from typing import List, Any, Tuple
|
4 |
-
import json
|
5 |
-
import os
|
6 |
-
|
7 |
-
# Mapping for song_type and group_type
|
8 |
-
song_type_mapping = {
|
9 |
-
1: "presentación",
|
10 |
-
2: "pasodoble/tango",
|
11 |
-
3: "cuplé",
|
12 |
-
4: "estribillo",
|
13 |
-
5: "popurrí",
|
14 |
-
6: "cuarteta",
|
15 |
-
}
|
16 |
-
|
17 |
-
group_type_mapping = {
|
18 |
-
1: "coro",
|
19 |
-
2: "comparsa",
|
20 |
-
3: "chirigota",
|
21 |
-
4: "cuarteto",
|
22 |
-
}
|
23 |
-
|
24 |
-
class CadizCarnivalConfig(BuilderConfig):
|
25 |
-
def __init__(self, **kwargs):
|
26 |
-
super(CadizCarnivalConfig, self).__init__(**kwargs)
|
27 |
-
|
28 |
-
class CadizCarnivalDataset(DatasetBuilder):
|
29 |
-
VERSION = "1.0.0"
|
30 |
-
BUILDER_CONFIGS = [
|
31 |
-
CadizCarnivalConfig(name="accurate", description="This part of my dataset covers accurate data"),
|
32 |
-
CadizCarnivalConfig(name="midaccurate", description="This part of my dataset covers midaccurate data"),
|
33 |
-
]
|
34 |
-
|
35 |
-
def _info(self):
|
36 |
-
return Features({
|
37 |
-
"id": Value("string"),
|
38 |
-
"authors": Sequence(Value("string")),
|
39 |
-
"song_type": Value("string"),
|
40 |
-
"year": Value("string"),
|
41 |
-
"group": Value("string"),
|
42 |
-
"group_type": Value("string"),
|
43 |
-
"lyric": Sequence(Value("string")),
|
44 |
-
})
|
45 |
-
|
46 |
-
def _split_generators(self, dl_manager: DownloadManager) -> List[SplitGenerator]:
|
47 |
-
paths = dl_manager.download_and_extract({
|
48 |
-
"accurate": "data/accurate-00000-of-00001.json",
|
49 |
-
"midaccurate": "data/midaccurate-00000-of-00001.json"
|
50 |
-
})
|
51 |
-
|
52 |
-
if self.config.name == "accurate":
|
53 |
-
return [SplitGenerator(name="accurate", gen_kwargs={"filepath": paths["accurate"]})]
|
54 |
-
elif self.config.name == "midaccurate":
|
55 |
-
return [SplitGenerator(name="midaccurate", gen_kwargs={"filepath": paths["midaccurate"]})]
|
56 |
-
|
57 |
-
def _generate_examples(self, filepath: str) -> Tuple[str, Any]:
|
58 |
-
with open(filepath, encoding="utf-8") as f:
|
59 |
-
data = json.load(f)
|
60 |
-
for item in data:
|
61 |
-
item["song_type"] = song_type_mapping.get(item["song_type"], "indefinido")
|
62 |
-
item["group_type"] = group_type_mapping.get(item["group_type"], "indefinido")
|
63 |
-
yield item["id"], item
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|