Commit
•
03587f8
1
Parent(s):
23c403c
Require data manual download
Browse files
fquad.py
CHANGED
@@ -1,13 +1,21 @@
|
|
1 |
-
"""
|
2 |
|
3 |
|
4 |
import json
|
5 |
import os
|
|
|
6 |
|
7 |
import datasets
|
8 |
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
_CITATION = """\
|
12 |
@ARTICLE{2020arXiv200206071
|
13 |
author = {Martin, d'Hoffschmidt and Maxime, Vidal and
|
@@ -25,33 +33,28 @@ archivePrefix = {arXiv},
|
|
25 |
}
|
26 |
"""
|
27 |
|
28 |
-
# TODO(fquad):
|
29 |
-
_DESCRIPTION = """\
|
30 |
-
FQuAD: French Question Answering Dataset
|
31 |
-
We introduce FQuAD, a native French Question Answering Dataset. FQuAD contains 25,000+ question and answer pairs.
|
32 |
-
Finetuning CamemBERT on FQuAD yields a F1 score of 88% and an exact match of 77.9%.
|
33 |
|
34 |
-
|
|
|
35 |
|
36 |
-
|
37 |
-
_URLS = {
|
38 |
-
"train": _URL + "train.json.zip",
|
39 |
-
"valid": _URL + "valid.json.zip",
|
40 |
-
}
|
41 |
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
|
|
|
48 |
|
49 |
def _info(self):
|
50 |
-
# TODO(fquad): Specifies the datasets.DatasetInfo object
|
51 |
return datasets.DatasetInfo(
|
52 |
-
# This is the description that will appear on the datasets page.
|
53 |
description=_DESCRIPTION,
|
54 |
-
# datasets.features.FeatureConnectors
|
55 |
features=datasets.Features(
|
56 |
{
|
57 |
"context": datasets.Value("string"),
|
@@ -62,39 +65,28 @@ class Fquad(datasets.GeneratorBasedBuilder):
|
|
62 |
# These are the features of your dataset like images, labels ...
|
63 |
}
|
64 |
),
|
65 |
-
|
66 |
-
# specify them here. They'll be used if as_supervised=True in
|
67 |
-
# builder.as_dataset.
|
68 |
-
supervised_keys=None,
|
69 |
-
# Homepage of the dataset for documentation
|
70 |
-
homepage="https://fquad.illuin.tech/",
|
71 |
citation=_CITATION,
|
72 |
)
|
73 |
|
74 |
def _split_generators(self, dl_manager):
|
75 |
"""Returns SplitGenerators."""
|
76 |
-
|
77 |
-
# dl_manager is a datasets.download.DownloadManager that can be used to
|
78 |
-
# download and extract URLs
|
79 |
-
download_urls = _URLS
|
80 |
-
dl_dir = dl_manager.download_and_extract(download_urls)
|
81 |
return [
|
82 |
datasets.SplitGenerator(
|
83 |
name=datasets.Split.TRAIN,
|
84 |
# These kwargs will be passed to _generate_examples
|
85 |
-
gen_kwargs={"filepath": os.path.join(
|
86 |
),
|
87 |
datasets.SplitGenerator(
|
88 |
name=datasets.Split.VALIDATION,
|
89 |
# These kwargs will be passed to _generate_examples
|
90 |
-
gen_kwargs={"filepath": os.path.join(
|
91 |
),
|
92 |
]
|
93 |
|
94 |
def _generate_examples(self, filepath):
|
95 |
-
|
96 |
"""Yields examples."""
|
97 |
-
# TODO(fquad): Yields (key, example) tuples from the dataset
|
98 |
with open(filepath, encoding="utf-8") as f:
|
99 |
data = json.load(f)
|
100 |
for id1, examples in enumerate(data["data"]):
|
|
|
1 |
+
"""FQuAD dataset."""
|
2 |
|
3 |
|
4 |
import json
|
5 |
import os
|
6 |
+
from textwrap import dedent
|
7 |
|
8 |
import datasets
|
9 |
|
10 |
|
11 |
+
_HOMEPAGE = "https://fquad.illuin.tech/"
|
12 |
+
|
13 |
+
_DESCRIPTION = """\
|
14 |
+
FQuAD: French Question Answering Dataset
|
15 |
+
We introduce FQuAD, a native French Question Answering Dataset. FQuAD contains 25,000+ question and answer pairs.
|
16 |
+
Finetuning CamemBERT on FQuAD yields a F1 score of 88% and an exact match of 77.9%.
|
17 |
+
"""
|
18 |
+
|
19 |
_CITATION = """\
|
20 |
@ARTICLE{2020arXiv200206071
|
21 |
author = {Martin, d'Hoffschmidt and Maxime, Vidal and
|
|
|
33 |
}
|
34 |
"""
|
35 |
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
+
class Fquad(datasets.GeneratorBasedBuilder):
|
38 |
+
"""FQuAD dataset."""
|
39 |
|
40 |
+
VERSION = datasets.Version("1.0.0")
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
@property
|
43 |
+
def manual_download_instructions(self):
|
44 |
+
return dedent("""\
|
45 |
+
To access the data for this dataset, you need to request it at:
|
46 |
+
https://fquad.illuin.tech/#download
|
47 |
|
48 |
+
Unzip the downloaded file with `unzip download-form-fquad1.0.zip -d <path/to/directory>`, into a destination
|
49 |
+
directory <path/to/directory>, which will contain the two data files train.json and valid.json.
|
50 |
|
51 |
+
To load the dataset, pass the full path to the destination directory
|
52 |
+
in your call to the loading function: `datasets.load_dataset("fquad", data_dir="<path/to/directory>")`
|
53 |
+
""")
|
54 |
|
55 |
def _info(self):
|
|
|
56 |
return datasets.DatasetInfo(
|
|
|
57 |
description=_DESCRIPTION,
|
|
|
58 |
features=datasets.Features(
|
59 |
{
|
60 |
"context": datasets.Value("string"),
|
|
|
65 |
# These are the features of your dataset like images, labels ...
|
66 |
}
|
67 |
),
|
68 |
+
homepage=_HOMEPAGE,
|
|
|
|
|
|
|
|
|
|
|
69 |
citation=_CITATION,
|
70 |
)
|
71 |
|
72 |
def _split_generators(self, dl_manager):
|
73 |
"""Returns SplitGenerators."""
|
74 |
+
data_dir = os.path.abspath(os.path.expanduser(dl_manager.manual_dir))
|
|
|
|
|
|
|
|
|
75 |
return [
|
76 |
datasets.SplitGenerator(
|
77 |
name=datasets.Split.TRAIN,
|
78 |
# These kwargs will be passed to _generate_examples
|
79 |
+
gen_kwargs={"filepath": os.path.join(data_dir, "train.json")},
|
80 |
),
|
81 |
datasets.SplitGenerator(
|
82 |
name=datasets.Split.VALIDATION,
|
83 |
# These kwargs will be passed to _generate_examples
|
84 |
+
gen_kwargs={"filepath": os.path.join(data_dir, "valid.json")},
|
85 |
),
|
86 |
]
|
87 |
|
88 |
def _generate_examples(self, filepath):
|
|
|
89 |
"""Yields examples."""
|
|
|
90 |
with open(filepath, encoding="utf-8") as f:
|
91 |
data = json.load(f)
|
92 |
for id1, examples in enumerate(data["data"]):
|