Commit
•
4022948
1
Parent(s):
c25bef7
Delete loading script
Browse files- bn_hate_speech.py +0 -89
bn_hate_speech.py
DELETED
@@ -1,89 +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 |
-
"""Bengali Hate Speech Dataset"""
|
16 |
-
|
17 |
-
|
18 |
-
import csv
|
19 |
-
|
20 |
-
import datasets
|
21 |
-
|
22 |
-
|
23 |
-
_CITATION = """\
|
24 |
-
@misc{karim2020classification,
|
25 |
-
title={Classification Benchmarks for Under-resourced Bengali Language based on Multichannel Convolutional-LSTM Network},
|
26 |
-
author={Md. Rezaul Karim and Bharathi Raja Chakravarthi and John P. McCrae and Michael Cochez},
|
27 |
-
year={2020},
|
28 |
-
eprint={2004.07807},
|
29 |
-
archivePrefix={arXiv},
|
30 |
-
primaryClass={cs.CL}
|
31 |
-
}
|
32 |
-
"""
|
33 |
-
|
34 |
-
_DESCRIPTION = """\
|
35 |
-
The Bengali Hate Speech Dataset is a collection of Bengali articles collected from Bengali news articles,
|
36 |
-
news dump of Bengali TV channels, books, blogs, and social media. Emphasis was placed on Facebook pages and
|
37 |
-
newspaper sources because they attract close to 50 million followers and is a common source of opinions
|
38 |
-
and hate speech. The raw text corpus contains 250 million articles and the full dataset is being prepared
|
39 |
-
for release. This is a subset of the full dataset.
|
40 |
-
|
41 |
-
This dataset was prepared for hate-speech text classification benchmark on Bengali, an under-resourced language.
|
42 |
-
"""
|
43 |
-
|
44 |
-
_HOMEPAGE = "https://github.com/rezacsedu/Bengali-Hate-Speech-Dataset"
|
45 |
-
|
46 |
-
_LICENSE = "MIT License"
|
47 |
-
|
48 |
-
_URL = "https://raw.githubusercontent.com/rezacsedu/Bengali-Hate-Speech-Dataset/main/bengali_%20hate_v1.0.csv"
|
49 |
-
|
50 |
-
|
51 |
-
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
52 |
-
class BnHateSpeech(datasets.GeneratorBasedBuilder):
|
53 |
-
"""Bengali Hate Speech Dataset"""
|
54 |
-
|
55 |
-
def _info(self):
|
56 |
-
features = datasets.Features(
|
57 |
-
{
|
58 |
-
"text": datasets.Value("string"),
|
59 |
-
"label": datasets.features.ClassLabel(
|
60 |
-
names=["Personal", "Political", "Religious", "Geopolitical", "Gender abusive"]
|
61 |
-
),
|
62 |
-
}
|
63 |
-
)
|
64 |
-
return datasets.DatasetInfo(
|
65 |
-
description=_DESCRIPTION,
|
66 |
-
features=features,
|
67 |
-
supervised_keys=None,
|
68 |
-
homepage=_HOMEPAGE,
|
69 |
-
license=_LICENSE,
|
70 |
-
citation=_CITATION,
|
71 |
-
)
|
72 |
-
|
73 |
-
def _split_generators(self, dl_manager):
|
74 |
-
"""Returns SplitGenerators."""
|
75 |
-
|
76 |
-
train_path = dl_manager.download_and_extract(_URL)
|
77 |
-
return [
|
78 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
|
79 |
-
]
|
80 |
-
|
81 |
-
def _generate_examples(self, filepath):
|
82 |
-
"""Generate Bengali Hate Speech examples."""
|
83 |
-
|
84 |
-
with open(filepath, encoding="utf-8") as csv_file:
|
85 |
-
reader = csv.reader(csv_file, delimiter="\t")
|
86 |
-
next(reader, None)
|
87 |
-
for id_, row in enumerate(reader):
|
88 |
-
text, label = row
|
89 |
-
yield id_, {"text": text, "label": label}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|