Datasets:

Languages:
French
Multilinguality:
monolingual
Size Categories:
1K<n<10K
Language Creators:
crowdsourced
found
Annotations Creators:
crowdsourced
Source Datasets:
original
ArXiv:
License:
File size: 3,886 Bytes
32ff1d9
27b0027
 
 
 
32ff1d9
27b0027
 
 
 
32ff1d9
 
 
 
 
 
 
 
27b0027
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32ff1d9
 
9d04d6d
32ff1d9
27b0027
32ff1d9
 
 
 
 
27b0027
32ff1d9
 
27b0027
32ff1d9
 
 
27b0027
 
 
 
 
 
 
 
 
 
 
 
 
 
32ff1d9
27b0027
 
 
 
 
32ff1d9
27b0027
 
 
 
32ff1d9
27b0027
 
 
 
32ff1d9
27b0027
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
"""FQuAD dataset."""


import json
import os
from textwrap import dedent

import datasets


_HOMEPAGE = "https://fquad.illuin.tech/"

_DESCRIPTION = """\
FQuAD: French Question Answering Dataset
We introduce FQuAD, a native French Question Answering Dataset. FQuAD contains 25,000+ question and answer pairs.
Finetuning CamemBERT on FQuAD yields a F1 score of 88% and an exact match of 77.9%.
"""

_CITATION = """\
@ARTICLE{2020arXiv200206071
       author = {Martin, d'Hoffschmidt and Maxime, Vidal and
         Wacim, Belblidia and Tom, Brendlé},
        title = "{FQuAD: French Question Answering Dataset}",
      journal = {arXiv e-prints},
     keywords = {Computer Science - Computation and Language},
         year = "2020",
        month = "Feb",
          eid = {arXiv:2002.06071},
        pages = {arXiv:2002.06071},
archivePrefix = {arXiv},
       eprint = {2002.06071},
 primaryClass = {cs.CL}
}
"""


class Fquad(datasets.GeneratorBasedBuilder):
    """FQuAD dataset."""

    VERSION = datasets.Version("1.0.0")

    @property
    def manual_download_instructions(self):
        return dedent("""\
        To access the data for this dataset, you need to request it at:
        https://fquad.illuin.tech/#download

        Unzip the downloaded file with `unzip download-form-fquad1.0.zip -d <path/to/directory>`, into a destination
        directory <path/to/directory>, which will contain the two data files train.json and valid.json.

        To load the dataset, pass the full path to the destination directory
        in your call to the loading function: `datasets.load_dataset("fquad", data_dir="<path/to/directory>")`
        """)

    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(
                {
                    "context": datasets.Value("string"),
                    "questions": datasets.features.Sequence(datasets.Value("string")),
                    "answers": datasets.features.Sequence(
                        {"texts": datasets.Value("string"), "answers_starts": datasets.Value("int32")}
                    ),
                    # These are the features of your dataset like images, labels ...
                }
            ),
            homepage=_HOMEPAGE,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        """Returns SplitGenerators."""
        data_dir = os.path.abspath(os.path.expanduser(dl_manager.manual_dir))
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                # These kwargs will be passed to _generate_examples
                gen_kwargs={"filepath": os.path.join(data_dir, "train.json")},
            ),
            datasets.SplitGenerator(
                name=datasets.Split.VALIDATION,
                # These kwargs will be passed to _generate_examples
                gen_kwargs={"filepath": os.path.join(data_dir, "valid.json")},
            ),
        ]

    def _generate_examples(self, filepath):
        """Yields examples."""
        with open(filepath, encoding="utf-8") as f:
            data = json.load(f)
            for id1, examples in enumerate(data["data"]):
                for id2, example in enumerate(examples["paragraphs"]):
                    questions = [question["question"] for question in example["qas"]]
                    answers = [answer["answers"] for answer in example["qas"]]
                    texts = [answer[0]["text"] for answer in answers]
                    answers_starts = [answer[0]["answer_start"] for answer in answers]

                    yield str(id1) + "_" + str(id2), {
                        "context": example["context"],
                        "questions": questions,
                        "answers": {"texts": texts, "answers_starts": answers_starts},
                    }