File size: 2,450 Bytes
6e27ba3 |
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 |
# coding=utf-8
# CodeGauntlt dataset loading script for Hugging Face Datasets
# path: codegauntlt.py
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
|