initial commit
Browse files
test.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datasets
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
_CITATION = """\
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
_DESCRIPTION = """\
|
| 8 |
+
This is a test dataset.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
_URL = "https://pastebin.com/raw/HvpE1CnA" # a dummy data file
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class Test(datasets.GeneratorBasedBuilder):
|
| 15 |
+
"""SQUAD: The Stanford Question Answering Dataset. Version 1.1."""
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _info(self):
|
| 19 |
+
return datasets.DatasetInfo(
|
| 20 |
+
description=_DESCRIPTION,
|
| 21 |
+
features=datasets.Features(
|
| 22 |
+
{
|
| 23 |
+
"text": datasets.Value("string"),
|
| 24 |
+
}
|
| 25 |
+
),
|
| 26 |
+
supervised_keys=None,
|
| 27 |
+
homepage="https://huggingface.co/datasets/lhoestq/test",
|
| 28 |
+
citation=_CITATION,
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
def _split_generators(self, dl_manager):
|
| 32 |
+
downloaded_file = dl_manager.download_and_extract(_URL)
|
| 33 |
+
|
| 34 |
+
return [
|
| 35 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_file}),
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
def _generate_examples(self, filepath):
|
| 39 |
+
"""This function returns the examples in the raw (text) form."""
|
| 40 |
+
for _id, line in enumerate(open(filepath, encoding="utf-8")):
|
| 41 |
+
yield _id, {"text": line.rstrip()}
|