Datasets:
Upload fair-rationales.py
Browse files- fair-rationales.py +11 -17
fair-rationales.py
CHANGED
@@ -58,15 +58,12 @@ class FairRationalesConfig(datasets.BuilderConfig):
|
|
58 |
|
59 |
def __init__(
|
60 |
self,
|
61 |
-
|
62 |
url,
|
63 |
data_url,
|
64 |
-
citation,
|
65 |
-
# data_file,
|
66 |
-
# attentioncheck,
|
67 |
-
# group_id,
|
68 |
-
# originaldata_split,
|
69 |
attributes,
|
|
|
|
|
70 |
label_classes=None,
|
71 |
label_classes_original=None,
|
72 |
**kwargs,
|
@@ -87,16 +84,13 @@ class FairRationalesConfig(datasets.BuilderConfig):
|
|
87 |
**kwargs: keyword arguments forwarded to super.
|
88 |
"""
|
89 |
super(FairRationalesConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
|
90 |
-
self.
|
91 |
self.label_classes = label_classes
|
92 |
self.label_classes_original = label_classes_original
|
93 |
-
# self.attentioncheck = attentioncheck
|
94 |
-
# self.group_id = group_id
|
95 |
-
# self.originaldata_split = originaldata_split
|
96 |
self.attributes = attributes
|
97 |
-
self.data_url = data_url
|
98 |
-
# self.data_file = data_file
|
99 |
self.url = url
|
|
|
|
|
100 |
self.citation = citation
|
101 |
|
102 |
|
@@ -105,7 +99,7 @@ class FairRationales(datasets.GeneratorBasedBuilder):
|
|
105 |
|
106 |
BUILDER_CONFIGS = [
|
107 |
FairRationalesConfig(
|
108 |
-
|
109 |
description=textwrap.dedent(
|
110 |
"""\
|
111 |
The Stanford Sentiment Treebank is a corpus with fully labeled parse trees that allows for a complete analysis of the compositional effects of sentiment in language.
|
@@ -152,7 +146,7 @@ class FairRationales(datasets.GeneratorBasedBuilder):
|
|
152 |
),
|
153 |
),
|
154 |
FairRationalesConfig(
|
155 |
-
|
156 |
description=textwrap.dedent(
|
157 |
"""\
|
158 |
DynaSent is an English-language benchmark task for ternary (positive/negative/neutral) sentiment analysis.
|
@@ -185,7 +179,7 @@ class FairRationales(datasets.GeneratorBasedBuilder):
|
|
185 |
),
|
186 |
),
|
187 |
FairRationalesConfig(
|
188 |
-
|
189 |
description=textwrap.dedent(
|
190 |
"""\
|
191 |
Common Sense Explanations (CoS-E) allows for training language models to automatically
|
@@ -238,7 +232,7 @@ class FairRationales(datasets.GeneratorBasedBuilder):
|
|
238 |
"originaldata_id": datasets.Value("string"),
|
239 |
"annotator_ID": datasets.Value("int64")
|
240 |
}
|
241 |
-
if self.config.
|
242 |
features["label"] = datasets.Value("string")
|
243 |
else:
|
244 |
features["label"] = datasets.ClassLabel(names=self.config.label_classes)
|
@@ -290,7 +284,7 @@ class FairRationales(datasets.GeneratorBasedBuilder):
|
|
290 |
}
|
291 |
for attribute_name, _ in self.config.attributes:
|
292 |
example[attribute_name] = data[attribute_name]
|
293 |
-
if self.config.
|
294 |
example["sst2_id"] = data["sst2_id"]
|
295 |
example["sst2_split"] = data["sst2_split"]
|
296 |
yield id_, example
|
|
|
58 |
|
59 |
def __init__(
|
60 |
self,
|
61 |
+
name,
|
62 |
url,
|
63 |
data_url,
|
|
|
|
|
|
|
|
|
|
|
64 |
attributes,
|
65 |
+
citation,
|
66 |
+
description,
|
67 |
label_classes=None,
|
68 |
label_classes_original=None,
|
69 |
**kwargs,
|
|
|
84 |
**kwargs: keyword arguments forwarded to super.
|
85 |
"""
|
86 |
super(FairRationalesConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
|
87 |
+
self.name = name
|
88 |
self.label_classes = label_classes
|
89 |
self.label_classes_original = label_classes_original
|
|
|
|
|
|
|
90 |
self.attributes = attributes
|
|
|
|
|
91 |
self.url = url
|
92 |
+
self.data_url = data_url
|
93 |
+
self.description = description
|
94 |
self.citation = citation
|
95 |
|
96 |
|
|
|
99 |
|
100 |
BUILDER_CONFIGS = [
|
101 |
FairRationalesConfig(
|
102 |
+
name="sst2",
|
103 |
description=textwrap.dedent(
|
104 |
"""\
|
105 |
The Stanford Sentiment Treebank is a corpus with fully labeled parse trees that allows for a complete analysis of the compositional effects of sentiment in language.
|
|
|
146 |
),
|
147 |
),
|
148 |
FairRationalesConfig(
|
149 |
+
name="dynasent",
|
150 |
description=textwrap.dedent(
|
151 |
"""\
|
152 |
DynaSent is an English-language benchmark task for ternary (positive/negative/neutral) sentiment analysis.
|
|
|
179 |
),
|
180 |
),
|
181 |
FairRationalesConfig(
|
182 |
+
name="cose",
|
183 |
description=textwrap.dedent(
|
184 |
"""\
|
185 |
Common Sense Explanations (CoS-E) allows for training language models to automatically
|
|
|
232 |
"originaldata_id": datasets.Value("string"),
|
233 |
"annotator_ID": datasets.Value("int64")
|
234 |
}
|
235 |
+
if self.config.name == "cose":
|
236 |
features["label"] = datasets.Value("string")
|
237 |
else:
|
238 |
features["label"] = datasets.ClassLabel(names=self.config.label_classes)
|
|
|
284 |
}
|
285 |
for attribute_name, _ in self.config.attributes:
|
286 |
example[attribute_name] = data[attribute_name]
|
287 |
+
if self.config.name == "sst2":
|
288 |
example["sst2_id"] = data["sst2_id"]
|
289 |
example["sst2_split"] = data["sst2_split"]
|
290 |
yield id_, example
|