Delete letras-carnaval-cadiz.py
Browse files- letras-carnaval-cadiz.py +0 -64
letras-carnaval-cadiz.py
DELETED
@@ -1,64 +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="accurated", description="This part of my dataset covers accurated data"),
|
32 |
-
CadizCarnivalConfig(name="mid-accurated", description="This part of my dataset covers mid-accurated 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 |
-
"accurated": "data/accurate-00000-of-00001.json",
|
49 |
-
"mid-accurated": "data/mid-accurate-00000-of-00001.json"
|
50 |
-
})
|
51 |
-
|
52 |
-
if self.config.name == "accurated":
|
53 |
-
return [SplitGenerator(name=Split.TRAIN, gen_kwargs={"filepath": paths["accurated"]})]
|
54 |
-
elif self.config.name == "mid-accurated":
|
55 |
-
return [SplitGenerator(name=Split.TEST, gen_kwargs={"filepath": paths["mid-accurated"]})
|
56 |
-
]
|
57 |
-
|
58 |
-
def _generate_examples(self, filepath: str) -> Tuple[str, Any]:
|
59 |
-
with open(filepath, encoding="utf-8") as f:
|
60 |
-
data = json.load(f)
|
61 |
-
for item in data:
|
62 |
-
item["song_type"] = song_type_mapping.get(item["song_type"], "indefinido")
|
63 |
-
item["group_type"] = group_type_mapping.get(item["group_type"], "indefinido")
|
64 |
-
yield item["id"], item
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|