Datasets:
Tasks:
Text Classification
Sub-tasks:
intent-classification
Languages:
Polish
Size:
10K<n<100K
License:
Delete loading script
Browse files- poleval2019_cyberbullying.py +0 -153
poleval2019_cyberbullying.py
DELETED
@@ -1,153 +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 |
-
"""Cyberbullying Classification Dataset in Polish"""
|
16 |
-
|
17 |
-
|
18 |
-
import os
|
19 |
-
|
20 |
-
import datasets
|
21 |
-
|
22 |
-
|
23 |
-
_DESCRIPTION = """\
|
24 |
-
In Task 6-1, the participants are to distinguish between normal/non-harmful tweets (class: 0) and tweets
|
25 |
-
that contain any kind of harmful information (class: 1). This includes cyberbullying, hate speech and
|
26 |
-
related phenomena.
|
27 |
-
|
28 |
-
In Task 6-2, the participants shall distinguish between three classes of tweets: 0 (non-harmful),
|
29 |
-
1 (cyberbullying), 2 (hate-speech). There are various definitions of both cyberbullying and hate-speech,
|
30 |
-
some of them even putting those two phenomena in the same group. The specific conditions on which we based
|
31 |
-
our annotations for both cyberbullying and hate-speech, which have been worked out during ten years of research
|
32 |
-
will be summarized in an introductory paper for the task, however, the main and definitive condition to 1
|
33 |
-
distinguish the two is whether the harmful action is addressed towards a private person(s) (cyberbullying),
|
34 |
-
or a public person/entity/large group (hate-speech).
|
35 |
-
"""
|
36 |
-
|
37 |
-
_HOMEPAGE = "http://2019.poleval.pl/index.php/tasks/task6"
|
38 |
-
|
39 |
-
_URL_TRAIN_TASK1 = "http://2019.poleval.pl/task6/task_6-1.zip"
|
40 |
-
_URL_TRAIN_TASK2 = "http://2019.poleval.pl/task6/task_6-2.zip"
|
41 |
-
_URL_TEST = "http://2019.poleval.pl/task6/task6_test.zip"
|
42 |
-
|
43 |
-
_CITATION = """\
|
44 |
-
@proceedings{ogr:kob:19:poleval,
|
45 |
-
editor = {Maciej Ogrodniczuk and Łukasz Kobyliński},
|
46 |
-
title = {{Proceedings of the PolEval 2019 Workshop}},
|
47 |
-
year = {2019},
|
48 |
-
address = {Warsaw, Poland},
|
49 |
-
publisher = {Institute of Computer Science, Polish Academy of Sciences},
|
50 |
-
url = {http://2019.poleval.pl/files/poleval2019.pdf},
|
51 |
-
isbn = "978-83-63159-28-3"}
|
52 |
-
}
|
53 |
-
"""
|
54 |
-
|
55 |
-
|
56 |
-
class Poleval2019CyberBullyingConfig(datasets.BuilderConfig):
|
57 |
-
"""BuilderConfig for Poleval2019CyberBullying."""
|
58 |
-
|
59 |
-
def __init__(
|
60 |
-
self,
|
61 |
-
text_features,
|
62 |
-
label_classes,
|
63 |
-
**kwargs,
|
64 |
-
):
|
65 |
-
super(Poleval2019CyberBullyingConfig, self).__init__(version=datasets.Version("1.0.0"), **kwargs)
|
66 |
-
self.text_features = text_features
|
67 |
-
self.label_classes = label_classes
|
68 |
-
|
69 |
-
|
70 |
-
class Poleval2019CyberBullying(datasets.GeneratorBasedBuilder):
|
71 |
-
"""Cyberbullying Classification Dataset in Polish"""
|
72 |
-
|
73 |
-
VERSION = datasets.Version("1.0.0")
|
74 |
-
|
75 |
-
BUILDER_CONFIGS = [
|
76 |
-
Poleval2019CyberBullyingConfig(
|
77 |
-
name="task01",
|
78 |
-
text_features=["text"],
|
79 |
-
label_classes=["0", "1"],
|
80 |
-
),
|
81 |
-
Poleval2019CyberBullyingConfig(
|
82 |
-
name="task02",
|
83 |
-
text_features=["text"],
|
84 |
-
label_classes=["0", "1", "2"],
|
85 |
-
),
|
86 |
-
]
|
87 |
-
|
88 |
-
def _info(self):
|
89 |
-
|
90 |
-
features = {text_feature: datasets.Value("string") for text_feature in self.config.text_features}
|
91 |
-
features["label"] = datasets.features.ClassLabel(names=self.config.label_classes)
|
92 |
-
|
93 |
-
return datasets.DatasetInfo(
|
94 |
-
description=_DESCRIPTION,
|
95 |
-
features=datasets.Features(features),
|
96 |
-
supervised_keys=("text", "label"),
|
97 |
-
homepage=_HOMEPAGE,
|
98 |
-
citation=_CITATION,
|
99 |
-
)
|
100 |
-
|
101 |
-
def _split_generators(self, dl_manager):
|
102 |
-
"""Returns SplitGenerators."""
|
103 |
-
|
104 |
-
if self.config.name == "task01":
|
105 |
-
train_path = dl_manager.download_and_extract(_URL_TRAIN_TASK1)
|
106 |
-
|
107 |
-
if self.config.name == "task02":
|
108 |
-
train_path = dl_manager.download_and_extract(_URL_TRAIN_TASK2)
|
109 |
-
|
110 |
-
data_dir_test = dl_manager.download_and_extract(_URL_TEST)
|
111 |
-
|
112 |
-
if self.config.name == "task01":
|
113 |
-
test_path = os.path.join(data_dir_test, "Task6", "task 01")
|
114 |
-
|
115 |
-
if self.config.name == "task02":
|
116 |
-
test_path = os.path.join(data_dir_test, "Task6", "task 02")
|
117 |
-
|
118 |
-
return [
|
119 |
-
datasets.SplitGenerator(
|
120 |
-
name=datasets.Split.TRAIN,
|
121 |
-
gen_kwargs={
|
122 |
-
"filepath": train_path,
|
123 |
-
"split": "train",
|
124 |
-
},
|
125 |
-
),
|
126 |
-
datasets.SplitGenerator(
|
127 |
-
name=datasets.Split.TEST,
|
128 |
-
gen_kwargs={
|
129 |
-
"filepath": test_path,
|
130 |
-
"split": "test",
|
131 |
-
},
|
132 |
-
),
|
133 |
-
]
|
134 |
-
|
135 |
-
def _generate_examples(self, filepath, split):
|
136 |
-
"""Yields examples."""
|
137 |
-
|
138 |
-
if split == "train":
|
139 |
-
text_path = os.path.join(filepath, "training_set_clean_only_text.txt")
|
140 |
-
label_path = os.path.join(filepath, "training_set_clean_only_tags.txt")
|
141 |
-
|
142 |
-
if split == "test":
|
143 |
-
if self.config.name == "task01":
|
144 |
-
text_path = os.path.join(filepath, "test_set_clean_only_text.txt")
|
145 |
-
label_path = os.path.join(filepath, "test_set_clean_only_tags.txt")
|
146 |
-
if self.config.name == "task02":
|
147 |
-
text_path = os.path.join(filepath, "test_set_only_text.txt")
|
148 |
-
label_path = os.path.join(filepath, "test_set_only_tags.txt")
|
149 |
-
|
150 |
-
with open(text_path, encoding="utf-8") as text_file:
|
151 |
-
with open(label_path, encoding="utf-8") as label_file:
|
152 |
-
for id_, (text, label) in enumerate(zip(text_file, label_file)):
|
153 |
-
yield id_, {"text": text.strip(), "label": int(label.strip())}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|