File size: 1,718 Bytes
c106d7c 4c93549 c106d7c |
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
import datasets
import os
import json
_CITATION = """
"""
_DESCRIPTION = """
"""
names = [
"github",
"arxiv",
"wikipedia",
"opensubtitles",
"openwebtext2",
"gutenberg",
"dm-mathematics",
"enron",
"bibliotik",
"pubmed-abstracts",
"youtubesubtitles",
"hackernews",
"commoncrawl",
"europarl",
"uspto",
"freelaw",
"nih-exporter",
"stackexchange",
"pubmed-central",
#"ubuntu-irc", # too small to split 10 ways according to helm code
#"bookcorpus",
#"philpapers",
]
class Builder(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("1.0.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(name=name, version=datasets.Version("1.0.0"), description=_DESCRIPTION)
for name in names
]
def _info(self):
features = datasets.Features(
{
"text": datasets.Value("string"),
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
homepage="",
license="",
citation=_CITATION,
)
def _split_generators(self, dl_manager):
test_json = dl_manager.download(os.path.join(self.config.name, "test.jsonl"))
return [
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={"path": test_json},
),
]
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
def _generate_examples(self, path):
with open(path, encoding="utf-8") as f:
for key, row in enumerate(f):
yield key, json.loads(row)
|