Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
sentiment-classification
Languages:
Arabic
Size:
10K - 100K
Tags:
sarcasm-detection
License:
Commit
•
659fd35
1
Parent(s):
404bc41
Delete loading script
Browse files- ar_sarcasm.py +0 -110
ar_sarcasm.py
DELETED
@@ -1,110 +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 |
-
|
16 |
-
|
17 |
-
import csv
|
18 |
-
import os
|
19 |
-
|
20 |
-
import datasets
|
21 |
-
|
22 |
-
|
23 |
-
# no BibTeX citation
|
24 |
-
_CITATION = """@inproceedings{abu-farha-magdy-2020-arabic,
|
25 |
-
title = "From {A}rabic Sentiment Analysis to Sarcasm Detection: The {A}r{S}arcasm Dataset",
|
26 |
-
author = "Abu Farha, Ibrahim and Magdy, Walid",
|
27 |
-
booktitle = "Proceedings of the 4th Workshop on Open-Source Arabic Corpora and Processing Tools, with a Shared Task on Offensive Language Detection",
|
28 |
-
month = may,
|
29 |
-
year = "2020",
|
30 |
-
address = "Marseille, France",
|
31 |
-
publisher = "European Language Resource Association",
|
32 |
-
url = "https://www.aclweb.org/anthology/2020.osact-1.5",
|
33 |
-
pages = "32--39",
|
34 |
-
language = "English",
|
35 |
-
ISBN = "979-10-95546-51-1",
|
36 |
-
}"""
|
37 |
-
|
38 |
-
_DESCRIPTION = """\
|
39 |
-
ArSarcasm is a new Arabic sarcasm detection dataset.
|
40 |
-
The dataset was created using previously available Arabic sentiment analysis datasets (SemEval 2017 and ASTD)
|
41 |
-
and adds sarcasm and dialect labels to them. The dataset contains 10,547 tweets, 1,682 (16%) of which are sarcastic.
|
42 |
-
"""
|
43 |
-
|
44 |
-
_LICENSE = "MIT"
|
45 |
-
|
46 |
-
# From: https://github.com/iabufarha/ArSarcasm/archive/master.zip
|
47 |
-
_URLs = {
|
48 |
-
"default": "data.zip",
|
49 |
-
}
|
50 |
-
|
51 |
-
|
52 |
-
class ArSarcasm(datasets.GeneratorBasedBuilder):
|
53 |
-
VERSION = datasets.Version("1.0.0")
|
54 |
-
|
55 |
-
def _info(self):
|
56 |
-
features = datasets.Features(
|
57 |
-
{
|
58 |
-
"dialect": datasets.ClassLabel(names=["egypt", "gulf", "levant", "magreb", "msa"]),
|
59 |
-
"sarcasm": datasets.ClassLabel(names=["non-sarcastic", "sarcastic"]),
|
60 |
-
"sentiment": datasets.ClassLabel(names=["negative", "neutral", "positive"]),
|
61 |
-
"original_sentiment": datasets.ClassLabel(names=["negative", "neutral", "positive"]),
|
62 |
-
"tweet": datasets.Value("string"),
|
63 |
-
"source": datasets.Value("string"),
|
64 |
-
}
|
65 |
-
)
|
66 |
-
return datasets.DatasetInfo(
|
67 |
-
description=_DESCRIPTION,
|
68 |
-
features=features,
|
69 |
-
supervised_keys=None,
|
70 |
-
homepage="https://github.com/iabufarha/ArSarcasm",
|
71 |
-
license=_LICENSE,
|
72 |
-
citation=_CITATION,
|
73 |
-
)
|
74 |
-
|
75 |
-
def _split_generators(self, dl_manager):
|
76 |
-
my_urls = _URLs[self.config.name]
|
77 |
-
data_dir = dl_manager.download_and_extract(my_urls)
|
78 |
-
|
79 |
-
return [
|
80 |
-
datasets.SplitGenerator(
|
81 |
-
name=datasets.Split.TRAIN,
|
82 |
-
gen_kwargs={
|
83 |
-
"filepath": os.path.join(data_dir, "ArSarcasm-master", "dataset", "ArSarcasm_train.csv"),
|
84 |
-
},
|
85 |
-
),
|
86 |
-
datasets.SplitGenerator(
|
87 |
-
name=datasets.Split.TEST,
|
88 |
-
gen_kwargs={
|
89 |
-
"filepath": os.path.join(data_dir, "ArSarcasm-master", "dataset", "ArSarcasm_test.csv"),
|
90 |
-
},
|
91 |
-
),
|
92 |
-
]
|
93 |
-
|
94 |
-
def _generate_examples(self, filepath):
|
95 |
-
with open(filepath, encoding="utf-8") as f:
|
96 |
-
rdr = csv.reader(f, delimiter=",")
|
97 |
-
next(rdr)
|
98 |
-
for id_, row in enumerate(rdr):
|
99 |
-
if len(row) < 6:
|
100 |
-
continue
|
101 |
-
if row[4][0] == '"' and row[4][-1] == '"':
|
102 |
-
row[4] = row[4][1:-1]
|
103 |
-
yield id_, {
|
104 |
-
"dialect": row[0],
|
105 |
-
"sarcasm": "sarcastic" if row[1] == "True" else "non-sarcastic",
|
106 |
-
"sentiment": row[2],
|
107 |
-
"original_sentiment": row[3],
|
108 |
-
"tweet": row[4],
|
109 |
-
"source": row[5],
|
110 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|