Datasets:
Update enwik8.py
#4
by
lucaslingle
- opened
enwik8.py
CHANGED
|
@@ -35,22 +35,17 @@ _URLS = {"source": "http://mattmahoney.net/dc/enwik8.zip"}
|
|
| 35 |
|
| 36 |
class Enwik8(datasets.GeneratorBasedBuilder):
|
| 37 |
|
| 38 |
-
VERSION = datasets.Version("
|
| 39 |
|
| 40 |
BUILDER_CONFIGS = [
|
| 41 |
datasets.BuilderConfig(
|
| 42 |
-
name="enwik8",
|
| 43 |
version=VERSION,
|
| 44 |
-
description="This version of the dataset
|
| 45 |
-
)
|
| 46 |
-
datasets.BuilderConfig(
|
| 47 |
-
name="enwik8-raw",
|
| 48 |
-
version=VERSION,
|
| 49 |
-
description="This version of the dataset contains a raw string version split with all content",
|
| 50 |
-
),
|
| 51 |
]
|
| 52 |
|
| 53 |
-
DEFAULT_CONFIG_NAME = "enwik8"
|
| 54 |
|
| 55 |
def _info(self):
|
| 56 |
|
|
@@ -77,15 +72,31 @@ class Enwik8(datasets.GeneratorBasedBuilder):
|
|
| 77 |
gen_kwargs={
|
| 78 |
"filepath": os.path.join(data_dir, "enwik8"),
|
| 79 |
"split": "train",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
},
|
| 81 |
)
|
| 82 |
]
|
| 83 |
|
| 84 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 85 |
-
def _generate_examples(self, filepath, split):
|
| 86 |
with open(filepath, encoding="utf-8") as f:
|
| 87 |
-
|
| 88 |
-
yield 0, {"text": f.read()}
|
| 89 |
-
else:
|
| 90 |
-
for key, line in enumerate(f):
|
| 91 |
-
yield key, {"text": line.strip()}
|
|
|
|
| 35 |
|
| 36 |
class Enwik8(datasets.GeneratorBasedBuilder):
|
| 37 |
|
| 38 |
+
VERSION = datasets.Version("2.0.0")
|
| 39 |
|
| 40 |
BUILDER_CONFIGS = [
|
| 41 |
datasets.BuilderConfig(
|
| 42 |
+
name="enwik8-standard",
|
| 43 |
version=VERSION,
|
| 44 |
+
description="This version of the dataset uses the standard split of 90M/5M/5M bytes, and yields a single text blob per split.",
|
| 45 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
]
|
| 47 |
|
| 48 |
+
DEFAULT_CONFIG_NAME = "enwik8-standard"
|
| 49 |
|
| 50 |
def _info(self):
|
| 51 |
|
|
|
|
| 72 |
gen_kwargs={
|
| 73 |
"filepath": os.path.join(data_dir, "enwik8"),
|
| 74 |
"split": "train",
|
| 75 |
+
"start_index": 0,
|
| 76 |
+
"end_index": 90_000_000,
|
| 77 |
+
},
|
| 78 |
+
),
|
| 79 |
+
datasets.SplitGenerator(
|
| 80 |
+
name=datasets.Split.VALIDATION,
|
| 81 |
+
gen_kwargs={
|
| 82 |
+
"filepath": os.path.join(data_dir, "enwik8"),
|
| 83 |
+
"split": "validation",
|
| 84 |
+
"start_index": 90_000_000,
|
| 85 |
+
"end_index": 95_000_000,
|
| 86 |
+
},
|
| 87 |
+
),
|
| 88 |
+
datasets.SplitGenerator(
|
| 89 |
+
name=datasets.Split.TEST,
|
| 90 |
+
gen_kwargs={
|
| 91 |
+
"filepath": os.path.join(data_dir, "enwik8"),
|
| 92 |
+
"split": "test",
|
| 93 |
+
"start_index": 95_000_000,
|
| 94 |
+
"end_index": 100_000_000,
|
| 95 |
},
|
| 96 |
)
|
| 97 |
]
|
| 98 |
|
| 99 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 100 |
+
def _generate_examples(self, filepath, split, start_index, end_index):
|
| 101 |
with open(filepath, encoding="utf-8") as f:
|
| 102 |
+
yield 0, {"text": f.read()[start_index:end_index]}
|
|
|
|
|
|
|
|
|
|
|
|