Datasets:
Update enwik8.py
#4
by lucaslingle - opened
34 unmodified lines35363738383940414242434445464748495044454647534849505120 unmodified lines7273747576777879808182838485868788899091929394959697989985100101878810289909134 unmodified lines
class Enwik8(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("1.1.0") VERSION = datasets.Version("2.0.0")
BUILDER_CONFIGS = [ datasets.BuilderConfig( name="enwik8", name="enwik8-standard", 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", ), 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" DEFAULT_CONFIG_NAME = "enwik8-standard"
def _info(self):
20 unmodified lines gen_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): def _generate_examples(self, filepath, split, start_index, end_index): with open(filepath, encoding="utf-8") as f: if self.config.name.endswith("raw"): yield 0, {"text": f.read()} yield 0, {"text": f.read()[start_index:end_index]} else: for key, line in enumerate(f): yield key, {"text": line.strip()}enwik8.py+27-16