File size: 1,862 Bytes
ede0033
 
 
4fbb362
ede0033
 
 
 
 
 
4fbb362
 
ede0033
 
4fbb362
 
 
 
 
 
 
 
 
 
 
 
ede0033
 
 
4fbb362
ede0033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
49
50
51
52
53



from datasets import DatasetInfo, Features, Split, SplitGenerator, GeneratorBasedBuilder, Value
import json

class MyDataset(GeneratorBasedBuilder):
    def _info(self):
        return DatasetInfo(
            features=Features({
                "questions": Value("string"),
                "answers": Value("string")
            }),
            supervised_keys=("questions", "answers"),
            homepage="https://github.com/FreedomIntelligence/Huatuo-26M",
            citation='''
                        @misc{li2023huatuo26m,
                              title={Huatuo-26M, a Large-scale Chinese Medical QA Dataset}, 
                              author={Jianquan Li and Xidong Wang and Xiangbo Wu and Zhiyi Zhang and Xiaolong Xu and Jie Fu and Prayag Tiwari and Xiang Wan and Benyou Wang},
                              year={2023},
                              eprint={2305.01526},
                              archivePrefix={arXiv},
                              primaryClass={cs.CL}
                        }

                        ''',
        )

    def _split_generators(self, dl_manager):

        test_path = "test_datasets.jsonl"

        return [
            SplitGenerator(name=Split.TEST, gen_kwargs={"filepath": test_path}),
        ]

    def _generate_examples(self, filepath):
        with open(filepath, encoding="utf-8") as f:
            for id_, row in enumerate(f):
                # Process your data here and create a dictionary with the features.
                # For example, if your data is in JSON format:
                data = json.loads(row)
                yield id_, {
                    "questions": data["questions"],
                    "answers": data["answers"],
                }

if __name__ == '__main__':
    from datasets import load_dataset

    dataset = load_dataset("my_dataset.py")

    print()