gpucce commited on
Commit
b2fbbce
·
1 Parent(s): 15bdbdd

add download script

Browse files
Files changed (1) hide show
  1. abricot.py +115 -0
abricot.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # TODO: Address all TODOs and remove all explanatory comments
15
+
16
+
17
+ import csv
18
+ import json
19
+ import os
20
+
21
+ import datasets
22
+
23
+
24
+ _CITATION = """"""
25
+
26
+ _DESCRIPTION = """This new dataset is designed to measure Language Models abstractness and inclusiveness understanding in Italian."""
27
+
28
+ _HOMEPAGE = ""
29
+
30
+ _LICENSE = "CC BY 4.0"
31
+
32
+
33
+ _URLS = {
34
+ "abs": "https://github.com/aramelior/ABRICOT-ABstRactness-and-Inclusiveness-in-COntexT"
35
+ }
36
+
37
+
38
+ class abricot(datasets.GeneratorBasedBuilder):
39
+
40
+ VERSION = datasets.Version("0.1.0")
41
+
42
+ BUILDER_CONFIGS = [
43
+ datasets.BuilderConfig(name="abs", version=VERSION, description="Abstraction assessment"),
44
+ # datasets.BuilderConfig(name="ita", version=VERSION, description="Italian Understanding"),
45
+ ]
46
+
47
+ DEFAULT_CONFIG_NAME = "abs"
48
+
49
+ def _info(self):
50
+ if self.config.name == "abs":
51
+ features = datasets.Features(
52
+ # TODO: add after the image col is there "immagine": datasets.Value("string"),
53
+ {
54
+ "ID": datasets.Value("string"),
55
+ "domain": datasets.Value("string"),
56
+ "begin": datasets.Value("int64"),
57
+ "end": datasets.Value("int64"),
58
+ "text": datasets.Value("string"),
59
+ "target_token": datasets.Value("string"),
60
+ "target_lemma": datasets.Value("string"),
61
+ "inc_mean": datasets.Value("float"),
62
+ "inc_std": datasets.Value("float"),
63
+ "abs_mean": datasets.Value("float"),
64
+ "abs_std": datasets.Value("float"),
65
+ "target_number": datasets.Value("string"),
66
+ }
67
+ )
68
+
69
+ return datasets.DatasetInfo(
70
+ description=_DESCRIPTION,
71
+ features=features,
72
+ homepage=_HOMEPAGE,
73
+ license=_LICENSE,
74
+ citation=_CITATION,
75
+ )
76
+
77
+ def _split_generators(self, dl_manager):
78
+
79
+ urls = _URLS[self.config.name]
80
+ data_dir = dl_manager.extract(urls)
81
+ if self.config.name == "abs":
82
+ data_file = "dataset_it.csv"
83
+ return [
84
+ datasets.SplitGenerator(
85
+ name=datasets.Split.VALIDATION,
86
+ # These kwargs will be passed to _generate_examples
87
+ gen_kwargs={
88
+ "filepath": os.path.join(data_dir, data_file),
89
+ "split": "val",
90
+ },
91
+ ),
92
+ ]
93
+
94
+ def _generate_examples(self, filepath, split):
95
+ ds = datasets.load_dataset("csv", data_files=filepath)["train"]
96
+ for key, row in enumerate(ds):
97
+ # data = json.loads(row)
98
+ if self.config.name == "abs":
99
+ # Yields examples as (key, example) tuples
100
+ out = {
101
+ "ID": row["ID"],
102
+ "domain": row["domain"],
103
+ "begin": row["begin"],
104
+ "end": row["end"],
105
+ "text": row["text"],
106
+ "target_token": row["target_token"],
107
+ "target_lemma": row["target_lemma"],
108
+ "inc_mean": row["inc_mean"],
109
+ "inc_std": row["inc_std"],
110
+ "abs_mean": row["abs_mean"],
111
+ "abs_std": row["abs_std"],
112
+ "target_number": row["target_number"],
113
+ }
114
+
115
+ yield key, out