Datasets:
Tasks:
Text Retrieval
Modalities:
Text
Formats:
parquet
Sub-tasks:
document-retrieval
Languages:
code
Size:
10K - 100K
License:
Convert dataset to Parquet (#5)
Browse files- Convert dataset to Parquet (4bfc047a7002cc24638f10e8855a20fbbbec630d)
- Delete loading script (ce880554b60b42b24b872c7acd26bfa9fb4e0aa5)
- Delete loading script auxiliary file (6e3bb97cf21cac956cd0511120a420fc490fbd19)
- Delete loading script auxiliary file (9679450cf55e2c7796b46ef46cfb6fd8a6c44671)
Files changed (7)
- README.md+11-2
- code_x_glue_cc_clone_detection_poj104.pyDeleted-93
- common.pyDeleted-75
- data/test-00000-of-00001.parquetAdded+3
- data/train-00000-of-00001.parquetAdded+3
- data/validation-00000-of-00001.parquetAdded+3
- generated_definitions.pyDeleted-12
1234512 unmodified lines18192021222312 unmodified lines3637383940414243---pretty_name: CodeXGlueCcCloneDetectionPoj104annotations_creators:- foundlanguage_creators:12 unmodified lines- text-retrievaltask_ids:- document-retrievaldataset_info:features:- name: id12 unmodified lines- name: testnum_bytes: 7227506num_examples: 12000download_size: 8658581dataset_size: 33789014---# Dataset Card for "code_x_glue_cc_clone_detection_poj_104"123412 unmodified lines1718192021222312 unmodified lines3637383940414243444546474849505152---annotations_creators:- foundlanguage_creators:12 unmodified lines- text-retrievaltask_ids:- document-retrievalpretty_name: CodeXGlueCcCloneDetectionPoj104dataset_info:features:- name: id12 unmodified lines- name: testnum_bytes: 7227506num_examples: 12000download_size: 13348734dataset_size: 33789014configs:- config_name: defaultdata_files:- split: trainpath: data/train-*- split: validationpath: data/validation-*- split: testpath: data/test-*---# Dataset Card for "code_x_glue_cc_clone_detection_poj_104"
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293from typing import List
import datasets
from .common import TrainValidTestChildfrom .generated_definitions import DEFINITIONS
_DESCRIPTION = """Given a code and a collection of candidates as the input, the task is to return Top K codes with the same semantic. Models are evaluated by MAP score.We use POJ-104 dataset on this task."""
_CITATION = """@inproceedings{mou2016convolutional,title={Convolutional neural networks over tree structures for programming language processing},author={Mou, Lili and Li, Ge and Zhang, Lu and Wang, Tao and Jin, Zhi},booktitle={Proceedings of the Thirtieth AAAI Conference on Artificial Intelligence},pages={1287--1293},year={2016}}"""
class CodeXGlueCcCloneDetectionPoj104Impl(TrainValidTestChild): _DESCRIPTION = _DESCRIPTION _CITATION = _CITATION
_FEATURES = { "id": datasets.Value("int32"), # Index of the sample "code": datasets.Value("string"), # The full text of the function "label": datasets.Value("string"), # The id of problem that the source code solves }
_SUPERVISED_KEYS = ["label"]
SPLIT_RANGES = {"train": (1, 65), "valid": (65, 81), "test": (81, 195)}
def _generate_examples(self, files, split_name): cont = 0 for path, f in files: # path are in the format ProgramData/{index}/{filename} label = int(path.split("/")[1]) if self.SPLIT_RANGES[split_name][0] <= label <= self.SPLIT_RANGES[split_name][1]: js = {} js["label"] = str(label) js["id"] = cont js["code"] = f.read().decode("latin-1") yield cont, js cont += 1
CLASS_MAPPING = { "CodeXGlueCcCloneDetectionPoj104": CodeXGlueCcCloneDetectionPoj104Impl,}
class CodeXGlueCcCloneDetectionPoj104(datasets.GeneratorBasedBuilder): BUILDER_CONFIG_CLASS = datasets.BuilderConfig BUILDER_CONFIGS = [ datasets.BuilderConfig(name=name, description=info["description"]) for name, info in DEFINITIONS.items() ]
def _info(self): name = self.config.name info = DEFINITIONS[name] if info["class_name"] in CLASS_MAPPING: self.child = CLASS_MAPPING[info["class_name"]](info) else: raise RuntimeError(f"Unknown python class for dataset configuration {name}") ret = self.child._info() return ret
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]: name = self.config.name info = DEFINITIONS[name] archive = dl_manager.download(info["raw_url"] + "/programs.tar.gz") return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, # These kwargs will be passed to _generate_examples gen_kwargs={"files": dl_manager.iter_archive(archive), "split_name": "train"}, ), datasets.SplitGenerator( name=datasets.Split.VALIDATION, # These kwargs will be passed to _generate_examples gen_kwargs={"files": dl_manager.iter_archive(archive), "split_name": "valid"}, ), datasets.SplitGenerator( name=datasets.Split.TEST, # These kwargs will be passed to _generate_examples gen_kwargs={"files": dl_manager.iter_archive(archive), "split_name": "test"}, ), ]
def _generate_examples(self, files, split_name): return self.child._generate_examples(files, split_name)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475from typing import List
import datasets
# Citation, taken from https://github.com/microsoft/CodeXGLUE_DEFAULT_CITATION = """@article{CodeXGLUE, title={CodeXGLUE: A Benchmark Dataset and Open Challenge for Code Intelligence}, year={2020},}"""
class Child: _DESCRIPTION = None _FEATURES = None _CITATION = None SPLITS = {"train": datasets.Split.TRAIN} _SUPERVISED_KEYS = None
def __init__(self, info): self.info = info
def homepage(self): return self.info["project_url"]
def _info(self): # This is the description that will appear on the datasets page. return datasets.DatasetInfo( description=self.info["description"] + "\n\n" + self._DESCRIPTION, features=datasets.Features(self._FEATURES), homepage=self.homepage(), citation=self._CITATION or _DEFAULT_CITATION, supervised_keys=self._SUPERVISED_KEYS, )
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]: SPLITS = self.SPLITS _URL = self.info["raw_url"] urls_to_download = {} for split in SPLITS: if split not in urls_to_download: urls_to_download[split] = {}
for key, url in self.generate_urls(split): if not url.startswith("http"): url = _URL + "/" + url urls_to_download[split][key] = url
downloaded_files = {} for k, v in urls_to_download.items(): downloaded_files[k] = dl_manager.download_and_extract(v)
return [ datasets.SplitGenerator( name=SPLITS[k], gen_kwargs={"split_name": k, "file_paths": downloaded_files[k]}, ) for k in SPLITS ]
def check_empty(self, entries): all_empty = all([v == "" for v in entries.values()]) all_non_empty = all([v != "" for v in entries.values()])
if not all_non_empty and not all_empty: raise RuntimeError("Parallel data files should have the same number of lines.")
return all_empty
class TrainValidTestChild(Child): SPLITS = { "train": datasets.Split.TRAIN, "valid": datasets.Split.VALIDATION, "test": datasets.Split.TEST, }123version https://git-lfs.github.com/spec/v1oid sha256:4c1d6389d66a68c2b5ad4c345ac264b8f4062258aa870b74a3fd478b7cce4955size 2853417123version https://git-lfs.github.com/spec/v1oid sha256:36403bfcf7933eb40fcdadd543bfece26d18c52a4f1960a96550aa6b15708c03size 8031542123version https://git-lfs.github.com/spec/v1oid sha256:497282b576c408edc2bf4ba0d1b12fda3cdadb102f3cd670a99fa6eeef587ab7size 2463775123456789101112DEFINITIONS = { "default": { "class_name": "CodeXGlueCcCloneDetectionPoj104", "dataset_type": "Code-Code", "description": "CodeXGLUE Clone-detection-POJ-104 dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/Clone-detection-POJ-104", "dir_name": "Clone-detection-POJ-104", "name": "default", "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/Clone-detection-POJ-104", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/Clone-detection-POJ-104/dataset", "sizes": {"test": 12000, "train": 32000, "validation": 8000}, }}README.md+11-2
code_x_glue_cc_clone_detection_poj104.pyDeleted-93
common.pyDeleted-75
data/test-00000-of-00001.parquetAdded+3
data/train-00000-of-00001.parquetAdded+3
data/validation-00000-of-00001.parquetAdded+3
generated_definitions.pyDeleted-12