Datasets:
Languages:
English
Multilinguality:
monolingual
Size Categories:
10M<n<100M
Language Creators:
found
Annotations Creators:
no-annotation
Source Datasets:
original
ArXiv:
License:
unknown
Commit
•
a3de9de
1
Parent(s):
6e9b2df
Support streaming bookcorpus dataset (#4564)
Browse filesCommit from https://github.com/huggingface/datasets/commit/bd8fd273000a02bae960a32a92d543ba3eab1bed
- bookcorpus.py +9 -16
bookcorpus.py
CHANGED
@@ -16,9 +16,6 @@
|
|
16 |
# Lint as: python3
|
17 |
"""The BookCorpus dataset."""
|
18 |
|
19 |
-
|
20 |
-
import os
|
21 |
-
|
22 |
import datasets
|
23 |
|
24 |
|
@@ -83,20 +80,16 @@ class Bookcorpus(datasets.GeneratorBasedBuilder):
|
|
83 |
yield ex["text"]
|
84 |
|
85 |
def _split_generators(self, dl_manager):
|
86 |
-
arch_path = dl_manager.
|
87 |
-
|
88 |
return [
|
89 |
-
datasets.SplitGenerator(
|
|
|
|
|
90 |
]
|
91 |
|
92 |
-
def _generate_examples(self,
|
93 |
-
files = [
|
94 |
-
os.path.join(directory, "books_large_p1.txt"),
|
95 |
-
os.path.join(directory, "books_large_p2.txt"),
|
96 |
-
]
|
97 |
_id = 0
|
98 |
-
for
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
_id += 1
|
16 |
# Lint as: python3
|
17 |
"""The BookCorpus dataset."""
|
18 |
|
|
|
|
|
|
|
19 |
import datasets
|
20 |
|
21 |
|
80 |
yield ex["text"]
|
81 |
|
82 |
def _split_generators(self, dl_manager):
|
83 |
+
arch_path = dl_manager.download(URL)
|
|
|
84 |
return [
|
85 |
+
datasets.SplitGenerator(
|
86 |
+
name=datasets.Split.TRAIN, gen_kwargs={"files": dl_manager.iter_archive(arch_path)}
|
87 |
+
),
|
88 |
]
|
89 |
|
90 |
+
def _generate_examples(self, files):
|
|
|
|
|
|
|
|
|
91 |
_id = 0
|
92 |
+
for path, file in files:
|
93 |
+
for line in file:
|
94 |
+
yield _id, {"text": line.decode("utf-8").strip()}
|
95 |
+
_id += 1
|
|