|
|
|
|
|
|
|
|
|
|
|
import json |
|
import datasets |
|
|
|
_DESCRIPTION = """\ |
|
CodeGauntlt is a multi-source dataset designed for evaluating and enhancing the robustness of AI code repair and generation agents. It introduces adversarially-constructed, obfuscated, or deceptive bugs across several programming languages, based on real-world and synthetic sources. |
|
""" |
|
|
|
_HOMEPAGE = "https://huggingface.co/datasets/HackerHardware/CodeGauntlt" |
|
|
|
_CITATION = """\ |
|
@misc{codegauntlt2025, |
|
title={CodeGauntlt: A Dataset for Adversarial Evaluation of Code Repair Models}, |
|
author={Esteban and Collaborators}, |
|
year={2025}, |
|
howpublished={\\url{https://huggingface.co/datasets/HackerHardware/CodeGauntlt}}, |
|
} |
|
""" |
|
|
|
class CodeGauntlt(datasets.GeneratorBasedBuilder): |
|
VERSION = datasets.Version("1.0.0") |
|
|
|
def _info(self): |
|
features = datasets.Features( |
|
{ |
|
"id": datasets.Value("string"), |
|
"source": datasets.Value("string"), |
|
"description": datasets.Value("string"), |
|
"code_buggy": datasets.Value("string"), |
|
"code_fixed": datasets.Value("string"), |
|
"bug_type": datasets.Value("string"), |
|
"tags": datasets.Value("string"), |
|
"metadata": datasets.Value("string") |
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
homepage=_HOMEPAGE, |
|
citation=_CITATION, |
|
license="apache-2.0" |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
data_dir = dl_manager.download_and_extract("./data") |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={"filepath": f"{data_dir}/train.jsonl"} |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
gen_kwargs={"filepath": f"{data_dir}/validation.jsonl"} |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
gen_kwargs={"filepath": f"{data_dir}/test.jsonl"} |
|
), |
|
] |
|
|
|
def _generate_examples(self, filepath): |
|
with open(filepath, encoding="utf-8") as f: |
|
for i, line in enumerate(f): |
|
record = json.loads(line) |
|
yield i, record |
|
|