albertvillanova HF staff commited on
Commit
ce88055
·
verified ·
1 Parent(s): 4bfc047

Delete loading script

Browse files
code_x_glue_cc_clone_detection_poj104.py DELETED
@@ -1,93 +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 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.
10
- We use POJ-104 dataset on this task."""
11
-
12
- _CITATION = """@inproceedings{mou2016convolutional,
13
- title={Convolutional neural networks over tree structures for programming language processing},
14
- author={Mou, Lili and Li, Ge and Zhang, Lu and Wang, Tao and Jin, Zhi},
15
- booktitle={Proceedings of the Thirtieth AAAI Conference on Artificial Intelligence},
16
- pages={1287--1293},
17
- year={2016}
18
- }"""
19
-
20
-
21
- class CodeXGlueCcCloneDetectionPoj104Impl(TrainValidTestChild):
22
- _DESCRIPTION = _DESCRIPTION
23
- _CITATION = _CITATION
24
-
25
- _FEATURES = {
26
- "id": datasets.Value("int32"), # Index of the sample
27
- "code": datasets.Value("string"), # The full text of the function
28
- "label": datasets.Value("string"), # The id of problem that the source code solves
29
- }
30
-
31
- _SUPERVISED_KEYS = ["label"]
32
-
33
- SPLIT_RANGES = {"train": (1, 65), "valid": (65, 81), "test": (81, 195)}
34
-
35
- def _generate_examples(self, files, split_name):
36
- cont = 0
37
- for path, f in files:
38
- # path are in the format ProgramData/{index}/{filename}
39
- label = int(path.split("/")[1])
40
- if self.SPLIT_RANGES[split_name][0] <= label <= self.SPLIT_RANGES[split_name][1]:
41
- js = {}
42
- js["label"] = str(label)
43
- js["id"] = cont
44
- js["code"] = f.read().decode("latin-1")
45
- yield cont, js
46
- cont += 1
47
-
48
-
49
- CLASS_MAPPING = {
50
- "CodeXGlueCcCloneDetectionPoj104": CodeXGlueCcCloneDetectionPoj104Impl,
51
- }
52
-
53
-
54
- class CodeXGlueCcCloneDetectionPoj104(datasets.GeneratorBasedBuilder):
55
- BUILDER_CONFIG_CLASS = datasets.BuilderConfig
56
- BUILDER_CONFIGS = [
57
- datasets.BuilderConfig(name=name, description=info["description"]) for name, info in DEFINITIONS.items()
58
- ]
59
-
60
- def _info(self):
61
- name = self.config.name
62
- info = DEFINITIONS[name]
63
- if info["class_name"] in CLASS_MAPPING:
64
- self.child = CLASS_MAPPING[info["class_name"]](info)
65
- else:
66
- raise RuntimeError(f"Unknown python class for dataset configuration {name}")
67
- ret = self.child._info()
68
- return ret
69
-
70
- def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
71
- name = self.config.name
72
- info = DEFINITIONS[name]
73
- archive = dl_manager.download(info["raw_url"] + "/programs.tar.gz")
74
- return [
75
- datasets.SplitGenerator(
76
- name=datasets.Split.TRAIN,
77
- # These kwargs will be passed to _generate_examples
78
- gen_kwargs={"files": dl_manager.iter_archive(archive), "split_name": "train"},
79
- ),
80
- datasets.SplitGenerator(
81
- name=datasets.Split.VALIDATION,
82
- # These kwargs will be passed to _generate_examples
83
- gen_kwargs={"files": dl_manager.iter_archive(archive), "split_name": "valid"},
84
- ),
85
- datasets.SplitGenerator(
86
- name=datasets.Split.TEST,
87
- # These kwargs will be passed to _generate_examples
88
- gen_kwargs={"files": dl_manager.iter_archive(archive), "split_name": "test"},
89
- ),
90
- ]
91
-
92
- def _generate_examples(self, files, split_name):
93
- return self.child._generate_examples(files, split_name)