File size: 3,192 Bytes
1d50cfe
 
 
 
 
 
 
 
 
1171735
1d50cfe
 
 
 
 
 
 
 
 
 
 
31c0cc9
1171735
 
 
 
41f5e2c
 
 
 
 
1171735
41f5e2c
31c0cc9
1d50cfe
 
 
 
 
 
1171735
41f5e2c
1d50cfe
 
1171735
1d50cfe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1171735
1d50cfe
 
1171735
1d50cfe
8fb79fe
 
 
 
1171735
 
1d50cfe
 
 
1171735
 
 
ed51a5e
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# silicone-merged.py

## About: This is a dataset script for diwank/silicone-merged
## Docs: https://huggingface.co/docs/datasets/dataset_script.html


"""Merged and simplified dialog act datasets from the silicone collection."""


import pandas as pd
import os

import datasets

_DESCRIPTION = """\
Merged and simplified dialog act datasets from the silicone collection.
"""

_HOMEPAGE = "https://huggingface.co/datasets/diwank/silicone-merged"
_LICENSE = "MIT"

_URLS = {
    "default": dict(
        train="https://huggingface.co/datasets/diwank/silicone-merged/resolve/main/train.h5",
        validation="https://huggingface.co/datasets/diwank/silicone-merged/resolve/main/validation.h5",
        test="https://huggingface.co/datasets/diwank/silicone-merged/resolve/main/test.h5",
    ),
    "balanced": dict(
        train="https://huggingface.co/datasets/diwank/silicone-merged/resolve/main/balanced.h5",
        validation="https://huggingface.co/datasets/diwank/silicone-merged/resolve/main/validation.h5",
        test="https://huggingface.co/datasets/diwank/silicone-merged/resolve/main/test.h5",
    )

}

class SiliconeMergedDataset(datasets.GeneratorBasedBuilder):
    """Merged and simplified dialog act datasets from the silicone collection."""

    VERSION = datasets.Version("1.0.0")
    BUILDER_CONFIGS = [
        datasets.BuilderConfig(name="default", version=VERSION, description="Default config"),
        datasets.BuilderConfig(name="balanced", version=VERSION, description="Balanced dataset config"),
    ]

    DEFAULT_CONFIG_NAME = "default"


    def _info(self):
        
        features = datasets.Features(
            {
                "text_a": datasets.Value("string"),
                "text_b": datasets.Value("string"),
                "labels": datasets.Value("int64")
            }
        )
        
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=features,
            supervised_keys=("text_b", "labels"),
            homepage=_HOMEPAGE,
            license=_LICENSE,
        )

    def _split_generators(self, dl_manager):
        # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
        # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
        # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
        urls = _URLS[self.config.name]
        filepaths = dl_manager.download_and_extract(urls)
        return [
            datasets.SplitGenerator(
                name=getattr(datasets.Split, split.upper()),
                # These kwargs will be passed to _generate_examples
                gen_kwargs=dict(
                    filepath=filepaths[split],
                    split=split,
                ),
            )
            for split in ["train", "test", "validation"]
        ]

    def _generate_examples(self, filepath, split):
        df = pd.read_hdf(filepath, "data")

        for key, tuple in enumerate(df.itertuples(index=False)):
            yield key, tuple._asdict()