Datasets:
Update enwik8.py
#4
by lucaslingle - opened
34 unmodified lines3536373839404142434445464748495051525354555620 unmodified lines77787980818283848586878889909134 unmodified linesclass Enwik8(datasets.GeneratorBasedBuilder):VERSION = datasets.Version("1.1.0")BUILDER_CONFIGS = [datasets.BuilderConfig(name="enwik8",version=VERSION,description="This version of the dataset contains a split by line version with all content",),datasets.BuilderConfig(name="enwik8-raw",version=VERSION,description="This version of the dataset contains a raw string version split with all content",),]DEFAULT_CONFIG_NAME = "enwik8"def _info(self):20 unmodified linesgen_kwargs={"filepath": os.path.join(data_dir, "enwik8"),"split": "train",},)]# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`def _generate_examples(self, filepath, split):with open(filepath, encoding="utf-8") as f:if self.config.name.endswith("raw"):yield 0, {"text": f.read()}else:for key, line in enumerate(f):yield key, {"text": line.strip()}34 unmodified lines353637383940414243444546474849505120 unmodified lines7273747576777879808182838485868788899091929394959697989910010110234 unmodified linesclass Enwik8(datasets.GeneratorBasedBuilder):VERSION = datasets.Version("2.0.0")BUILDER_CONFIGS = [datasets.BuilderConfig(name="enwik8-standard",version=VERSION,description="This version of the dataset uses the standard split of 90M/5M/5M bytes, and yields a single text blob per split.",)]DEFAULT_CONFIG_NAME = "enwik8-standard"def _info(self):20 unmodified linesgen_kwargs={"filepath": os.path.join(data_dir, "enwik8"),"split": "train","start_index": 0,"end_index": 90_000_000,},),datasets.SplitGenerator(name=datasets.Split.VALIDATION,gen_kwargs={"filepath": os.path.join(data_dir, "enwik8"),"split": "validation","start_index": 90_000_000,"end_index": 95_000_000,},),datasets.SplitGenerator(name=datasets.Split.TEST,gen_kwargs={"filepath": os.path.join(data_dir, "enwik8"),"split": "test","start_index": 95_000_000,"end_index": 100_000_000,},)]# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`def _generate_examples(self, filepath, split, start_index, end_index):with open(filepath, encoding="utf-8") as f:yield 0, {"text": f.read()[start_index:end_index]}
enwik8.py+27-16