anjandash commited on
Commit
67669b4
1 Parent(s): 6d45cbf

Upload Dataset Loader Script

Browse files
Files changed (1) hide show
  1. java-cmpx.py +59 -0
java-cmpx.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import ast
3
+ import csv
4
+ import datasets
5
+
6
+ _DESCRIPTION = "JEMMA Java CMPX"
7
+ _CITATION = "NOT AVAILABLE"
8
+ _HOMEPAGE = "NOT AVAILABLE"
9
+ _LICENSE = "MIT"
10
+
11
+
12
+ _BASE_TRAIN_FILE_URL = "https://huggingface.co/datasets/giganticode/java-cmpx/resolve/main/Jemma_Properties_Methods_CMPX__Huggingface_Dataset_TRAIN.csv"
13
+ _BASE_TEST_FILE_URL = "https://huggingface.co/datasets/giganticode/java-cmpx/resolve/main/Jemma_Properties_Methods_CMPX__Huggingface_Dataset_TEST.csv"
14
+
15
+ _URLS = {
16
+ "train": _BASE_TRAIN_FILE_URL,
17
+ "test": _BASE_TEST_FILE_URL
18
+ }
19
+
20
+ class JavaCMPX(datasets.GeneratorBasedBuilder):
21
+ """Java CMPX"""
22
+
23
+ def _info(self):
24
+ """Returns Info"""
25
+ return datasets.DatasetInfo(
26
+ description=_DESCRIPTION,
27
+ features=datasets.Features(
28
+ {
29
+ "method_id": datasets.Value("string"),
30
+ "cyclomatic_complexity": datasets.Value("int32"),
31
+ "method_text": datasets.Value("string")
32
+ }
33
+ ),
34
+ homepage=_HOMEPAGE,
35
+ license=_LICENSE,
36
+ citation=_CITATION,
37
+ )
38
+
39
+ def _split_generators(self, dl_manager):
40
+ """Returns SplitGenerators"""
41
+ data_file = dl_manager.download(_URLS)
42
+ return [
43
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_file["train"]}),
44
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": data_file["test"]}),
45
+ ]
46
+
47
+
48
+ def _generate_examples(self, filepath):
49
+ """Yields Examples"""
50
+ with open(filepath, encoding="utf-8") as f:
51
+ reader = csv.reader(f)
52
+ for id_, row in enumerate(reader):
53
+ if id_ == 0:
54
+ continue
55
+ yield id_, {
56
+ "method_id": row[0],
57
+ "cyclomatic_complexity": row[1],
58
+ "method_text": row[2],
59
+ }