Datasets:
Tasks:
Text Classification
Formats:
parquet
Sub-tasks:
semantic-similarity-classification
Languages:
code
Size:
1M - 10M
License:
Convert dataset to Parquet
#3
by albertvillanova HF Staff - opened
Files changed (16)
- README.md+14-5
- code_x_glue_cc_clone_detection_big_clone_bench.pyDeleted-95
- common.pyDeleted-75
- data/test-00000-of-00003.parquetAdded+3
- data/test-00001-of-00003.parquetAdded+3
- data/test-00002-of-00003.parquetAdded+3
- data/train-00000-of-00006.parquetAdded+3
- data/train-00001-of-00006.parquetAdded+3
- data/train-00002-of-00006.parquetAdded+3
- data/train-00003-of-00006.parquetAdded+3
- data/train-00004-of-00006.parquetAdded+3
- data/train-00005-of-00006.parquetAdded+3
- data/validation-00000-of-00003.parquetAdded+3
- data/validation-00001-of-00003.parquetAdded+3
- data/validation-00002-of-00003.parquetAdded+3
- generated_definitions.pyDeleted-12
33 unmodified lines3435363738394041424344454647484933 unmodified linesdtype: boolsplits:- name: trainnum_bytes: 2888035757num_examples: 901028- name: validationnum_bytes: 1371399694num_examples: 415416- name: testnum_bytes: 1220662901num_examples: 415416download_size: 47955874dataset_size: 5480098352---# Dataset Card for "code_x_glue_cc_clone_detection_big_clone_bench"33 unmodified lines3435363738394041424344454647484950515253545556575833 unmodified linesdtype: boolsplits:- name: trainnum_bytes: 2888035029num_examples: 901028- name: validationnum_bytes: 1371399358num_examples: 415416- name: testnum_bytes: 1220662565num_examples: 415416download_size: 1279275281dataset_size: 5480096952configs:- 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_big_clone_bench"
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495from typing import List
import datasets
from .common import TrainValidTestChildfrom .generated_definitions import DEFINITIONS
_DESCRIPTION = """Given two codes as the input, the task is to do binary classification (0/1), where 1 stands for semantic equivalence and 0 for others. Models are evaluated by F1 score.The dataset we use is BigCloneBench and filtered following the paper Detecting Code Clones with Graph Neural Network and Flow-Augmented Abstract Syntax Tree."""
_CITATION = """@inproceedings{svajlenko2014towards,title={Towards a big data curated benchmark of inter-project code clones},author={Svajlenko, Jeffrey and Islam, Judith F and Keivanloo, Iman and Roy, Chanchal K and Mia, Mohammad Mamun},booktitle={2014 IEEE International Conference on Software Maintenance and Evolution},pages={476--480},year={2014},organization={IEEE}}
@inproceedings{wang2020detecting,title={Detecting Code Clones with Graph Neural Network and Flow-Augmented Abstract Syntax Tree},author={Wang, Wenhan and Li, Ge and Ma, Bo and Xia, Xin and Jin, Zhi},booktitle={2020 IEEE 27th International Conference on Software Analysis, Evolution and Reengineering (SANER)},pages={261--271},year={2020},organization={IEEE}}"""
class CodeXGlueCcCloneDetectionBigCloneBenchImpl(TrainValidTestChild): _DESCRIPTION = _DESCRIPTION _CITATION = _CITATION
_FEATURES = { "id": datasets.Value("int32"), # Index of the sample "id1": datasets.Value("int32"), # The first function id "id2": datasets.Value("int32"), # The second function id "func1": datasets.Value("string"), # The full text of the first function "func2": datasets.Value("string"), # The full text of the second function "label": datasets.Value("bool"), # 1 is the functions are not equivalent, 0 otherwise }
_SUPERVISED_KEYS = ["label"]
def generate_urls(self, split_name): yield "index", f"{split_name}.txt" yield "data", "data.jsonl"
def _generate_examples(self, split_name, file_paths): import json
js_all = {}
with open(file_paths["data"], encoding="utf-8") as f: for idx, line in enumerate(f): entry = json.loads(line) js_all[int(entry["idx"])] = entry["func"]
with open(file_paths["index"], encoding="utf-8") as f: for idx, line in enumerate(f): line = line.strip() idx1, idx2, label = [int(i) for i in line.split("\t")] func1 = js_all[idx1] func2 = js_all[idx2]
yield idx, dict(id=idx, id1=idx1, id2=idx2, func1=func1, func2=func2, label=(label == 1))
CLASS_MAPPING = { "CodeXGlueCcCloneDetectionBigCloneBench": CodeXGlueCcCloneDetectionBigCloneBenchImpl,}
class CodeXGlueCcCloneDetectionBigCloneBench(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]: return self.child._split_generators(dl_manager=dl_manager)
def _generate_examples(self, split_name, file_paths): return self.child._generate_examples(split_name, file_paths)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:fa6070bbcf222e8820ffd54394c58fd7415a3047b53a8600c26f13fcc2d3e237size 73274624123version https://git-lfs.github.com/spec/v1oid sha256:3041c74294df1cf3dedef1f1e8cd48ec8b5fac4f9f8ce3f2cf23fa89b8c0e22fsize 73531556123version https://git-lfs.github.com/spec/v1oid sha256:cabaa1a2baec5704465960dbac045ef6a1e9ea321b1282cc00d1d239c2e434d5size 73451480123version https://git-lfs.github.com/spec/v1oid sha256:e697520aa623001cdead968ea33dbedc151eab09a799edc9a97e8f41737d97c2size 135781192123version https://git-lfs.github.com/spec/v1oid sha256:14d12e9a8d668c3653fb40a315a05dc125e21d5a4bcda877784d6948efa8a308size 141782535123version https://git-lfs.github.com/spec/v1oid sha256:25fc34400a381b530c9aa5e018c1b376116a31fb6d957e67c07eb29499391700size 136258214123version https://git-lfs.github.com/spec/v1oid sha256:a9628497bef6e09c95ebec0b1c1420ef26975aa97c544607fb2cc424fc889a54size 135629068123version https://git-lfs.github.com/spec/v1oid sha256:a1f9e30aa06db2a4bc38b2f27e087c930d1339c276890927f66ea860f2619735size 135570525123version https://git-lfs.github.com/spec/v1oid sha256:0987845a65b404e24b5f872a0d317f7dea05ff348494fec1f70facd6cad5107fsize 135937619123version https://git-lfs.github.com/spec/v1oid sha256:78977bd996d61415ba5a264d48df3cb7f37217ebbdc133c1135a570c88e84fe8size 79253146123version https://git-lfs.github.com/spec/v1oid sha256:80d7d626a51e55aafd30f52a2ca3d5d3421f9659dbaa9f89516044e9ce7fbf67size 79386757123version https://git-lfs.github.com/spec/v1oid sha256:cc34145b23539b34f86d05c62119d123287f128933217c7c4f3e92be1a0b3f92size 79418565123456789101112DEFINITIONS = { "default": { "class_name": "CodeXGlueCcCloneDetectionBigCloneBench", "dataset_type": "Code-Code", "description": "CodeXGLUE Clone-detection-BigCloneBench dataset, available at https://github.com/microsoft/CodeXGLUE/tree/main/Code-Code/Clone-detection-BigCloneBench", "dir_name": "Clone-detection-BigCloneBench", "name": "default", "project_url": "https://github.com/madlag/CodeXGLUE/tree/main/Code-Code/Clone-detection-BigCloneBench", "raw_url": "https://raw.githubusercontent.com/madlag/CodeXGLUE/main/Code-Code/Clone-detection-BigCloneBench/dataset", "sizes": {"test": 415416, "train": 901028, "validation": 415416}, }}README.md+14-5
code_x_glue_cc_clone_detection_big_clone_bench.pyDeleted-95
common.pyDeleted-75
data/test-00000-of-00003.parquetAdded+3
data/test-00001-of-00003.parquetAdded+3
data/test-00002-of-00003.parquetAdded+3
data/train-00000-of-00006.parquetAdded+3
data/train-00001-of-00006.parquetAdded+3
data/train-00002-of-00006.parquetAdded+3
data/train-00003-of-00006.parquetAdded+3
data/train-00004-of-00006.parquetAdded+3
data/train-00005-of-00006.parquetAdded+3
data/validation-00000-of-00003.parquetAdded+3
data/validation-00001-of-00003.parquetAdded+3
data/validation-00002-of-00003.parquetAdded+3
generated_definitions.pyDeleted-12