Diwank Singh Tomer
commited on
Commit
•
1d50cfe
1
Parent(s):
73baee0
Add loader script
Browse filesSigned-off-by: Diwank Singh Tomer <diwank.singh@gmail.com>
- silicone-merged.py +95 -0
silicone-merged.py
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# silicone-merged.py
|
2 |
+
|
3 |
+
## About: This is a dataset script for diwank/silicone-merged
|
4 |
+
## Docs: https://huggingface.co/docs/datasets/dataset_script.html
|
5 |
+
|
6 |
+
|
7 |
+
"""Merged and simplified dialog act datasets from the silicone collection."""
|
8 |
+
|
9 |
+
|
10 |
+
import csv
|
11 |
+
import os
|
12 |
+
|
13 |
+
import datasets
|
14 |
+
|
15 |
+
_DESCRIPTION = """\
|
16 |
+
Merged and simplified dialog act datasets from the silicone collection.
|
17 |
+
"""
|
18 |
+
|
19 |
+
_HOMEPAGE = "https://huggingface.co/datasets/diwank/silicone-merged"
|
20 |
+
_LICENSE = "MIT"
|
21 |
+
|
22 |
+
_URLS = [
|
23 |
+
"https://huggingface.co/datasets/diwank/silicone-merged/resolve/main/train.csv",
|
24 |
+
"https://huggingface.co/datasets/diwank/silicone-merged/resolve/main/validation.csv",
|
25 |
+
"https://huggingface.co/datasets/diwank/silicone-merged/resolve/main/test.csv",
|
26 |
+
]
|
27 |
+
|
28 |
+
class SiliconeMergedDataset(datasets.GeneratorBasedBuilder):
|
29 |
+
"""Merged and simplified dialog act datasets from the silicone collection."""
|
30 |
+
|
31 |
+
VERSION = datasets.Version("1.0.0")
|
32 |
+
BUILDER_CONFIGS = [
|
33 |
+
datasets.BuilderConfig(name="default", version=VERSION, description="default config"),
|
34 |
+
]
|
35 |
+
|
36 |
+
DEFAULT_CONFIG_NAME = "default"
|
37 |
+
|
38 |
+
|
39 |
+
def _info(self):
|
40 |
+
|
41 |
+
features = datasets.Features(
|
42 |
+
{
|
43 |
+
"text_a": datasets.Value("string"),
|
44 |
+
"text_b": datasets.Value("string"),
|
45 |
+
"labels": datasets.Value("int64")
|
46 |
+
}
|
47 |
+
)
|
48 |
+
|
49 |
+
return datasets.DatasetInfo(
|
50 |
+
description=_DESCRIPTION,
|
51 |
+
features=features,
|
52 |
+
supervised_keys=("text_b", "labels"),
|
53 |
+
homepage=_HOMEPAGE,
|
54 |
+
license=_LICENSE,
|
55 |
+
)
|
56 |
+
|
57 |
+
def _split_generators(self, dl_manager):
|
58 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
59 |
+
# 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.
|
60 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
61 |
+
urls = _URLS[self.config.name]
|
62 |
+
data_dir = dl_manager.download_and_extract(urls)
|
63 |
+
return [
|
64 |
+
datasets.SplitGenerator(
|
65 |
+
name=datasets.Split.TRAIN,
|
66 |
+
# These kwargs will be passed to _generate_examples
|
67 |
+
gen_kwargs={
|
68 |
+
"filepath": os.path.join(data_dir, "train.csv"),
|
69 |
+
"split": "train",
|
70 |
+
},
|
71 |
+
),
|
72 |
+
datasets.SplitGenerator(
|
73 |
+
name=datasets.Split.TEST,
|
74 |
+
# These kwargs will be passed to _generate_examples
|
75 |
+
gen_kwargs={
|
76 |
+
"filepath": os.path.join(data_dir, "test.csv"),
|
77 |
+
"split": "test"
|
78 |
+
},
|
79 |
+
),
|
80 |
+
datasets.SplitGenerator(
|
81 |
+
name=datasets.Split.VALIDATION,
|
82 |
+
# These kwargs will be passed to _generate_examples
|
83 |
+
gen_kwargs={
|
84 |
+
"filepath": os.path.join(data_dir, "validation.csv"),
|
85 |
+
"split": "validation",
|
86 |
+
},
|
87 |
+
),
|
88 |
+
]
|
89 |
+
|
90 |
+
def _generate_examples(self, filepath, split):
|
91 |
+
|
92 |
+
with open(filepath, encoding="utf-8") as f:
|
93 |
+
reader = csv.reader(f)
|
94 |
+
for key, data in enumerate(reader):
|
95 |
+
yield key, data
|