Datasets:

Sub-tasks:
extractive-qa
Multilinguality:
multilingual
Size Categories:
unknown
Language Creators:
expert-generated
Annotations Creators:
expert-generated
Source Datasets:
extended|squad
ArXiv:
Tags:
License:
albertvillanova HF staff commited on
Commit
ef4d39b
1 Parent(s): 285410c

Delete loading script

Browse files
Files changed (1) hide show
  1. xquad.py +0 -131
xquad.py DELETED
@@ -1,131 +0,0 @@
1
- """TODO(xquad): Add a description here."""
2
-
3
-
4
- import json
5
-
6
- import datasets
7
- from datasets.tasks import QuestionAnsweringExtractive
8
-
9
-
10
- _CITATION = """\
11
- @article{Artetxe:etal:2019,
12
- author = {Mikel Artetxe and Sebastian Ruder and Dani Yogatama},
13
- title = {On the cross-lingual transferability of monolingual representations},
14
- journal = {CoRR},
15
- volume = {abs/1910.11856},
16
- year = {2019},
17
- archivePrefix = {arXiv},
18
- eprint = {1910.11856}
19
- }
20
- """
21
-
22
- _DESCRIPTION = """\
23
- XQuAD (Cross-lingual Question Answering Dataset) is a benchmark dataset for evaluating cross-lingual question answering
24
- performance. The dataset consists of a subset of 240 paragraphs and 1190 question-answer pairs from the development set
25
- of SQuAD v1.1 (Rajpurkar et al., 2016) together with their professional translations into ten languages: Spanish, German,
26
- Greek, Russian, Turkish, Arabic, Vietnamese, Thai, Chinese, Hindi and Romanian. Consequently, the dataset is entirely parallel
27
- across 12 languages.
28
- """
29
-
30
- _URL = "https://github.com/deepmind/xquad/raw/master/"
31
- _LANG = ["ar", "de", "zh", "vi", "en", "es", "hi", "el", "th", "tr", "ru", "ro"]
32
-
33
-
34
- class XquadConfig(datasets.BuilderConfig):
35
-
36
- """BuilderConfig for Xquad"""
37
-
38
- def __init__(self, lang, **kwargs):
39
- """
40
-
41
- Args:
42
- lang: string, language for the input text
43
- **kwargs: keyword arguments forwarded to super.
44
- """
45
- super(XquadConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
46
- self.lang = lang
47
-
48
-
49
- class Xquad(datasets.GeneratorBasedBuilder):
50
- """TODO(xquad): Short description of my dataset."""
51
-
52
- # TODO(xquad): Set up version.
53
- VERSION = datasets.Version("1.0.0")
54
- BUILDER_CONFIGS = [XquadConfig(name=f"xquad.{lang}", description=_DESCRIPTION, lang=lang) for lang in _LANG]
55
-
56
- def _info(self):
57
- # TODO(xquad): Specifies the datasets.DatasetInfo object
58
- return datasets.DatasetInfo(
59
- # This is the description that will appear on the datasets page.
60
- description=_DESCRIPTION,
61
- # datasets.features.FeatureConnectors
62
- features=datasets.Features(
63
- {
64
- "id": datasets.Value("string"),
65
- "context": datasets.Value("string"),
66
- "question": datasets.Value("string"),
67
- "answers": datasets.features.Sequence(
68
- {
69
- "text": datasets.Value("string"),
70
- "answer_start": datasets.Value("int32"),
71
- }
72
- ),
73
- # These are the features of your dataset like images, labels ...
74
- }
75
- ),
76
- # If there's a common (input, target) tuple from the features,
77
- # specify them here. They'll be used if as_supervised=True in
78
- # builder.as_dataset.
79
- supervised_keys=None,
80
- # Homepage of the dataset for documentation
81
- homepage="https://github.com/deepmind/xquad",
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
- """Returns SplitGenerators."""
92
- # TODO(xquad): Downloads the data and defines the splits
93
- # dl_manager is a datasets.download.DownloadManager that can be used to
94
- # download and extract URLs
95
- urls_to_download = {lang: _URL + f"xquad.{lang}.json" for lang in _LANG}
96
- downloaded_files = dl_manager.download_and_extract(urls_to_download)
97
-
98
- return [
99
- datasets.SplitGenerator(
100
- name=datasets.Split.VALIDATION,
101
- # These kwargs will be passed to _generate_examples
102
- gen_kwargs={"filepath": downloaded_files[self.config.lang]},
103
- ),
104
- ]
105
-
106
- def _generate_examples(self, filepath):
107
- """Yields examples."""
108
- # TODO(xquad): Yields (key, example) tuples from the dataset
109
- with open(filepath, encoding="utf-8") as f:
110
- xquad = json.load(f)
111
- id_ = 0
112
- for article in xquad["data"]:
113
- for paragraph in article["paragraphs"]:
114
- context = paragraph["context"].strip()
115
- for qa in paragraph["qas"]:
116
- question = qa["question"].strip()
117
- answer_starts = [answer["answer_start"] for answer in qa["answers"]]
118
- answers = [answer["text"].strip() for answer in qa["answers"]]
119
-
120
- # Features currently used are "context", "question", and "answers".
121
- # Others are extracted here for the ease of future expansions.
122
- yield id_, {
123
- "context": context,
124
- "question": question,
125
- "id": qa["id"],
126
- "answers": {
127
- "answer_start": answer_starts,
128
- "text": answers,
129
- },
130
- }
131
- id_ += 1