arduwa commited on
Commit
99daf87
1 Parent(s): 773f1d2

Upload 4 files

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. README.md +24 -0
  3. poquad-dev.json +0 -0
  4. poquad-train.json +3 -0
  5. poquad.py +132 -0
.gitattributes CHANGED
@@ -53,3 +53,4 @@ 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
+ poquad-train.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language_creators:
5
+ - found
6
+ language:
7
+ - pl
8
+ license:
9
+ - cc-by-4.0
10
+ multilinguality:
11
+ - monolingual
12
+ pretty_name: PoQuaD
13
+ size_categories:
14
+ - 10K<n<100K
15
+ source_datasets:
16
+ - original
17
+ task_categories:
18
+ - question-answering
19
+ task_ids:
20
+ - extractive-qa
21
+ - open-domain-qa
22
+ ---
23
+
24
+ PoQuaD dataset
poquad-dev.json ADDED
The diff for this file is too large to render. See raw diff
 
poquad-train.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b1ac3acabb49fedb7bb7db0de0690ddb22585d6419321589cc1bb0a8068a4ff9
3
+ size 47183344
poquad.py ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FROM SQUAD_V2"""
2
+
3
+
4
+ import json
5
+
6
+ import datasets
7
+ from datasets.tasks import QuestionAnsweringExtractive
8
+
9
+
10
+ # TODO(squad_v2): BibTeX citation
11
+ _CITATION = """\
12
+ Tuora, R., Zawadzka-Paluektau, N., Klamra, C., Zwierzchowska, A., Kobyliński, Ł. (2022).
13
+ Towards a Polish Question Answering Dataset (PoQuAD).
14
+ In: Tseng, YH., Katsurai, M., Nguyen, H.N. (eds) From Born-Physical to Born-Virtual: Augmenting Intelligence in Digital Libraries. ICADL 2022.
15
+ Lecture Notes in Computer Science, vol 13636. Springer, Cham.
16
+ https://doi.org/10.1007/978-3-031-21756-2_16
17
+ """
18
+
19
+ _DESCRIPTION = """\
20
+ PoQuaD description
21
+ """
22
+
23
+
24
+ _URLS = {
25
+ "train": "poquad-train.json",
26
+ "dev": "poquad-dev.json",
27
+ }
28
+
29
+
30
+ class SquadV2Config(datasets.BuilderConfig):
31
+ """BuilderConfig for SQUAD."""
32
+
33
+ def __init__(self, **kwargs):
34
+ """BuilderConfig for SQUADV2.
35
+ Args:
36
+ **kwargs: keyword arguments forwarded to super.
37
+ """
38
+ super(SquadV2Config, self).__init__(**kwargs)
39
+
40
+
41
+ class SquadV2(datasets.GeneratorBasedBuilder):
42
+ """TODO(squad_v2): Short description of my dataset."""
43
+
44
+ # TODO(squad_v2): Set up version.
45
+ BUILDER_CONFIGS = [
46
+ SquadV2Config(name="poquad", version=datasets.Version("1.0.0"), description="PoQuaD plaint text"),
47
+ ]
48
+
49
+ def _info(self):
50
+ # TODO(squad_v2): 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
+ "id": datasets.Value("string"),
58
+ "title": datasets.Value("string"),
59
+ "context": datasets.Value("string"),
60
+ "question": datasets.Value("string"),
61
+ "answers": datasets.features.Sequence(
62
+ {
63
+ "text": datasets.Value("string"),
64
+ "answer_start": datasets.Value("int32"),
65
+ }
66
+ ),
67
+ # These are the features of your dataset like images, labels ...
68
+ }
69
+ ),
70
+ # If there's a common (input, target) tuple from the features,
71
+ # specify them here. They'll be used if as_supervised=True in
72
+ # builder.as_dataset.
73
+ supervised_keys=None,
74
+ # Homepage of the dataset for documentation
75
+ homepage="https://rajpurkar.github.io/SQuAD-explorer/",
76
+ citation=_CITATION,
77
+ task_templates=[
78
+ QuestionAnsweringExtractive(
79
+ question_column="question", context_column="context", answers_column="answers"
80
+ )
81
+ ],
82
+ )
83
+
84
+ def _split_generators(self, dl_manager):
85
+ """Returns SplitGenerators."""
86
+ # TODO(squad_v2): Downloads the data and defines the splits
87
+ # dl_manager is a datasets.download.DownloadManager that can be used to
88
+ # download and extract URLs
89
+ urls_to_download = _URLS
90
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
91
+
92
+ return [
93
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
94
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
95
+ ]
96
+
97
+ def _generate_examples(self, filepath):
98
+ """Yields examples."""
99
+ # TODO(squad_v2): Yields (key, example) tuples from the dataset
100
+ with open(filepath, encoding="utf-8") as f:
101
+ squad = json.load(f)
102
+ id_ = 0
103
+ for example in squad["data"]:
104
+ title = example.get("title", "")
105
+ # paragraph_id = example["id"]
106
+ for paragraph in example["paragraphs"]:
107
+ context = paragraph["context"] # do not strip leading blank spaces GH-2585
108
+ for qa in paragraph["qas"]:
109
+ question = qa["question"]
110
+
111
+ if "answers" not in qa:
112
+ continue
113
+ answer_starts = [answer["answer_start"] for answer in qa["answers"]]
114
+ #answer_ends = [answer["answer_end"] for answer in qa["answers"]]
115
+ answers = [answer["text"] for answer in qa["answers"]]
116
+ is_impossible = qa["is_impossible"]
117
+ # Features currently used are "context", "question", and "answers".
118
+ # Others are extracted here for the ease of future expansions.
119
+ id_ += 1
120
+ yield str(id_), {
121
+ "id": str(id_),
122
+ "title": title,
123
+ "context": context,
124
+ "question": question,
125
+ "is_impossible" : is_impossible,
126
+ # "paragraph_id": paragraph_id,
127
+ "answers": {
128
+ "answer_start": answer_starts,
129
+ #"answer_end": answer_ends,
130
+ "text": answers,
131
+ },
132
+ }