-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsplit-dataset.py
More file actions
77 lines (64 loc) · 2.18 KB
/
split-dataset.py
File metadata and controls
77 lines (64 loc) · 2.18 KB
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
import json
import datasets
from datasets import load_dataset
import os
_CITATION = """"""
_DESCRIPTION = """"""
_HOMEPAGE = ""
_LICENSE = "CC BY-NC-ND 4.0"
class Text2Chart31(datasets.GeneratorBasedBuilder):
"""Text2Chart31 Corpus dataset."""
VERSION = datasets.Version("1.1.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(name="Text2Chart31"),
]
def _info(self):
features = datasets.Features(
{
"id": datasets.Value("string"),
"description": datasets.Value("string"),
"code": datasets.Value("string"),
"csv-address": datasets.Value("string"),
"csv-name": datasets.Value("string"),
"data-table": datasets.Value("string"),
"data-type": datasets.Value("string"),
"plot-category": datasets.Value("string"),
"plot-type": datasets.Value("string"),
"reasoning-step": datasets.Value("string"),
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
supervised_keys=None,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
path = "."
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"filepath": (path + "/prepare-data/", "Text2Chart-31-train.json"),
"split": "train",
},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"filepath": (path + "/prepare-data/", "Text2Chart-31-test.json"),
"split": "test",
},
),
]
def _generate_examples(self, filepath, split):
"""Yields examples."""
path, fname = filepath
bio = os.path.join(path, fname)
with open(bio, "r") as f:
data = json.load(f)
for example in data:
yield example["id"], example