anjandash commited on
Commit
8d85efc
1 Parent(s): 692abd3

Upload java-cmpx-v1.py

Browse files
Files changed (1) hide show
  1. java-cmpx-v1.py +58 -0
java-cmpx-v1.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import csv
4
+ import datasets
5
+ csv.field_size_limit(sys.maxsize)
6
+
7
+ _DESCRIPTION = "JEMMA Java CMPX"
8
+ _CITATION = "NOT AVAILABLE"
9
+ _HOMEPAGE = "NOT AVAILABLE"
10
+ _LICENSE = "MIT"
11
+
12
+
13
+ _BASE_TRAIN_FILE_URL = "https://huggingface.co/datasets/giganticode/java-cmpx-v1/resolve/main/Jemma_Properties_Methods_CMPX__Huggingface_Dataset_TRAIN.csv"
14
+ _BASE_TEST_FILE_URL = "https://huggingface.co/datasets/giganticode/java-cmpx-v1/resolve/main/Jemma_Properties_Methods_CMPX__Huggingface_Dataset_TEST.csv"
15
+
16
+ _URLS = {
17
+ "train": _BASE_TRAIN_FILE_URL,
18
+ "test": _BASE_TEST_FILE_URL
19
+ }
20
+
21
+ class JavaCMPX(datasets.GeneratorBasedBuilder):
22
+ """Java CMPX"""
23
+
24
+ def _info(self):
25
+ """Returns Info"""
26
+ return datasets.DatasetInfo(
27
+ description=_DESCRIPTION,
28
+ features=datasets.Features(
29
+ {
30
+ "text": datasets.Value("string"),
31
+ "label": datasets.Value("int32"),
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
+ "text": row[0],
57
+ "label": row[1],
58
+ }