Datasets:
Delete kmhas_Korean_hatespeech.py
Browse files- kmhas_Korean_hatespeech.py +0 -116
kmhas_Korean_hatespeech.py
DELETED
@@ -1,116 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
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 |
-
"""K-MHaS Korean Multi-label Hate Speech Dataset"""
|
16 |
-
|
17 |
-
|
18 |
-
import csv
|
19 |
-
|
20 |
-
import datasets
|
21 |
-
from datasets.tasks import TextClassification
|
22 |
-
|
23 |
-
_CITATION = """\
|
24 |
-
@inproceedings{lee-etal-2022-k,
|
25 |
-
title = "K-{MH}a{S}: A Multi-label Hate Speech Detection Dataset in {K}orean Online News Comment",
|
26 |
-
author = "Lee, Jean and
|
27 |
-
Lim, Taejun and
|
28 |
-
Lee, Heejun and
|
29 |
-
Jo, Bogeun and
|
30 |
-
Kim, Yangsok and
|
31 |
-
Yoon, Heegeun and
|
32 |
-
Han, Soyeon Caren",
|
33 |
-
booktitle = "Proceedings of the 29th International Conference on Computational Linguistics",
|
34 |
-
month = oct,
|
35 |
-
year = "2022",
|
36 |
-
address = "Gyeongju, Republic of Korea",
|
37 |
-
publisher = "International Committee on Computational Linguistics",
|
38 |
-
url = "https://aclanthology.org/2022.coling-1.311",
|
39 |
-
pages = "3530--3538",
|
40 |
-
abstract = "Online hate speech detection has become an important issue due to the growth of online content, but resources in languages other than English are extremely limited. We introduce K-MHaS, a new multi-label dataset for hate speech detection that effectively handles Korean language patterns. The dataset consists of 109k utterances from news comments and provides a multi-label classification using 1 to 4 labels, and handles subjectivity and intersectionality. We evaluate strong baselines on K-MHaS. KR-BERT with a sub-character tokenizer outperforms others, recognizing decomposed characters in each hate speech class.",
|
41 |
-
}
|
42 |
-
"""
|
43 |
-
|
44 |
-
_DESCRIPTION = """\
|
45 |
-
The K-MHaS (Korean Multi-label Hate Speech) dataset contains 109k utterances from Korean online news comments labeled with 8 fine-grained hate speech classes or Not Hate Speech class.
|
46 |
-
The fine-grained hate speech classes are politics, origin, physical, age, gender, religion, race, and profanity and these categories are selected in order to reflect the social and historical context.
|
47 |
-
"""
|
48 |
-
|
49 |
-
_HOMEPAGE = "https://github.com/adlnlp/K-MHaS"
|
50 |
-
|
51 |
-
_LICENSE = "cc-by-sa-4.0"
|
52 |
-
|
53 |
-
_TRAIN_DOWNLOAD_URL = "https://raw.githubusercontent.com/adlnlp/K-MHaS/main/data/kmhas_train.txt"
|
54 |
-
_VALIDATION_DOWNLOAD_URL = "https://raw.githubusercontent.com/adlnlp/K-MHaS/main/data/kmhas_valid.txt"
|
55 |
-
_TEST_DOWNLOAD_URL = "https://raw.githubusercontent.com/adlnlp/K-MHaS/main/data/kmhas_test.txt"
|
56 |
-
|
57 |
-
_CLASS_NAMES = [
|
58 |
-
"origin",
|
59 |
-
"physical",
|
60 |
-
"politics",
|
61 |
-
"profanity",
|
62 |
-
"age",
|
63 |
-
"gender",
|
64 |
-
"race",
|
65 |
-
"religion",
|
66 |
-
"not hate speech"
|
67 |
-
]
|
68 |
-
|
69 |
-
class Kmhas(datasets.GeneratorBasedBuilder):
|
70 |
-
"""K-MHaS Korean Multi-label Hate Speech Dataset"""
|
71 |
-
|
72 |
-
VERSION = datasets.Version("1.0.0")
|
73 |
-
|
74 |
-
def _info(self):
|
75 |
-
|
76 |
-
features = datasets.Features(
|
77 |
-
{
|
78 |
-
"document": datasets.Value("string"),
|
79 |
-
"label": datasets.Sequence(datasets.ClassLabel(names=_CLASS_NAMES))
|
80 |
-
}
|
81 |
-
)
|
82 |
-
|
83 |
-
return datasets.DatasetInfo(
|
84 |
-
description=_DESCRIPTION,
|
85 |
-
features=features,
|
86 |
-
homepage=_HOMEPAGE,
|
87 |
-
license=_LICENSE,
|
88 |
-
citation=_CITATION,
|
89 |
-
task_templates=[TextClassification(text_column="document", label_column="label")],
|
90 |
-
)
|
91 |
-
|
92 |
-
def _split_generators(self, dl_manager):
|
93 |
-
train_path = dl_manager.download_and_extract(_TRAIN_DOWNLOAD_URL)
|
94 |
-
validation_path = dl_manager.download_and_extract(_VALIDATION_DOWNLOAD_URL)
|
95 |
-
test_path = dl_manager.download_and_extract(_TEST_DOWNLOAD_URL)
|
96 |
-
return [
|
97 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
|
98 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": validation_path}),
|
99 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}),
|
100 |
-
]
|
101 |
-
|
102 |
-
def _generate_examples(self, filepath):
|
103 |
-
"""Generate K-MHaS Korean Multi-label Hate Speech examples"""
|
104 |
-
|
105 |
-
with open(filepath, 'r') as f:
|
106 |
-
lines = f.readlines()[1:]
|
107 |
-
|
108 |
-
for index, line in enumerate(lines):
|
109 |
-
row = line.strip().split('\t')
|
110 |
-
sentence = row[0]
|
111 |
-
label = [int(ind) for ind in row[1].split(",")]
|
112 |
-
yield index, {
|
113 |
-
"document" : sentence,
|
114 |
-
"label": label,
|
115 |
-
}
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|