davidlms commited on
Commit
36e1bc9
1 Parent(s): 46e3d88

Delete letras-carnaval-cadiz.py

Browse files
Files changed (1) hide show
  1. letras-carnaval-cadiz.py +0 -108
letras-carnaval-cadiz.py DELETED
@@ -1,108 +0,0 @@
1
- from datasets import DatasetBuilder, SplitGenerator, Split, Features, Value, Sequence, BuilderConfig, GeneratorBasedBuilder
2
- import datasets
3
- from datasets.utils.download_manager import DownloadManager
4
- from typing import List, Any, Tuple
5
- import json
6
- import os
7
- import tempfile
8
-
9
- _CITATION = """\
10
- @misc{letrascarnavalcadiz2023,
11
- author = {Romero Reyna, Iván and Franco Medinilla, Jesús Federico and Avecilla de la Herrán, Jesús Carlos},
12
- title = {letras-carnaval-cadiz},
13
- year = {2023},
14
- url = {https://huggingface.co/datasets/IES-Rafael-Alberti/letras-carnaval-cadiz}
15
- }
16
- """
17
-
18
- _DESCRIPTION = """\
19
- This dataset is a comprehensive collection of lyrics from the Carnaval de Cádiz, a significant cultural heritage of the city of Cádiz, Spain. Despite its cultural importance, there has been a lack of a structured database for these lyrics, hindering research and public access to this cultural heritage. This dataset aims to address this gap.
20
-
21
- The dataset was created by the Cádiz AI Learning Community, a branch of the non-profit association Spain AI, and was developed by Iván Romero Reyna and Jesús Federico Franco Medinilla, students of the Specialization Course in Artificial Intelligence and Big Data at IES Rafael Alberti during the 2022-2023 academic year. The project is supervised by Jesús Carlos Avecilla de la Herrán, a computational linguist.
22
-
23
- Collaboration is encouraged, with individuals able to verify the different records of the dataset at letrascarnavalcadiz.com, ensuring the transcription of the lyrics and all data are correct. New lyrics can also be added to the dataset. Corrections and additions are not immediately reflected in the dataset but are updated periodically.
24
-
25
- For more information or to report a problem, you can write to [email protected].
26
- """
27
-
28
- # Mapping for song_type and group_type
29
- song_type_mapping = {
30
- 1: "presentación",
31
- 2: "pasodoble/tango",
32
- 3: "cuplé",
33
- 4: "estribillo",
34
- 5: "popurrí",
35
- 6: "cuarteta",
36
- }
37
-
38
- group_type_mapping = {
39
- 1: "coro",
40
- 2: "comparsa",
41
- 3: "chirigota",
42
- 4: "cuarteto",
43
- }
44
-
45
- class CadizCarnivalConfig(BuilderConfig):
46
- def __init__(self, **kwargs):
47
- super().__init__(version=datasets.Version("1.0.2"), **kwargs)
48
-
49
- class CadizCarnivalDataset(GeneratorBasedBuilder):
50
- VERSION = "1.0.0"
51
- BUILDER_CONFIGS = [
52
- CadizCarnivalConfig(name="accurate", description="This part of my dataset covers accurate data"),
53
- CadizCarnivalConfig(name="midaccurate", description="This part of my dataset covers midaccurate data"),
54
- CadizCarnivalConfig(name="all", description="This part of my dataset covers both accurate and midaccurate data"),
55
- ]
56
-
57
- DEFAULT_CONFIG_NAME = "all"
58
-
59
- def _info(self):
60
- return datasets.DatasetInfo(
61
- description=_DESCRIPTION,
62
- features=datasets.Features({
63
- "id": Value("string"),
64
- "authors": Sequence(Value("string")),
65
- "song_type": Value("string"),
66
- "year": Value("string"),
67
- "group": Value("string"),
68
- "group_type": Value("string"),
69
- "lyrics": Sequence(Value("string")),
70
- }),
71
- supervised_keys=None,
72
- homepage="https://letrascarnavalcadiz.com/",
73
- citation=_CITATION,
74
- )
75
-
76
- def _split_generators(self, dl_manager: DownloadManager) -> List[SplitGenerator]:
77
- urls_to_download = {
78
- "accurate": "https://huggingface.co/datasets/IES-Rafael-Alberti/letras-carnaval-cadiz/raw/main/data/accurate-00000-of-00001.json",
79
- "midaccurate": "https://huggingface.co/datasets/IES-Rafael-Alberti/letras-carnaval-cadiz/raw/main/data/midaccurate-00000-of-00001.json"
80
- }
81
- downloaded_files = dl_manager.download_and_extract(urls_to_download)
82
-
83
- if self.config.name == "accurate":
84
- return [SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["accurate"]})]
85
- elif self.config.name == "midaccurate":
86
- return [SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["midaccurate"]})]
87
- else: # Default is "all"
88
- # Load both JSON files and combine them
89
- with open(downloaded_files["accurate"], 'r') as f:
90
- data_accurate = json.load(f)
91
- with open(downloaded_files["midaccurate"], 'r') as f:
92
- data_midaccurate = json.load(f)
93
- data_all = data_accurate + data_midaccurate
94
-
95
- # Write the combined data to a temporary file
96
- with tempfile.NamedTemporaryFile(delete=False, mode='w') as temp_file:
97
- json.dump(data_all, temp_file)
98
- temp_filepath = temp_file.name
99
-
100
- return [SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": temp_filepath})]
101
-
102
- def _generate_examples(self, filepath: str):
103
- with open(filepath, encoding="utf-8") as f:
104
- data = json.load(f)
105
- for item in data:
106
- item["song_type"] = song_type_mapping.get(item["song_type"], "indefinido")
107
- item["group_type"] = group_type_mapping.get(item["group_type"], "indefinido")
108
- yield item["id"], item