Datasets:
Tasks:
Text Retrieval
Modalities:
Text
Formats:
parquet
Sub-tasks:
document-retrieval
Languages:
code
Size:
10K - 100K
License:
Update files from the datasets library (from 1.16.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.16.0
- README.md +1 -0
- code_x_glue_cc_clone_detection_poj104.py +30 -24
README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
annotations_creators:
|
| 3 |
- found
|
| 4 |
language_creators:
|
|
|
|
| 1 |
---
|
| 2 |
+
pretty_name: CodeXGlueCcCloneDetectionPoj104
|
| 3 |
annotations_creators:
|
| 4 |
- found
|
| 5 |
language_creators:
|
code_x_glue_cc_clone_detection_poj104.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import os.path
|
| 3 |
from typing import List
|
| 4 |
|
| 5 |
import datasets
|
|
@@ -34,27 +32,16 @@ class CodeXGlueCcCloneDetectionPoj104Impl(TrainValidTestChild):
|
|
| 34 |
|
| 35 |
SPLIT_RANGES = {"train": (1, 65), "valid": (65, 81), "test": (81, 195)}
|
| 36 |
|
| 37 |
-
def
|
| 38 |
-
yield "data", "programs.tar.gz"
|
| 39 |
-
|
| 40 |
-
def _generate_examples(self, split_name, file_paths):
|
| 41 |
-
def files(path):
|
| 42 |
-
g = os.walk(path)
|
| 43 |
-
file = []
|
| 44 |
-
for path, dir_list, file_list in g:
|
| 45 |
-
for file_name in file_list:
|
| 46 |
-
file.append(os.path.join(path, file_name))
|
| 47 |
-
return file
|
| 48 |
-
|
| 49 |
-
root_path = file_paths["data"]
|
| 50 |
cont = 0
|
| 51 |
-
for
|
| 52 |
-
|
| 53 |
-
|
|
|
|
| 54 |
js = {}
|
| 55 |
-
js["label"] =
|
| 56 |
js["id"] = cont
|
| 57 |
-
js["code"] =
|
| 58 |
yield cont, js
|
| 59 |
cont += 1
|
| 60 |
|
|
@@ -81,7 +68,26 @@ class CodeXGlueCcCloneDetectionPoj104(datasets.GeneratorBasedBuilder):
|
|
| 81 |
return ret
|
| 82 |
|
| 83 |
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from typing import List
|
| 2 |
|
| 3 |
import datasets
|
|
|
|
| 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 |
|
|
|
|
| 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)
|