Commit
·
9cc4798
1
Parent(s):
b7667f0
Create b.py
Browse files
b.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022 the HuggingFace Datasets Authors.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
import os
|
17 |
+
|
18 |
+
import datasets
|
19 |
+
import json
|
20 |
+
|
21 |
+
class DebugConfig(datasets.BuilderConfig):
|
22 |
+
"""BuilderConfig for Winoground."""
|
23 |
+
|
24 |
+
def __init__(self, **kwargs):
|
25 |
+
"""BuilderConfig for Winoground.
|
26 |
+
Args:
|
27 |
+
**kwargs: keyword arguments forwarded to super.
|
28 |
+
"""
|
29 |
+
super(DebugConfig, self).__init__(**kwargs)
|
30 |
+
|
31 |
+
|
32 |
+
class Debug(datasets.GeneratorBasedBuilder):
|
33 |
+
BUILDER_CONFIG_CLASS = DebugConfig
|
34 |
+
|
35 |
+
BUILDER_CONFIGS = [
|
36 |
+
DebugConfig(
|
37 |
+
name="default",
|
38 |
+
),
|
39 |
+
]
|
40 |
+
|
41 |
+
def _info(self):
|
42 |
+
return datasets.DatasetInfo(
|
43 |
+
description=_DESCRIPTION,
|
44 |
+
features=datasets.Features(
|
45 |
+
{
|
46 |
+
"cue": datasets.Value("string"),
|
47 |
+
}
|
48 |
+
),
|
49 |
+
task_templates=[],
|
50 |
+
)
|
51 |
+
|
52 |
+
def _split_generators(self, dl_manager):
|
53 |
+
"""Returns SplitGenerators."""
|
54 |
+
|
55 |
+
hf_auth_token = dl_manager.download_config.use_auth_token
|
56 |
+
if hf_auth_token is None:
|
57 |
+
raise ConnectionError(
|
58 |
+
"Please set use_auth_token=True or use_auth_token='<TOKEN>' to download this dataset"
|
59 |
+
)
|
60 |
+
|
61 |
+
downloaded_files = dl_manager.download_and_extract({
|
62 |
+
"examples": "winogavil_dataset.csv",
|
63 |
+
})
|
64 |
+
|
65 |
+
return [datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs=downloaded_files)]
|
66 |
+
|
67 |
+
def _generate_examples(self, examples):
|
68 |
+
"""Yields examples."""
|
69 |
+
df = pd.read_csv(examples)
|
70 |
+
for r_idx, r in df.iterrows():
|
71 |
+
r_dict = r.to_dict()
|
72 |
+
yield r_idx, r_dict
|