# 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 csv 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 = [ "https://huggingface.co/datasets/diwank/silicone-merged/resolve/main/train.csv", "https://huggingface.co/datasets/diwank/silicone-merged/resolve/main/validation.csv", "https://huggingface.co/datasets/diwank/silicone-merged/resolve/main/test.csv", ] 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"), ] 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] data_dir = dl_manager.download_and_extract(urls) return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, # These kwargs will be passed to _generate_examples gen_kwargs={ "filepath": os.path.join(data_dir, "train.csv"), "split": "train", }, ), datasets.SplitGenerator( name=datasets.Split.TEST, # These kwargs will be passed to _generate_examples gen_kwargs={ "filepath": os.path.join(data_dir, "test.csv"), "split": "test" }, ), datasets.SplitGenerator( name=datasets.Split.VALIDATION, # These kwargs will be passed to _generate_examples gen_kwargs={ "filepath": os.path.join(data_dir, "validation.csv"), "split": "validation", }, ), ] def _generate_examples(self, filepath, split): with open(filepath, encoding="utf-8") as f: reader = csv.reader(f) for key, data in enumerate(reader): yield key, data