davidlms commited on
Commit
fd9fe88
·
1 Parent(s): 42f826d

Delete letras-carnaval-cadiz.py

Browse files
Files changed (1) hide show
  1. letras-carnaval-cadiz.py +0 -77
letras-carnaval-cadiz.py DELETED
@@ -1,77 +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 logging
8
-
9
- logging.basicConfig(level=logging.DEBUG)
10
-
11
- # Mapping for song_type and group_type
12
- song_type_mapping = {
13
- 1: "presentación",
14
- 2: "pasodoble/tango",
15
- 3: "cuplé",
16
- 4: "estribillo",
17
- 5: "popurrí",
18
- 6: "cuarteta",
19
- }
20
-
21
- group_type_mapping = {
22
- 1: "coro",
23
- 2: "comparsa",
24
- 3: "chirigota",
25
- 4: "cuarteto",
26
- }
27
-
28
- class CadizCarnivalConfig(BuilderConfig):
29
- def __init__(self, **kwargs):
30
- super().__init__(version=datasets.Version("1.0.2"), **kwargs)
31
-
32
- class CadizCarnivalDataset(GeneratorBasedBuilder):
33
- VERSION = "1.0.0"
34
- BUILDER_CONFIGS = [
35
- CadizCarnivalConfig(name="accurate", description="This part of my dataset covers accurate data"),
36
- CadizCarnivalConfig(name="midaccurate", description="This part of my dataset covers midaccurate data"),
37
- ]
38
-
39
- def _info(self):
40
- return datasets.DatasetInfo(
41
- description="_DESCRIPTION",
42
- features=datasets.Features({
43
- "id": Value("string"),
44
- "authors": Sequence(Value("string")),
45
- "song_type": Value("string"),
46
- "year": Value("string"),
47
- "group": Value("string"),
48
- "group_type": Value("string"),
49
- "lyrics": Sequence(Value("string")),
50
- }),
51
- supervised_keys=None,
52
- homepage="https://letrascarnavalcadiz.com/",
53
- citation="_CITATION",
54
- )
55
-
56
- def _split_generators(self, dl_manager: DownloadManager) -> List[SplitGenerator]:
57
- urls_to_download = {
58
- "accurate": "https://huggingface.co/datasets/IES-Rafael-Alberti/letras-carnaval-cadiz/raw/main/data/accurate-00000-of-00001.json",
59
- "midaccurate": "https://huggingface.co/datasets/IES-Rafael-Alberti/letras-carnaval-cadiz/raw/main/data/midaccurate-00000-of-00001.json"
60
- }
61
- downloaded_files = dl_manager.download_and_extract(urls_to_download)
62
-
63
- if self.config.name == "accurate":
64
- return [SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["accurate"]})]
65
- elif self.config.name == "midaccurate":
66
- return [SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["midaccurate"]})]
67
-
68
-
69
-
70
- def _generate_examples(self, filepath: str):
71
- with open(filepath, encoding="utf-8") as f:
72
- data = json.load(f)
73
- for item in data:
74
- item["song_type"] = song_type_mapping.get(item["song_type"], "indefinido")
75
- item["group_type"] = group_type_mapping.get(item["group_type"], "indefinido")
76
- logging.debug(f"Processing item with id {item['id']}")
77
- yield item["id"], item