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