Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Size:
10K - 100K
Tags:
offensive-language
License:
Delete loading script
Browse files- offenseval_dravidian.py +0 -196
offenseval_dravidian.py
DELETED
@@ -1,196 +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 |
-
"""Offensive language identification in dravidian lanaguages dataset"""
|
16 |
-
|
17 |
-
|
18 |
-
import csv
|
19 |
-
|
20 |
-
import datasets
|
21 |
-
|
22 |
-
|
23 |
-
_HOMEPAGE = "https://competitions.codalab.org/competitions/27654#learn_the_details"
|
24 |
-
|
25 |
-
|
26 |
-
_CITATION = """\
|
27 |
-
@inproceedings{dravidianoffensive-eacl,
|
28 |
-
title={Findings of the Shared Task on {O}ffensive {L}anguage {I}dentification in {T}amil, {M}alayalam, and {K}annada},
|
29 |
-
author={Chakravarthi, Bharathi Raja and
|
30 |
-
Priyadharshini, Ruba and
|
31 |
-
Jose, Navya and
|
32 |
-
M, Anand Kumar and
|
33 |
-
Mandl, Thomas and
|
34 |
-
Kumaresan, Prasanna Kumar and
|
35 |
-
Ponnsamy, Rahul and
|
36 |
-
V,Hariharan and
|
37 |
-
Sherly, Elizabeth and
|
38 |
-
McCrae, John Philip },
|
39 |
-
booktitle = "Proceedings of the First Workshop on Speech and Language Technologies for Dravidian Languages",
|
40 |
-
month = April,
|
41 |
-
year = "2021",
|
42 |
-
publisher = "Association for Computational Linguistics",
|
43 |
-
year={2021}
|
44 |
-
}
|
45 |
-
"""
|
46 |
-
|
47 |
-
_DESCRIPTION = """\
|
48 |
-
Offensive language identification in dravidian lanaguages dataset. The goal of this task is to identify offensive language content of the code-mixed dataset of comments/posts in Dravidian Languages ( (Tamil-English, Malayalam-English, and Kannada-English)) collected from social media.
|
49 |
-
"""
|
50 |
-
|
51 |
-
_LICENSE = "Creative Commons Attribution 4.0 International Licence"
|
52 |
-
|
53 |
-
_URLs = {
|
54 |
-
"tamil": {
|
55 |
-
"TRAIN_DOWNLOAD_URL": "https://drive.google.com/u/0/uc?id=15auwrFAlq52JJ61u7eSfnhT9rZtI5sjk&export=download",
|
56 |
-
"VALIDATION_DOWNLOAD_URL": "https://drive.google.com/u/0/uc?id=1Jme-Oftjm7OgfMNLKQs1mO_cnsQmznRI&export=download",
|
57 |
-
},
|
58 |
-
"malayalam": {
|
59 |
-
"TRAIN_DOWNLOAD_URL": "https://drive.google.com/u/0/uc?id=13JCCr-IjZK7uhbLXeufptr_AxvsKinVl&export=download",
|
60 |
-
"VALIDATION_DOWNLOAD_URL": "https://drive.google.com/u/0/uc?id=1J0msLpLoM6gmXkjC6DFeQ8CG_rrLvjnM&export=download",
|
61 |
-
},
|
62 |
-
"kannada": {
|
63 |
-
"TRAIN_DOWNLOAD_URL": "https://drive.google.com/u/0/uc?id=1BFYF05rx-DK9Eb5hgoIgd6EcB8zOI-zu&export=download",
|
64 |
-
"VALIDATION_DOWNLOAD_URL": "https://drive.google.com/u/0/uc?id=1V077dMQvscqpUmcWTcFHqRa_vTy-bQ4H&export=download",
|
65 |
-
},
|
66 |
-
}
|
67 |
-
|
68 |
-
|
69 |
-
class OffensevalDravidian(datasets.GeneratorBasedBuilder):
|
70 |
-
"""Offensive language identification in dravidian lanaguages dataset"""
|
71 |
-
|
72 |
-
VERSION = datasets.Version("1.0.0")
|
73 |
-
|
74 |
-
BUILDER_CONFIGS = [
|
75 |
-
datasets.BuilderConfig(
|
76 |
-
name="tamil", version=VERSION, description="This part of my dataset covers Tamil dataset"
|
77 |
-
),
|
78 |
-
datasets.BuilderConfig(
|
79 |
-
name="malayalam", version=VERSION, description="This part of my dataset covers Malayalam dataset"
|
80 |
-
),
|
81 |
-
datasets.BuilderConfig(
|
82 |
-
name="kannada", version=VERSION, description="This part of my dataset covers Kannada dataset"
|
83 |
-
),
|
84 |
-
]
|
85 |
-
|
86 |
-
def _info(self):
|
87 |
-
|
88 |
-
if self.config.name == "tamil": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
89 |
-
features = datasets.Features(
|
90 |
-
{
|
91 |
-
"text": datasets.Value("string"),
|
92 |
-
"label": datasets.features.ClassLabel(
|
93 |
-
names=[
|
94 |
-
"Not_offensive",
|
95 |
-
"Offensive_Untargetede",
|
96 |
-
"Offensive_Targeted_Insult_Individual",
|
97 |
-
"Offensive_Targeted_Insult_Group",
|
98 |
-
"Offensive_Targeted_Insult_Other",
|
99 |
-
"not-Tamil",
|
100 |
-
]
|
101 |
-
),
|
102 |
-
}
|
103 |
-
)
|
104 |
-
elif self.config.name == "malayalam":
|
105 |
-
features = datasets.Features(
|
106 |
-
{
|
107 |
-
"text": datasets.Value("string"),
|
108 |
-
"label": datasets.features.ClassLabel(
|
109 |
-
names=[
|
110 |
-
"Not_offensive",
|
111 |
-
"Offensive_Untargetede",
|
112 |
-
"Offensive_Targeted_Insult_Individual",
|
113 |
-
"Offensive_Targeted_Insult_Group",
|
114 |
-
"Offensive_Targeted_Insult_Other",
|
115 |
-
"not-malayalam",
|
116 |
-
]
|
117 |
-
),
|
118 |
-
}
|
119 |
-
)
|
120 |
-
|
121 |
-
# else self.config.name == "kannada":
|
122 |
-
else:
|
123 |
-
features = datasets.Features(
|
124 |
-
{
|
125 |
-
"text": datasets.Value("string"),
|
126 |
-
"label": datasets.features.ClassLabel(
|
127 |
-
names=[
|
128 |
-
"Not_offensive",
|
129 |
-
"Offensive_Untargetede",
|
130 |
-
"Offensive_Targeted_Insult_Individual",
|
131 |
-
"Offensive_Targeted_Insult_Group",
|
132 |
-
"Offensive_Targeted_Insult_Other",
|
133 |
-
"not-Kannada",
|
134 |
-
]
|
135 |
-
),
|
136 |
-
}
|
137 |
-
)
|
138 |
-
|
139 |
-
return datasets.DatasetInfo(
|
140 |
-
# This is the description that will appear on the datasets page.
|
141 |
-
description=_DESCRIPTION,
|
142 |
-
# This defines the different columns of the dataset and their types
|
143 |
-
features=features, # Here we define them above because they are different between the two configurations
|
144 |
-
# If there's a common (input, target) tuple from the features,
|
145 |
-
# specify them here. They'll be used if as_supervised=True in
|
146 |
-
# builder.as_dataset.
|
147 |
-
supervised_keys=None,
|
148 |
-
# Homepage of the dataset for documentation
|
149 |
-
homepage=_HOMEPAGE,
|
150 |
-
# License for the dataset if available
|
151 |
-
license=_LICENSE,
|
152 |
-
# Citation for the dataset
|
153 |
-
citation=_CITATION,
|
154 |
-
)
|
155 |
-
|
156 |
-
def _split_generators(self, dl_manager):
|
157 |
-
"""Returns SplitGenerators."""
|
158 |
-
|
159 |
-
my_urls = _URLs[self.config.name]
|
160 |
-
|
161 |
-
train_path = dl_manager.download_and_extract(my_urls["TRAIN_DOWNLOAD_URL"])
|
162 |
-
validation_path = dl_manager.download_and_extract(my_urls["VALIDATION_DOWNLOAD_URL"])
|
163 |
-
|
164 |
-
return [
|
165 |
-
datasets.SplitGenerator(
|
166 |
-
name=datasets.Split.TRAIN,
|
167 |
-
gen_kwargs={
|
168 |
-
"filepath": train_path,
|
169 |
-
"split": "train",
|
170 |
-
},
|
171 |
-
),
|
172 |
-
datasets.SplitGenerator(
|
173 |
-
name=datasets.Split.VALIDATION,
|
174 |
-
gen_kwargs={
|
175 |
-
"filepath": validation_path,
|
176 |
-
"split": "validation",
|
177 |
-
},
|
178 |
-
),
|
179 |
-
]
|
180 |
-
|
181 |
-
def _generate_examples(self, filepath, split):
|
182 |
-
"""Generate Offenseval_dravidian examples."""
|
183 |
-
|
184 |
-
with open(filepath, encoding="utf-8") as csv_file:
|
185 |
-
csv_reader = csv.reader(
|
186 |
-
csv_file, quotechar='"', delimiter="\t", quoting=csv.QUOTE_ALL, skipinitialspace=False
|
187 |
-
)
|
188 |
-
|
189 |
-
for id_, row in enumerate(csv_reader):
|
190 |
-
|
191 |
-
if self.config.name == "kannada":
|
192 |
-
text, label = row
|
193 |
-
else:
|
194 |
-
text, label, dummy = row
|
195 |
-
|
196 |
-
yield id_, {"text": text, "label": label}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|