|
import json |
|
import datasets |
|
|
|
_REPO_NAME = "TeDriCS/tedrics-data" |
|
|
|
_DESCRIPTION = "" |
|
|
|
_HOMEPAGE = "" |
|
|
|
_CITATION = """\ |
|
@misc{, |
|
title={ }, |
|
author={}, |
|
year={2022} |
|
} |
|
""" |
|
|
|
_LICENSES = ['CC BY-SA', 'CC Attribution 4.0'] |
|
|
|
_SUBSETS = ["tasks", "testcases", "codefunctions"] |
|
|
|
_DATA_URLS = { |
|
"tasks": { |
|
"train": ["tedrics_data_tasks.json"] |
|
}, |
|
"testcases": { |
|
"train": ["tedrics_data_testcases.json"] |
|
}, |
|
"codefunctions": { |
|
"train": ["tedrics_data_codefunctions.json"] |
|
} |
|
} |
|
|
|
class TeDriCSData(datasets.GeneratorBasedBuilder): |
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig( |
|
name=f"{subset}", |
|
version=datasets.Version("1.0"), |
|
description=_DESCRIPTION, |
|
) |
|
for subset in _SUBSETS |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = "tasks" |
|
|
|
def _info(self): |
|
if self.config.name == "tasks": |
|
features = datasets.Features( |
|
{ |
|
"task_id": datasets.Value("int32"), |
|
"mbpp_task_id": datasets.Value("int32"), |
|
"source": datasets.Value("string"), |
|
"licence": datasets.Sequence(datasets.Value("string")), |
|
"task": datasets.Value("string"), |
|
} |
|
) |
|
|
|
if self.config.name == "testcases": |
|
features = datasets.Features( |
|
{ |
|
"task_id": datasets.Value("int32"), |
|
"mbpp_task_id": datasets.Value("int32"), |
|
"task": datasets.Value("string"), |
|
"test_cases": datasets.Sequence( |
|
{ |
|
"test_case_id": datasets.Value("int32"), |
|
"cot": datasets.Value("string"), |
|
"input": datasets.Sequence(datasets.Value("string")), |
|
"output": datasets.Value("string") |
|
} |
|
) |
|
} |
|
) |
|
|
|
if self.config.name == "codefunctions": |
|
features = datasets.Features( |
|
{ |
|
"task_id": datasets.Value("int32"), |
|
"mbpp_task_id": datasets.Value("int32"), |
|
"description": datasets.Value("string"), |
|
"cot": datasets.Value("string"), |
|
"imports": datasets.Sequence(datasets.Value("string")), |
|
"function_head": datasets.Sequence(datasets.Value("string")), |
|
"function_body": datasets.Sequence(datasets.Value("string")) |
|
} |
|
) |
|
|
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
supervised_keys=None, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSES, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
urls = _DATA_URLS[self.config.name] |
|
data = dl_manager.download(urls) |
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=split, |
|
gen_kwargs={ |
|
"files": data[split], |
|
}, |
|
) |
|
for split in [datasets.Split.TRAIN] |
|
] |
|
|
|
def _generate_examples(self, filepath): |
|
with open(filepath, encoding="utf-8") as file: |
|
data = json.load(file) |
|
id_ = 0 |
|
for sample in data: |
|
yield id_, sample |
|
id_ += 1 |