File size: 2,128 Bytes
34a454b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import json
import datasets

class GoEmotionsESConfig(datasets.BuilderConfig):
    def __init__(self, **kwargs):
        super(GoEmotionsESConfig, self).__init__(**kwargs)

class GoEmotionsES(datasets.GeneratorBasedBuilder):
    BUILDER_CONFIGS = [
        GoEmotionsESConfig(name="default", version=datasets.Version("1.0.0"), description="GoEmotions en español")
    ]

    def _info(self):
        return datasets.DatasetInfo(
            description="GoEmotions traducido y adaptado al español, por Lucio-Rhapsody",
            features=datasets.Features({
                "persona": datasets.Sequence(datasets.Value("string")),
                "historia": datasets.Sequence({
                    "from": datasets.Value("string"),
                    "value": datasets.Value("string")
                }),
                "metadatos": {
                    "coherente": datasets.Value("bool"),
                    "perplexity": datasets.Value("float"),
                    "emotion_manual": datasets.Value("string"),
                    "energy_level": datasets.Value("int32"),
                    "context_topic": datasets.Value("string"),
                    "memory_reference": datasets.Value("string"),
                    "intent": datasets.Value("string"),
                    "nivel_reflexion": datasets.Value("string"),
                    "tipo_vinculo": datasets.Value("string"),
                    "tono_conversacional": datasets.Value("string"),
                    "inspiracion_lucio": datasets.Value("bool")
                }
            }),
            license="CC-BY-4.0",
            homepage="https://huggingface.co/datasets/Lucio-Rhapsody/goemotions-es",
        )

    def _split_generators(self, dl_manager):
        path = dl_manager.download_and_extract("goemotions_es_unificadoDefinitivo.json")
        return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": path})]

    def _generate_examples(self, filepath):
        with open(filepath, encoding="utf-8") as f:
            data = json.load(f)
            for idx, row in enumerate(data):
                yield idx, row