File size: 1,569 Bytes
cf1900b
 
 
 
 
 
 
 
 
 
 
18371b3
cf1900b
1c621cd
cf1900b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1c621cd
 
 
cf1900b
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import datasets


_CITATION = """\
"""

_DESCRIPTION = """\
This is a test dataset.
"""

_URLS = {
    "train": "https://huggingface.co/datasets/changxin/test_pq/blob/main/another_text.txt",  # absolute
    "dev": "some_text.txt",                                                                 # relative
    "TEST1":"chuishui.txt"
}


class Test(datasets.GeneratorBasedBuilder):
    """SQUAD: The Stanford Question Answering Dataset. Version 1.1."""


    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(
                {
                    "text": datasets.Value("string"),
                }
            ),
            supervised_keys=None,
            homepage="https://huggingface.co/datasets/changxin/test_pq",
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        downloaded_files = dl_manager.download_and_extract(_URLS)

        return [
            datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
            datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
            datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["TEST1"]}),
        ]

    def _generate_examples(self, filepath):
        """This function returns the examples in the raw (text) form."""
        for _id, line in enumerate(open(filepath, encoding="utf-8")):
            yield _id, {"text": line.rstrip()}