ClassEval / ClassEval.py
FudanSELab's picture
Upload ClassEval.py
2ae3d1c
raw
history blame
3.83 kB
import json
import datasets
_DESCRIPTION = """\
FudanSELab ClassEval
"""
_URL = "ClassEval_data.json"
_CITATION = """\
@misc{du2023classeval,
title={ClassEval: A Manually-Crafted Benchmark for Evaluating LLMs on Class-level Code Generation},
author={Xueying Du and Mingwei Liu and Kaixin Wang and Hanlin Wang and Junwei Liu and Yixuan Chen and Jiayi Feng and Chaofeng Sha and Xin Peng and Yiling Lou},
year={2023},
eprint={2308.01861},
archivePrefix={arXiv},
primaryClass={cs.CL}
}"""
_HOMEPAGE = "https://github.com/FudanSELab/ClassEval"
_LICENSE = "MIT"
class ClassEval(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("1.0.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="class_eval",
version=datasets.Version("1.0.0"),
description=_DESCRIPTION,
)
]
def _info(self):
method_feature = datasets.Features(
{
"method_name": datasets.Value("string"),
"method_description": datasets.Value("string"),
"test_class": datasets.Value("string"),
"test_code": datasets.Value("string"),
"solution_code": datasets.Value("string"),
"dependencies": {
"Standalone": datasets.Value("bool"),
"lib_dependencies": datasets.Sequence(datasets.Value("string")),
"field_dependencies": datasets.Sequence(datasets.Value("string")),
"method_dependencies": datasets.Sequence(datasets.Value("string")),
}
}
)
features = datasets.Features(
{
"task_id": datasets.Value("string"),
"skeleton": datasets.Value("string"),
"test": datasets.Value("string"),
"solution_code": datasets.Value("string"),
"import_statement": datasets.Sequence(datasets.Value("string")),
"class_description": datasets.Value("string"),
"methods_info": [method_feature],
"class_name": datasets.Value("string"),
"test_classes": datasets.Sequence(datasets.Value("string")),
"class_constructor": datasets.Value("string"),
"fields": datasets.Sequence(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."""
data_dir = dl_manager.download(_URL)
return [
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"filepath": data_dir,
},
)
]
def _generate_examples(self, filepath):
key = 0
with open(filepath, encoding = 'utf-8') as f:
cont = json.load(f)
for row in cont:
yield key, {
"task_id": row["task_id"],
"skeleton": row["skeleton"],
"test": row["test"],
"solution_code": row["solution_code"],
"import_statement": row["import_statement"],
"class_description": row["class_description"],
"methods_info": row["methods_info"],
"class_name": row["class_name"],
"test_classes": row["test_classes"],
"class_constructor": row["class_constructor"],
"fields": row["fields"],
}
key += 1