Datasets:

Modalities:
Text
Formats:
csv
Libraries:
Datasets
pandas
License:
WeiWei2525 commited on
Commit
8af86ec
·
verified ·
1 Parent(s): 308b864

Upload social_bias_frames.py

Browse files
Files changed (1) hide show
  1. social_bias_frames.py +104 -0
social_bias_frames.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The TensorFlow Datasets Authors and 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
+ # Lint as: python3
17
+ """Social Bias Frames"""
18
+
19
+
20
+ import csv
21
+
22
+ import datasets
23
+
24
+
25
+ _CITATION = """\
26
+ @inproceedings{sap2020socialbiasframes,
27
+ title={Social Bias Frames: Reasoning about Social and Power Implications of Language},
28
+ author={Sap, Maarten and Gabriel, Saadia and Qin, Lianhui and Jurafsky, Dan and Smith, Noah A and Choi, Yejin},
29
+ year={2020},
30
+ booktitle={ACL},
31
+ }
32
+ """
33
+
34
+ _DESCRIPTION = """\
35
+ Social Bias Frames is a new way of representing the biases and offensiveness that are implied in language.
36
+ For example, these frames are meant to distill the implication that "women (candidates) are less qualified"
37
+ behind the statement "we shouldn’t lower our standards to hire more women."
38
+ """
39
+
40
+ _DATA_URL = "https://homes.cs.washington.edu/~msap/social-bias-frames/SBIC.v2.tgz"
41
+
42
+
43
+ class SocialBiasFrames(datasets.GeneratorBasedBuilder):
44
+ """TSocial Bias Frame"""
45
+
46
+ def _info(self):
47
+ return datasets.DatasetInfo(
48
+ description=_DESCRIPTION,
49
+ features=datasets.Features(
50
+ {
51
+ "whoTarget": datasets.Value("string"),
52
+ "intentYN": datasets.Value("string"),
53
+ "sexYN": datasets.Value("string"),
54
+ "sexReason": datasets.Value("string"),
55
+ "offensiveYN": datasets.Value("string"),
56
+ "annotatorGender": datasets.Value("string"),
57
+ "annotatorMinority": datasets.Value("string"),
58
+ "sexPhrase": datasets.Value("string"),
59
+ "speakerMinorityYN": datasets.Value("string"),
60
+ "WorkerId": datasets.Value("string"),
61
+ "HITId": datasets.Value("string"),
62
+ "annotatorPolitics": datasets.Value("string"),
63
+ "annotatorRace": datasets.Value("string"),
64
+ "annotatorAge": datasets.Value("string"),
65
+ "post": datasets.Value("string"),
66
+ "targetMinority": datasets.Value("string"),
67
+ "targetCategory": datasets.Value("string"),
68
+ "targetStereotype": datasets.Value("string"),
69
+ "dataSource": datasets.Value("string"),
70
+ }
71
+ ),
72
+ # No default supervised_keys (as we have to pass both premise
73
+ # and hypothesis as input).
74
+ supervised_keys=None,
75
+ homepage="https://homes.cs.washington.edu/~msap/social-bias-frames/",
76
+ citation=_CITATION,
77
+ )
78
+
79
+ def _split_generators(self, dl_manager):
80
+ archive = dl_manager.download(_DATA_URL)
81
+ return [
82
+ datasets.SplitGenerator(
83
+ name=datasets.Split.TEST,
84
+ gen_kwargs={"filepath": "SBIC.v2.tst.csv", "files": dl_manager.iter_archive(archive)},
85
+ ),
86
+ datasets.SplitGenerator(
87
+ name=datasets.Split.VALIDATION,
88
+ gen_kwargs={"filepath": "SBIC.v2.dev.csv", "files": dl_manager.iter_archive(archive)},
89
+ ),
90
+ datasets.SplitGenerator(
91
+ name=datasets.Split.TRAIN,
92
+ gen_kwargs={"filepath": "SBIC.v2.trn.csv", "files": dl_manager.iter_archive(archive)},
93
+ ),
94
+ ]
95
+
96
+ def _generate_examples(self, filepath, files):
97
+ """This function returns the examples in the raw (text) form."""
98
+ for path, f in files:
99
+ if path == filepath:
100
+ lines = (line.decode("utf-8") for line in f)
101
+ reader = csv.DictReader(lines)
102
+ for idx, row in enumerate(reader):
103
+ yield idx, row
104
+ break