albertvillanova HF staff commited on
Commit
55824d8
1 Parent(s): 07ecd48

Delete loading script

Browse files
code_x_glue_cc_clone_detection_big_clone_bench.py DELETED
@@ -1,95 +0,0 @@
1
- from typing import List
2
-
3
- import datasets
4
-
5
- from .common import TrainValidTestChild
6
- from .generated_definitions import DEFINITIONS
7
-
8
-
9
- _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.
10
- The dataset we use is BigCloneBench and filtered following the paper Detecting Code Clones with Graph Neural Network and Flow-Augmented Abstract Syntax Tree."""
11
-
12
- _CITATION = """@inproceedings{svajlenko2014towards,
13
- title={Towards a big data curated benchmark of inter-project code clones},
14
- author={Svajlenko, Jeffrey and Islam, Judith F and Keivanloo, Iman and Roy, Chanchal K and Mia, Mohammad Mamun},
15
- booktitle={2014 IEEE International Conference on Software Maintenance and Evolution},
16
- pages={476--480},
17
- year={2014},
18
- organization={IEEE}
19
- }
20
-
21
- @inproceedings{wang2020detecting,
22
- title={Detecting Code Clones with Graph Neural Network and Flow-Augmented Abstract Syntax Tree},
23
- author={Wang, Wenhan and Li, Ge and Ma, Bo and Xia, Xin and Jin, Zhi},
24
- booktitle={2020 IEEE 27th International Conference on Software Analysis, Evolution and Reengineering (SANER)},
25
- pages={261--271},
26
- year={2020},
27
- organization={IEEE}
28
- }"""
29
-
30
-
31
- class CodeXGlueCcCloneDetectionBigCloneBenchImpl(TrainValidTestChild):
32
- _DESCRIPTION = _DESCRIPTION
33
- _CITATION = _CITATION
34
-
35
- _FEATURES = {
36
- "id": datasets.Value("int32"), # Index of the sample
37
- "id1": datasets.Value("int32"), # The first function id
38
- "id2": datasets.Value("int32"), # The second function id
39
- "func1": datasets.Value("string"), # The full text of the first function
40
- "func2": datasets.Value("string"), # The full text of the second function
41
- "label": datasets.Value("bool"), # 1 is the functions are not equivalent, 0 otherwise
42
- }
43
-
44
- _SUPERVISED_KEYS = ["label"]
45
-
46
- def generate_urls(self, split_name):
47
- yield "index", f"{split_name}.txt"
48
- yield "data", "data.jsonl"
49
-
50
- def _generate_examples(self, split_name, file_paths):
51
- import json
52
-
53
- js_all = {}
54
-
55
- with open(file_paths["data"], encoding="utf-8") as f:
56
- for idx, line in enumerate(f):
57
- entry = json.loads(line)
58
- js_all[int(entry["idx"])] = entry["func"]
59
-
60
- with open(file_paths["index"], encoding="utf-8") as f:
61
- for idx, line in enumerate(f):
62
- line = line.strip()
63
- idx1, idx2, label = [int(i) for i in line.split("\t")]
64
- func1 = js_all[idx1]
65
- func2 = js_all[idx2]
66
-
67
- yield idx, dict(id=idx, id1=idx1, id2=idx2, func1=func1, func2=func2, label=(label == 1))
68
-
69
-
70
- CLASS_MAPPING = {
71
- "CodeXGlueCcCloneDetectionBigCloneBench": CodeXGlueCcCloneDetectionBigCloneBenchImpl,
72
- }
73
-
74
-
75
- class CodeXGlueCcCloneDetectionBigCloneBench(datasets.GeneratorBasedBuilder):
76
- BUILDER_CONFIG_CLASS = datasets.BuilderConfig
77
- BUILDER_CONFIGS = [
78
- datasets.BuilderConfig(name=name, description=info["description"]) for name, info in DEFINITIONS.items()
79
- ]
80
-
81
- def _info(self):
82
- name = self.config.name
83
- info = DEFINITIONS[name]
84
- if info["class_name"] in CLASS_MAPPING:
85
- self.child = CLASS_MAPPING[info["class_name"]](info)
86
- else:
87
- raise RuntimeError(f"Unknown python class for dataset configuration {name}")
88
- ret = self.child._info()
89
- return ret
90
-
91
- def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
92
- return self.child._split_generators(dl_manager=dl_manager)
93
-
94
- def _generate_examples(self, split_name, file_paths):
95
- return self.child._generate_examples(split_name, file_paths)