TheTung commited on
Commit
ab4b851
1 Parent(s): 27de8c0

Upload data

Browse files

Upload the data from local to the hub

.gitattributes CHANGED
@@ -53,3 +53,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
 
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
56
+ train-v2.0-es_small.json filter=lfs diff=lfs merge=lfs -text
57
+ train-v2.0-es.json filter=lfs diff=lfs merge=lfs -text
dev-v2.0-es.json ADDED
The diff for this file is too large to render. See raw diff
 
dev-v2.0-es_small.json ADDED
The diff for this file is too large to render. See raw diff
 
squad_es.py ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """TODO(squad_es): Add a description here."""
2
+
3
+
4
+ import json
5
+
6
+ import datasets
7
+
8
+
9
+ # TODO(squad_es): BibTeX citation
10
+ _CITATION = """\
11
+ @article{2016arXiv160605250R,
12
+ author = {Casimiro Pio , Carrino and Marta R. , Costa-jussa and Jose A. R. , Fonollosa},
13
+ title = "{Automatic Spanish Translation of the SQuAD Dataset for Multilingual
14
+ Question Answering}",
15
+ journal = {arXiv e-prints},
16
+ year = 2019,
17
+ eid = {arXiv:1912.05200v1},
18
+ pages = {arXiv:1912.05200v1},
19
+ archivePrefix = {arXiv},
20
+ eprint = {1912.05200v2},
21
+ }
22
+ """
23
+
24
+ # TODO(squad_es_v1):
25
+ _DESCRIPTION = """\
26
+ automatic translation of the Stanford Question Answering Dataset (SQuAD) v2 into Spanish
27
+ """
28
+
29
+ _URL = "https://raw.githubusercontent.com/ccasimiro88/TranslateAlignRetrieve/master/"
30
+ _URLS_V1 = {
31
+ "train": _URL + "SQuAD-es-v1.1/train-v1.1-es.json",
32
+ "dev": _URL + "SQuAD-es-v1.1/dev-v1.1-es.json",
33
+ }
34
+ _URLS_V2 = {
35
+ "train": _URL + "SQuAD-es-v2.0/train-v2.0-es.json",
36
+ "dev": _URL + "SQuAD-es-v2.0/dev-v2.0-es.json",
37
+ }
38
+
39
+
40
+ class SquadEsConfig(datasets.BuilderConfig):
41
+ """BuilderConfig for SQUADEsV2."""
42
+
43
+ def __init__(self, **kwargs):
44
+ """BuilderConfig for SQUADEsV2.
45
+
46
+ Args:
47
+ **kwargs: keyword arguments forwarded to super.
48
+ """
49
+ super(SquadEsConfig, self).__init__(**kwargs)
50
+
51
+
52
+ class SquadEs(datasets.GeneratorBasedBuilder):
53
+ """TODO(squad_es): Short description of my dataset."""
54
+
55
+ # TODO(squad_es): Set up version.
56
+ VERSION = datasets.Version("0.1.0")
57
+
58
+ BUILDER_CONFIGS = [
59
+ SquadEsConfig(
60
+ name="v1.1.0",
61
+ version=datasets.Version("1.1.0", ""),
62
+ description="Plain text Spanish squad version 1",
63
+ ),
64
+ SquadEsConfig(
65
+ name="v2.0.0",
66
+ version=datasets.Version("2.0.0", ""),
67
+ description="Plain text Spanish squad version 2",
68
+ ),
69
+ ]
70
+
71
+ def _info(self):
72
+ # TODO(squad_es): Specifies the datasets.DatasetInfo object
73
+ return datasets.DatasetInfo(
74
+ # This is the description that will appear on the datasets page.
75
+ description=_DESCRIPTION,
76
+ # datasets.features.FeatureConnectors
77
+ features=datasets.Features(
78
+ {
79
+ # These are the features of your dataset like images, labels ...
80
+ "id": datasets.Value("string"),
81
+ "title": datasets.Value("string"),
82
+ "context": datasets.Value("string"),
83
+ "question": datasets.Value("string"),
84
+ "answers": datasets.features.Sequence(
85
+ {
86
+ "text": datasets.Value("string"),
87
+ "answer_start": datasets.Value("int32"),
88
+ }
89
+ ),
90
+ }
91
+ ),
92
+ # If there's a common (input, target) tuple from the features,
93
+ # specify them here. They'll be used if as_supervised=True in
94
+ # builder.as_dataset.
95
+ supervised_keys=None,
96
+ # Homepage of the dataset for documentation
97
+ homepage="https://github.com/ccasimiro88/TranslateAlignRetrieve",
98
+ citation=_CITATION,
99
+ )
100
+
101
+ def _split_generators(self, dl_manager):
102
+ """Returns SplitGenerators."""
103
+ # TODO(squad_es): Downloads the data and defines the splits
104
+ # dl_manager is a datasets.download.DownloadManager that can be used to
105
+
106
+ # download and extract URLs
107
+ if self.config.name == "v1.1.0":
108
+ dl_dir = dl_manager.download_and_extract(_URLS_V1)
109
+ elif self.config.name == "v2.0.0":
110
+ dl_dir = dl_manager.download_and_extract(_URLS_V2)
111
+ else:
112
+ raise Exception("version does not match any existing one")
113
+ return [
114
+ datasets.SplitGenerator(
115
+ name=datasets.Split.TRAIN,
116
+ # These kwargs will be passed to _generate_examples
117
+ gen_kwargs={"filepath": dl_dir["train"]},
118
+ ),
119
+ datasets.SplitGenerator(
120
+ name=datasets.Split.VALIDATION,
121
+ # These kwargs will be passed to _generate_examples
122
+ gen_kwargs={"filepath": dl_dir["dev"]},
123
+ ),
124
+ ]
125
+
126
+ def _generate_examples(self, filepath):
127
+ """Yields examples."""
128
+ # TODO(squad_es): Yields (key, example) tuples from the dataset
129
+ with open(filepath, encoding="utf-8") as f:
130
+ data = json.load(f)
131
+ for example in data["data"]:
132
+ title = example.get("title", "").strip()
133
+ for paragraph in example["paragraphs"]:
134
+ context = paragraph["context"].strip()
135
+ for qa in paragraph["qas"]:
136
+ question = qa["question"].strip()
137
+ id_ = qa["id"]
138
+
139
+ answer_starts = [answer["answer_start"] for answer in qa["answers"]]
140
+ answers = [answer["text"].strip() for answer in qa["answers"]]
141
+
142
+ yield id_, {
143
+ "title": title,
144
+ "context": context,
145
+ "question": question,
146
+ "id": id_,
147
+ "answers": {
148
+ "answer_start": answer_starts,
149
+ "text": answers,
150
+ },
151
+ }
train-v2.0-es.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d5a2001fc9508449284114017c4fadce6bbe460dcb1656e89b780c125370c85
3
+ size 46750744
train-v2.0-es_small.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e5d1c6869482f17af936703adc77e7c9f6f417507e19ab5ee79d4d1dd55dc07
3
+ size 31532249