Datasets:
Tasks:
Question Answering
Modalities:
Text
Formats:
parquet
Sub-tasks:
extractive-qa
Languages:
Arabic
Size:
1K - 10K
License:
Commit
•
18e8b87
1
Parent(s):
d2a0f44
Delete loading script
Browse files
arcd.py
DELETED
@@ -1,123 +0,0 @@
|
|
1 |
-
"""ARCD: Arabic Reading Comprehension Dataset."""
|
2 |
-
|
3 |
-
|
4 |
-
import json
|
5 |
-
|
6 |
-
import datasets
|
7 |
-
from datasets.tasks import QuestionAnsweringExtractive
|
8 |
-
|
9 |
-
|
10 |
-
logger = datasets.logging.get_logger(__name__)
|
11 |
-
|
12 |
-
|
13 |
-
_CITATION = """\
|
14 |
-
@inproceedings{mozannar-etal-2019-neural,
|
15 |
-
title = {Neural {A}rabic Question Answering},
|
16 |
-
author = {Mozannar, Hussein and Maamary, Elie and El Hajal, Karl and Hajj, Hazem},
|
17 |
-
booktitle = {Proceedings of the Fourth Arabic Natural Language Processing Workshop},
|
18 |
-
month = {aug},
|
19 |
-
year = {2019},
|
20 |
-
address = {Florence, Italy},
|
21 |
-
publisher = {Association for Computational Linguistics},
|
22 |
-
url = {https://www.aclweb.org/anthology/W19-4612},
|
23 |
-
doi = {10.18653/v1/W19-4612},
|
24 |
-
pages = {108--118},
|
25 |
-
abstract = {This paper tackles the problem of open domain factual Arabic question answering (QA) using Wikipedia as our knowledge source. This constrains the answer of any question to be a span of text in Wikipedia. Open domain QA for Arabic entails three challenges: annotated QA datasets in Arabic, large scale efficient information retrieval and machine reading comprehension. To deal with the lack of Arabic QA datasets we present the Arabic Reading Comprehension Dataset (ARCD) composed of 1,395 questions posed by crowdworkers on Wikipedia articles, and a machine translation of the Stanford Question Answering Dataset (Arabic-SQuAD). Our system for open domain question answering in Arabic (SOQAL) is based on two components: (1) a document retriever using a hierarchical TF-IDF approach and (2) a neural reading comprehension model using the pre-trained bi-directional transformer BERT. Our experiments on ARCD indicate the effectiveness of our approach with our BERT-based reader achieving a 61.3 F1 score, and our open domain system SOQAL achieving a 27.6 F1 score.}
|
26 |
-
}
|
27 |
-
"""
|
28 |
-
|
29 |
-
_DESCRIPTION = """\
|
30 |
-
Arabic Reading Comprehension Dataset (ARCD) composed of 1,395 questions\
|
31 |
-
posed by crowdworkers on Wikipedia articles.
|
32 |
-
"""
|
33 |
-
|
34 |
-
_URL = "https://raw.githubusercontent.com/husseinmozannar/SOQAL/master/data/"
|
35 |
-
_URLs = {
|
36 |
-
"train": _URL + "arcd-train.json",
|
37 |
-
"dev": _URL + "arcd-test.json",
|
38 |
-
}
|
39 |
-
|
40 |
-
|
41 |
-
class ArcdConfig(datasets.BuilderConfig):
|
42 |
-
"""BuilderConfig for ARCD."""
|
43 |
-
|
44 |
-
def __init__(self, **kwargs):
|
45 |
-
"""BuilderConfig for ARCD.
|
46 |
-
|
47 |
-
Args:
|
48 |
-
**kwargs: keyword arguments forwarded to super.
|
49 |
-
"""
|
50 |
-
super(ArcdConfig, self).__init__(**kwargs)
|
51 |
-
|
52 |
-
|
53 |
-
class Arcd(datasets.GeneratorBasedBuilder):
|
54 |
-
"""ARCD: Arabic Reading Comprehension Dataset."""
|
55 |
-
|
56 |
-
BUILDER_CONFIGS = [
|
57 |
-
ArcdConfig(
|
58 |
-
name="plain_text",
|
59 |
-
version=datasets.Version("1.0.0", ""),
|
60 |
-
description="Plain text",
|
61 |
-
)
|
62 |
-
]
|
63 |
-
|
64 |
-
def _info(self):
|
65 |
-
return datasets.DatasetInfo(
|
66 |
-
description=_DESCRIPTION,
|
67 |
-
features=datasets.Features(
|
68 |
-
{
|
69 |
-
"id": datasets.Value("string"),
|
70 |
-
"title": datasets.Value("string"),
|
71 |
-
"context": datasets.Value("string"),
|
72 |
-
"question": datasets.Value("string"),
|
73 |
-
"answers": datasets.features.Sequence(
|
74 |
-
{"text": datasets.Value("string"), "answer_start": datasets.Value("int32")}
|
75 |
-
),
|
76 |
-
}
|
77 |
-
),
|
78 |
-
# No default supervised_keys (as we have to pass both question
|
79 |
-
# and context as input).
|
80 |
-
supervised_keys=None,
|
81 |
-
homepage="https://github.com/husseinmozannar/SOQAL/tree/master/data",
|
82 |
-
citation=_CITATION,
|
83 |
-
task_templates=[
|
84 |
-
QuestionAnsweringExtractive(
|
85 |
-
question_column="question", context_column="context", answers_column="answers"
|
86 |
-
)
|
87 |
-
],
|
88 |
-
)
|
89 |
-
|
90 |
-
def _split_generators(self, dl_manager):
|
91 |
-
urls_to_download = _URLs
|
92 |
-
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
93 |
-
|
94 |
-
return [
|
95 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
96 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
|
97 |
-
]
|
98 |
-
|
99 |
-
def _generate_examples(self, filepath):
|
100 |
-
"""This function returns the examples in the raw (text) form."""
|
101 |
-
logger.info("generating examples from = %s", filepath)
|
102 |
-
with open(filepath, encoding="utf-8") as f:
|
103 |
-
arcd = json.load(f)
|
104 |
-
for article in arcd["data"]:
|
105 |
-
title = article.get("title", "").strip()
|
106 |
-
for paragraph in article["paragraphs"]:
|
107 |
-
context = paragraph["context"].strip()
|
108 |
-
for qa in paragraph["qas"]:
|
109 |
-
question = qa["question"].strip()
|
110 |
-
id_ = qa["id"]
|
111 |
-
|
112 |
-
answer_starts = [answer["answer_start"] for answer in qa["answers"]]
|
113 |
-
answers = [answer["text"].strip() for answer in qa["answers"]]
|
114 |
-
|
115 |
-
# Features currently used are "context", "question", and "answers".
|
116 |
-
# Others are extracted here for the ease of future expansions.
|
117 |
-
yield id_, {
|
118 |
-
"title": title,
|
119 |
-
"context": context,
|
120 |
-
"question": question,
|
121 |
-
"id": id_,
|
122 |
-
"answers": {"answer_start": answer_starts, "text": answers},
|
123 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|