galtimur's picture
Update dataset/dataset.py
718c4ae verified
raw
history blame
1.47 kB
import datasets
_LANGUAGES = ["python", "java", "kotlin"]
class BugLocalizationConfig(datasets.BuilderConfig):
"""BuilderConfig for BugLocalizationConfig"""
def __init__(self, **kwargs):
"""BuilderConfig for BugLocalization Dataset.
Args:
**kwargs: keyword arguments forwarded to super.
"""
super(BugLocalizationConfig, self).__init__(**kwargs)
class BugLocalizationDatset(datasets.GeneratorBasedBuilder):
"""BugLocalizationDatset Dataset"""
BUILDER_CONFIGS = [
BugLocalizationConfig(name=lang, description=f"Bug localization dataset for {lang}.")
for lang in _LANGUAGES
]
def _info(self):
pass
def _split_generators(self, dl_manager):
urls = {
"python": "bug_localization_test_py.jsonl",
"java": "bug_localization_test_java.jsonl",
"kotlin": "bug_localization_test_kt.jsonl",
}
downloaded_files = dl_manager.download_and_extract(urls)
return [datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={"filepath": downloaded_files[self.config.name]}
)]
def _generate_examples(self, filepath):
with open(filepath, encoding="utf-8") as f:
for id_, line in enumerate(f):
data = json.loads(line)
yield data