Datasets:
Tasks:
Text Classification
Languages:
English
Size:
n<1K
ArXiv:
Tags:
Hate Speech Detection
License:
Commit
•
f8dec51
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +199 -0
- dataset_infos.json +1 -0
- dummy/binary/1.0.0/dummy_data.zip +3 -0
- dummy/multilabel/1.0.0/dummy_data.zip +3 -0
- ethos.py +159 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- crowdsourced
|
4 |
+
- expert-generated
|
5 |
+
language_creators:
|
6 |
+
- found, other
|
7 |
+
languages:
|
8 |
+
- en
|
9 |
+
licenses:
|
10 |
+
- agpl-3-0-or-later
|
11 |
+
multilinguality:
|
12 |
+
- monolingual
|
13 |
+
size_categories:
|
14 |
+
- n<1K
|
15 |
+
source_datasets:
|
16 |
+
- original
|
17 |
+
task_categories:
|
18 |
+
- text-classification
|
19 |
+
task_ids:
|
20 |
+
binary:
|
21 |
+
- sentiment-classification
|
22 |
+
- text-classification-other-Hate Speech Detection
|
23 |
+
multilabel:
|
24 |
+
- multi-label-classification
|
25 |
+
- sentiment-classification
|
26 |
+
- text-classification-other-Hate Speech Detection
|
27 |
+
---
|
28 |
+
|
29 |
+
# Dataset Card for Ethos
|
30 |
+
|
31 |
+
## Table of Contents
|
32 |
+
- [Dataset Description](#dataset-description)
|
33 |
+
- [Dataset Summary](#dataset-summary)
|
34 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
35 |
+
- [Languages](#languages)
|
36 |
+
- [Dataset Structure](#dataset-structure)
|
37 |
+
- [Data Instances](#data-instances)
|
38 |
+
- [Data Fields](#data-fields)
|
39 |
+
- [Data Splits](#data-splits)
|
40 |
+
- [Dataset Creation](#dataset-creation)
|
41 |
+
- [Curation Rationale](#curation-rationale)
|
42 |
+
- [Source Data](#source-data)
|
43 |
+
- [Annotations](#annotations)
|
44 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
45 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
46 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
47 |
+
- [Discussion of Biases](#discussion-of-biases)
|
48 |
+
- [Other Known Limitations](#other-known-limitations)
|
49 |
+
- [Additional Information](#additional-information)
|
50 |
+
- [Dataset Curators](#dataset-curators)
|
51 |
+
- [Licensing Information](#licensing-information)
|
52 |
+
- [Citation Information](#citation-information)
|
53 |
+
|
54 |
+
## Dataset Description
|
55 |
+
|
56 |
+
- **Homepage:** [ETHOS Hate Speech Dataset](https://github.com/intelligence-csd-auth-gr/Ethos-Hate-Speech-Dataset)
|
57 |
+
- **Repository:**[ETHOS Hate Speech Dataset](https://github.com/intelligence-csd-auth-gr/Ethos-Hate-Speech-Dataset)
|
58 |
+
- **Paper:**[ETHOS: an Online Hate Speech Detection Dataset](https://arxiv.org/abs/2006.08328)
|
59 |
+
|
60 |
+
### Dataset Summary
|
61 |
+
|
62 |
+
ETHOS: onlinE haTe speecH detectiOn dataSet. This repository contains a dataset for hate speech detection on social media platforms, called Ethos. There are two variations of the dataset:
|
63 |
+
- **Ethos_Dataset_Binary**: contains 998 comments in the dataset alongside with a label about hate speech *presence* or *absence*. 565 of them do not contain hate speech, while the rest of them, 433, contain.
|
64 |
+
- **Ethos_Dataset_Multi_Label** which contains 8 labels for the 433 comments with hate speech content. These labels are *violence* (if it incites (1) or not (0) violence), *directed_vs_general* (if it is directed to a person (1) or a group (0)), and 6 labels about the category of hate speech like, *gender*, *race*, *national_origin*, *disability*, *religion* and *sexual_orientation*.
|
65 |
+
|
66 |
+
***Ethos /ˈiːθɒs/***
|
67 |
+
is a Greek word meaning “character” that is used to describe the guiding beliefs or ideals that characterize a community, nation, or ideology. The Greeks also used this word to refer to the power of music to influence emotions, behaviors, and even morals.
|
68 |
+
|
69 |
+
### Supported Tasks and Leaderboards
|
70 |
+
|
71 |
+
[More Information Needed]
|
72 |
+
- `text-classification-other-Hate Speech Detection`, `sentiment-classification`,`multi-label-classification`: The dataset can be used to train a model for hate speech detection. Moreover, it can be used as a benchmark dataset for multi label classification algorithms.
|
73 |
+
|
74 |
+
### Languages
|
75 |
+
|
76 |
+
The text in the dataset is in English.
|
77 |
+
|
78 |
+
## Dataset Structure
|
79 |
+
|
80 |
+
### Data Instances
|
81 |
+
|
82 |
+
A typical data point in the binary version comprises a comment, with a `text` containing the text and a `label` describing if a comment contains hate speech content (1 - hate-speech) or not (0 - non-hate-speech). In the multilabel version more labels like *violence* (if it incites (1) or not (0) violence), *directed_vs_general* (if it is directed to a person (1) or a group (0)), and 6 labels about the category of hate speech like, *gender*, *race*, *national_origin*, *disability*, *religion* and *sexual_orientation* are appearing.
|
83 |
+
|
84 |
+
An example from the binary version, which is offensive, but it does not contain hate speech content:
|
85 |
+
```
|
86 |
+
{'text': 'What the fuck stupid people !!!',
|
87 |
+
'label': '0'
|
88 |
+
}
|
89 |
+
```
|
90 |
+
|
91 |
+
An example from the multi-label version, which contains hate speech content towards women (gender):
|
92 |
+
```
|
93 |
+
{'text': 'You should know women's sports are a joke',
|
94 |
+
`violence`: 0,
|
95 |
+
`directed_vs_generalized`: 0,
|
96 |
+
`gender`: 1,
|
97 |
+
`race`: 0,
|
98 |
+
`national_origin`: 0,
|
99 |
+
`disability`: 0,
|
100 |
+
`religion`: 0,
|
101 |
+
`sexual_orientation`: 0
|
102 |
+
}
|
103 |
+
```
|
104 |
+
|
105 |
+
|
106 |
+
### Data Fields
|
107 |
+
|
108 |
+
Ethos Binary:
|
109 |
+
- `text`: a `string` feature containing the text of the comment.
|
110 |
+
- `label`: a classification label, with possible values including `no_hate_speech`, `hate_speech`.
|
111 |
+
|
112 |
+
Ethis Multilabel:
|
113 |
+
- `text`: a `string` feature containing the text of the comment.
|
114 |
+
- `violence`: a classification label, with possible values including `not_violent`, `violent`.
|
115 |
+
- `directed_vs_generalized`: a classification label, with possible values including `generalized`, `directed`.
|
116 |
+
- `gender`: a classification label, with possible values including `false`, `true`.
|
117 |
+
- `race`: a classification label, with possible values including `false`, `true`.
|
118 |
+
- `national_origin`: a classification label, with possible values including `false`, `true`.
|
119 |
+
- `disability`: a classification label, with possible values including `false`, `true`.
|
120 |
+
- `religion`: a classification label, with possible values including `false`, `true`.
|
121 |
+
- `sexual_orientation`: a classification label, with possible values including `false`, `true`.
|
122 |
+
|
123 |
+
### Data Splits
|
124 |
+
|
125 |
+
The data is split into binary and multilabel. Multilabel is a subset of the binary version.
|
126 |
+
|
127 |
+
| | Instances | Labels |
|
128 |
+
| ----- | ------ | ----- |
|
129 |
+
| binary | 998 | 1 |
|
130 |
+
| multilabel | 433 | 8 |
|
131 |
+
|
132 |
+
## Dataset Creation
|
133 |
+
|
134 |
+
### Curation Rationale
|
135 |
+
|
136 |
+
The dataset was build by gathering online comments in Youtube videos and reddit comments, from videos and subreddits which may attract hate speech content.
|
137 |
+
|
138 |
+
### Source Data
|
139 |
+
|
140 |
+
#### Initial Data Collection and Normalization
|
141 |
+
|
142 |
+
The initial data we used are from the hatebusters platform: [Original data used](https://intelligence.csd.auth.gr/topics/hate-speech-detection/), but they were not included in this dataset
|
143 |
+
|
144 |
+
#### Who are the source language producers?
|
145 |
+
|
146 |
+
The language producers are users of reddit and Youtube. More informations can be found in this paper: [ETHOS: an Online Hate Speech Detection Dataset](https://arxiv.org/abs/2006.08328)
|
147 |
+
|
148 |
+
### Annotations
|
149 |
+
|
150 |
+
#### Annotation process
|
151 |
+
|
152 |
+
The annotation process is detailed in the third section of this paper: [ETHOS: an Online Hate Speech Detection Dataset](https://arxiv.org/abs/2006.08328)
|
153 |
+
|
154 |
+
#### Who are the annotators?
|
155 |
+
|
156 |
+
Originally anotated by Ioannis Mollas and validated through the Figure8 platform (APEN).
|
157 |
+
|
158 |
+
### Personal and Sensitive Information
|
159 |
+
|
160 |
+
No personal and sensitive information included in the dataset.
|
161 |
+
|
162 |
+
## Considerations for Using the Data
|
163 |
+
|
164 |
+
### Social Impact of Dataset
|
165 |
+
|
166 |
+
This dataset will help on the evolution of the automated hate speech detection tools. Those tools have great impact on preventing social issues.
|
167 |
+
|
168 |
+
### Discussion of Biases
|
169 |
+
|
170 |
+
This dataset tries to be unbiased towards its classes and labels.
|
171 |
+
|
172 |
+
### Other Known Limitations
|
173 |
+
|
174 |
+
The dataset is relatively small and should be used combined with larger datasets.
|
175 |
+
|
176 |
+
## Additional Information
|
177 |
+
|
178 |
+
### Dataset Curators
|
179 |
+
|
180 |
+
The dataset was initially created by [Intelligent Systems Lab](https://intelligence.csd.auth.gr).
|
181 |
+
|
182 |
+
### Licensing Information
|
183 |
+
|
184 |
+
The licensing status of the datasets is [GNU GPLv3](https://choosealicense.com/licenses/gpl-3.0/).
|
185 |
+
|
186 |
+
### Citation Information
|
187 |
+
```
|
188 |
+
@misc{mollas2020ethos,
|
189 |
+
title={ETHOS: an Online Hate Speech Detection Dataset},
|
190 |
+
author={Ioannis Mollas and Zoe Chrysopoulou and Stamatis Karlos and Grigorios Tsoumakas},
|
191 |
+
year={2020},
|
192 |
+
eprint={2006.08328},
|
193 |
+
archivePrefix={arXiv},
|
194 |
+
primaryClass={cs.CL}
|
195 |
+
}
|
196 |
+
```
|
197 |
+
|
198 |
+
## License
|
199 |
+
[GNU GPLv3](https://choosealicense.com/licenses/gpl-3.0/)
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"binary": {"description": "", "citation": "\n@misc{mollas2020ethos,\n title={ETHOS: an Online Hate Speech Detection Dataset},\n author={Ioannis Mollas and Zoe Chrysopoulou and Stamatis Karlos and Grigorios Tsoumakas},\n year={2020},\n eprint={2006.08328},\n archivePrefix={arXiv},\n primaryClass={cs.CL}\n}\n ", "homepage": "https://github.com/intelligence-csd-auth-gr/Ethos-Hate-Speech-Dataset/tree/masterethos/ethos_data", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 2, "names": ["no_hate_speech", "hate_speech"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "builder_name": "ethos", "config_name": "binary", "version": {"version_str": "1.0.0", "description": "", "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 124823, "num_examples": 998, "dataset_name": "ethos"}}, "download_checksums": {"https://raw.githubusercontent.com/intelligence-csd-auth-gr/Ethos-Hate-Speech-Dataset/master/ethos/ethos_data/Ethos_Dataset_Binary.csv": {"num_bytes": 123919, "checksum": "0cd0050c2592afcb5eca5876df485ca15cda9d7d16fe32c269857260fd10d96c"}}, "download_size": 123919, "post_processing_size": null, "dataset_size": 124823, "size_in_bytes": 248742}, "multilabel": {"description": "", "citation": "\n@misc{mollas2020ethos,\n title={ETHOS: an Online Hate Speech Detection Dataset},\n author={Ioannis Mollas and Zoe Chrysopoulou and Stamatis Karlos and Grigorios Tsoumakas},\n year={2020},\n eprint={2006.08328},\n archivePrefix={arXiv},\n primaryClass={cs.CL}\n}\n ", "homepage": "https://github.com/intelligence-csd-auth-gr/Ethos-Hate-Speech-Dataset/tree/masterethos/ethos_data", "license": "", "features": {"text": {"dtype": "string", "id": null, "_type": "Value"}, "violence": {"num_classes": 2, "names": ["not_violent", "violent"], "names_file": null, "id": null, "_type": "ClassLabel"}, "directed_vs_generalized": {"num_classes": 2, "names": ["generalied", "directed"], "names_file": null, "id": null, "_type": "ClassLabel"}, "gender": {"num_classes": 2, "names": ["false", "true"], "names_file": null, "id": null, "_type": "ClassLabel"}, "race": {"num_classes": 2, "names": ["false", "true"], "names_file": null, "id": null, "_type": "ClassLabel"}, "national_origin": {"num_classes": 2, "names": ["false", "true"], "names_file": null, "id": null, "_type": "ClassLabel"}, "disability": {"num_classes": 2, "names": ["false", "true"], "names_file": null, "id": null, "_type": "ClassLabel"}, "religion": {"num_classes": 2, "names": ["false", "true"], "names_file": null, "id": null, "_type": "ClassLabel"}, "sexual_orientation": {"num_classes": 2, "names": ["false", "true"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "builder_name": "ethos", "config_name": "multilabel", "version": {"version_str": "1.0.0", "description": "", "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 79112, "num_examples": 433, "dataset_name": "ethos"}}, "download_checksums": {"https://raw.githubusercontent.com/intelligence-csd-auth-gr/Ethos-Hate-Speech-Dataset/master/ethos/ethos_data/Ethos_Dataset_Multi_Label.csv": {"num_bytes": 62836, "checksum": "488c72a1582abdaf489a6e9eceeebba505447a00a25bd02e72fd6a56f9a3d83d"}}, "download_size": 62836, "post_processing_size": null, "dataset_size": 79112, "size_in_bytes": 141948}}
|
dummy/binary/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:46d353219fb246199191ab04b89c201139ed72d7c849550962332396e718057f
|
3 |
+
size 439
|
dummy/multilabel/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4fd529dabdbebd4738c234ebde0981366be6b9a2394ca0a2ede664493ce6ee64
|
3 |
+
size 550
|
ethos.py
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Ethos dataset"""
|
2 |
+
|
3 |
+
from __future__ import absolute_import, division, print_function
|
4 |
+
|
5 |
+
import logging
|
6 |
+
|
7 |
+
import pandas as pd
|
8 |
+
|
9 |
+
import datasets
|
10 |
+
|
11 |
+
|
12 |
+
_CITATION = """
|
13 |
+
@misc{mollas2020ethos,
|
14 |
+
title={ETHOS: an Online Hate Speech Detection Dataset},
|
15 |
+
author={Ioannis Mollas and Zoe Chrysopoulou and Stamatis Karlos and Grigorios Tsoumakas},
|
16 |
+
year={2020},
|
17 |
+
eprint={2006.08328},
|
18 |
+
archivePrefix={arXiv},
|
19 |
+
primaryClass={cs.CL}
|
20 |
+
}
|
21 |
+
"""
|
22 |
+
|
23 |
+
_DESCRIPTION = """
|
24 |
+
|
25 |
+
ETHOS: onlinE haTe speecH detectiOn dataSet. This repository contains a dataset for hate speech
|
26 |
+
detection on social media platforms, called Ethos. There are two variations of the dataset:
|
27 |
+
|
28 |
+
Ethos_Dataset_Binary: contains 998 comments in the dataset alongside with a label
|
29 |
+
about hate speech presence or absence. 565 of them do not contain hate speech,
|
30 |
+
while the rest of them, 433, contain.
|
31 |
+
|
32 |
+
Ethos_Dataset_Multi_Label: which contains 8 labels for the 433 comments with hate speech content.
|
33 |
+
These labels are violence (if it incites (1) or not (0) violence), directed_vs_general (if it is
|
34 |
+
directed to a person (1) or a group (0)), and 6 labels about the category of hate speech like,
|
35 |
+
gender, race, national_origin, disability, religion and sexual_orientation.
|
36 |
+
"""
|
37 |
+
|
38 |
+
_URL = "https://github.com/intelligence-csd-auth-gr/Ethos-Hate-Speech-Dataset"
|
39 |
+
|
40 |
+
|
41 |
+
class EthosConfig(datasets.BuilderConfig):
|
42 |
+
"""BuilderConfig for Ethos."""
|
43 |
+
|
44 |
+
def __init__(self, variation="binary", **kwargs):
|
45 |
+
"""Constructs an EthosDataset.
|
46 |
+
|
47 |
+
Args:
|
48 |
+
variation: can be binary or multilabel
|
49 |
+
**kwargs: keyword arguments forwarded to super.
|
50 |
+
"""
|
51 |
+
if variation.lower() == "binary":
|
52 |
+
self.variation = "binary"
|
53 |
+
elif variation.lower() == "multilabel":
|
54 |
+
self.variation = "multilabel"
|
55 |
+
else:
|
56 |
+
logging.warning("Wrong variation. Could be either 'binary' or 'multilabel', using 'binary' instead.")
|
57 |
+
self.variation = "binary"
|
58 |
+
super(EthosConfig, self).__init__(**kwargs)
|
59 |
+
|
60 |
+
|
61 |
+
class Ethos(datasets.GeneratorBasedBuilder):
|
62 |
+
BUILDER_CONFIG_CLASS = EthosConfig
|
63 |
+
|
64 |
+
BUILDER_CONFIGS = [
|
65 |
+
EthosConfig(
|
66 |
+
name="binary",
|
67 |
+
version=datasets.Version("1.0.0", ""),
|
68 |
+
description="Ethos Binary",
|
69 |
+
variation="binary",
|
70 |
+
),
|
71 |
+
EthosConfig(
|
72 |
+
name="multilabel",
|
73 |
+
version=datasets.Version("1.0.0", ""),
|
74 |
+
description="Ethos Multi Label",
|
75 |
+
variation="multilabel",
|
76 |
+
),
|
77 |
+
]
|
78 |
+
|
79 |
+
def _info(self):
|
80 |
+
if self.config.variation == "binary":
|
81 |
+
f = datasets.Features(
|
82 |
+
{
|
83 |
+
"text": datasets.Value("string"),
|
84 |
+
"label": datasets.features.ClassLabel(names=["no_hate_speech", "hate_speech"]),
|
85 |
+
}
|
86 |
+
)
|
87 |
+
else:
|
88 |
+
f = datasets.Features(
|
89 |
+
{
|
90 |
+
"text": datasets.Value("string"),
|
91 |
+
"violence": datasets.ClassLabel(names=["not_violent", "violent"]),
|
92 |
+
"directed_vs_generalized": datasets.ClassLabel(names=["generalied", "directed"]),
|
93 |
+
"gender": datasets.ClassLabel(names=["false", "true"]),
|
94 |
+
"race": datasets.ClassLabel(names=["false", "true"]),
|
95 |
+
"national_origin": datasets.ClassLabel(names=["false", "true"]),
|
96 |
+
"disability": datasets.ClassLabel(names=["false", "true"]),
|
97 |
+
"religion": datasets.ClassLabel(names=["false", "true"]),
|
98 |
+
"sexual_orientation": datasets.ClassLabel(names=["false", "true"]),
|
99 |
+
}
|
100 |
+
)
|
101 |
+
return datasets.DatasetInfo(
|
102 |
+
features=f,
|
103 |
+
supervised_keys=None,
|
104 |
+
homepage="https://github.com/intelligence-csd-auth-gr/Ethos-Hate-Speech-Dataset/tree/masterethos/ethos_data",
|
105 |
+
citation=_CITATION,
|
106 |
+
)
|
107 |
+
|
108 |
+
def _split_generators(self, dl_manager):
|
109 |
+
if self.config.variation == "binary":
|
110 |
+
url = {
|
111 |
+
"train": "https://raw.githubusercontent.com/intelligence-csd-auth-gr/Ethos-Hate-Speech-Dataset"
|
112 |
+
"/master/ethos/ethos_data/Ethos_Dataset_Binary.csv"
|
113 |
+
}
|
114 |
+
else:
|
115 |
+
url = {
|
116 |
+
"train": "https://raw.githubusercontent.com/intelligence-csd-auth-gr/Ethos-Hate-Speech-Dataset"
|
117 |
+
"/master/ethos/ethos_data/Ethos_Dataset_Multi_Label.csv"
|
118 |
+
}
|
119 |
+
downloaded_files = dl_manager.download_and_extract(url)
|
120 |
+
|
121 |
+
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]})]
|
122 |
+
|
123 |
+
def _generate_examples(self, filepath):
|
124 |
+
"""Yields examples."""
|
125 |
+
|
126 |
+
data = pd.read_csv(filepath, delimiter=";")
|
127 |
+
if self.config.variation == "binary":
|
128 |
+
|
129 |
+
x = data["comment"].values
|
130 |
+
y = [1 if i >= 0.5 else 0 for i in data["isHate"].values]
|
131 |
+
class_names = ["no_hate_speech", "hate_speech"]
|
132 |
+
for i in range(len(x)):
|
133 |
+
_id = i
|
134 |
+
yield _id, {"text": x[i], "label": class_names[y[i]]}
|
135 |
+
else:
|
136 |
+
x = data["comment"].values
|
137 |
+
y_temp = data.loc[:, data.columns != "comment"].values
|
138 |
+
y = []
|
139 |
+
for yt in y_temp:
|
140 |
+
yi = []
|
141 |
+
for i in yt:
|
142 |
+
if i >= 0.5:
|
143 |
+
yi.append(int(1))
|
144 |
+
else:
|
145 |
+
yi.append(int(0))
|
146 |
+
y.append(yi)
|
147 |
+
for i in range(len(x)):
|
148 |
+
_id = i
|
149 |
+
yield _id, {
|
150 |
+
"text": x[i],
|
151 |
+
"violence": y[i][0],
|
152 |
+
"directed_vs_generalized": y[i][1],
|
153 |
+
"gender": y[i][2],
|
154 |
+
"race": y[i][3],
|
155 |
+
"national_origin": y[i][4],
|
156 |
+
"disability": y[i][5],
|
157 |
+
"religion": y[i][6],
|
158 |
+
"sexual_orientation": y[i][7],
|
159 |
+
}
|