wics commited on
Commit
c44761b
·
1 Parent(s): f530a2a

Create ceval.py

Browse files
Files changed (1) hide show
  1. ceval.py +79 -0
ceval.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ import datasets
15
+ import json
16
+
17
+ _CITATION = """
18
+ """
19
+
20
+ _DESCRIPTION = """
21
+ """
22
+
23
+ _HOMEPAGE = ""
24
+
25
+ # TODO: Add the licence for the dataset here if you can find it
26
+ _LICENSE = ""
27
+
28
+ _URLS = {
29
+ "val": "https://raw.githubusercontent.com/wicsaax/ceval/main/ceval_val_all.jsonl",
30
+ }
31
+
32
+
33
+ class ceval(datasets.GeneratorBasedBuilder):
34
+ VERSION = datasets.Version("0.0.1")
35
+
36
+ BUILDER_CONFIGS = [
37
+ datasets.BuilderConfig(
38
+ name="ceval", version=VERSION, description="Chinese eval dataset."
39
+ ),
40
+ ]
41
+
42
+ def _info(self):
43
+ features = datasets.Features(
44
+ {
45
+ "subject": datasets.Value("string"),
46
+ "question": datasets.Value("string"),
47
+ "ideal": datasets.Value("string"),
48
+ "options": datasets.features.Sequence(datasets.Value("string")),
49
+
50
+ }
51
+ )
52
+ return datasets.DatasetInfo(
53
+ description=_DESCRIPTION,
54
+ features=features,
55
+ homepage=_HOMEPAGE,
56
+ license=_LICENSE,
57
+ citation=_CITATION,
58
+ )
59
+
60
+ def _split_generators(self, dl_manager):
61
+ urls = {
62
+ "val": _URLS["val"]
63
+ }
64
+ data_dir = dl_manager.download_and_extract(urls)
65
+ return [
66
+ datasets.SplitGenerator(
67
+ name=datasets.Split.TEST,
68
+ # These kwargs will be passed to _generate_examples
69
+ gen_kwargs={"filepath": data_dir["val"], "split": "val"},
70
+ )
71
+ ]
72
+
73
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
74
+ def _generate_examples(self, filepath, split):
75
+ with open(filepath, 'r', encoding="utf-8") as f:
76
+ print(filepath)
77
+ data = json.loads(f.read())
78
+ for idx, single_data in enumerate(data):
79
+ yield f"{idx}", single_data