Use GeneratorBasedBuilder
Browse files
wikipedia_snippets_streamed.py
CHANGED
|
@@ -24,7 +24,7 @@ _LICENSE = (
|
|
| 24 |
)
|
| 25 |
|
| 26 |
|
| 27 |
-
class WikipediaSnippetsStreamed(datasets.
|
| 28 |
"""Bengali wikipedia from 03/20/2021"""
|
| 29 |
|
| 30 |
def _info(self):
|
|
@@ -49,10 +49,10 @@ class WikipediaSnippetsStreamed(datasets.ArrowBasedBuilder):
|
|
| 49 |
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_file}),
|
| 50 |
]
|
| 51 |
|
| 52 |
-
def
|
| 53 |
logger.info("generating examples from = %s", filepath)
|
| 54 |
with open(filepath, "rb") as f:
|
| 55 |
pf = pq.ParquetFile(f)
|
| 56 |
for i in range(pf.num_row_groups):
|
| 57 |
id_ = f"{filepath}_{i}"
|
| 58 |
-
yield id_, pf.read_row_group(i)
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
|
| 27 |
+
class WikipediaSnippetsStreamed(datasets.GeneratorBasedBuilder):
|
| 28 |
"""Bengali wikipedia from 03/20/2021"""
|
| 29 |
|
| 30 |
def _info(self):
|
|
|
|
| 49 |
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_file}),
|
| 50 |
]
|
| 51 |
|
| 52 |
+
def _generate_examples(self, filepath):
|
| 53 |
logger.info("generating examples from = %s", filepath)
|
| 54 |
with open(filepath, "rb") as f:
|
| 55 |
pf = pq.ParquetFile(f)
|
| 56 |
for i in range(pf.num_row_groups):
|
| 57 |
id_ = f"{filepath}_{i}"
|
| 58 |
+
yield id_, pf.read_row_group(i).to_pydict()
|