anjandash commited on
Commit
8f4f4fc
1 Parent(s): 1d3cbd3

added support files

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