Datasets:

Languages:
Finnish
License:
emilnuutinen commited on
Commit
7f3d5b1
1 Parent(s): da734e4

Initial commit

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. dev-v2.0.json +0 -0
  3. squad_v2_fi.py +94 -0
  4. train-v2.0.json +3 -0
.gitattributes CHANGED
@@ -52,3 +52,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
52
  *.jpg filter=lfs diff=lfs merge=lfs -text
53
  *.jpeg filter=lfs diff=lfs merge=lfs -text
54
  *.webp filter=lfs diff=lfs merge=lfs -text
55
+ train-v2.0.json filter=lfs diff=lfs merge=lfs -text
dev-v2.0.json ADDED
The diff for this file is too large to render. See raw diff
 
squad_v2_fi.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ import datasets
4
+ from datasets.tasks import QuestionAnsweringExtractive
5
+
6
+ _DESCRIPTION = """\
7
+ combines the 100,000 questions in SQuAD1.1 with over 50,000 unanswerable questions written adversarially by crowdworkers
8
+ to look similar to answerable ones. To do well on SQuAD2.0, systems must not only answer questions when possible, but
9
+ also determine when no answer is supported by the paragraph and abstain from answering.
10
+ """
11
+
12
+
13
+ class SquadV2Config(datasets.BuilderConfig):
14
+ """BuilderConfig for SQUAD."""
15
+
16
+ def __init__(self, **kwargs):
17
+ """BuilderConfig for SQUADV2.
18
+
19
+ Args:
20
+ **kwargs: keyword arguments forwarded to super.
21
+ """
22
+ super(SquadV2Config, self).__init__(**kwargs)
23
+
24
+
25
+ class SquadV2(datasets.GeneratorBasedBuilder):
26
+
27
+ BUILDER_CONFIGS = [
28
+ SquadV2Config(name="squad_v2_fi", version=datasets.Version(
29
+ "1.0.0"), description="Finnish SQuAD v2.0"),
30
+ ]
31
+
32
+ def _info(self):
33
+ return datasets.DatasetInfo(
34
+ description=_DESCRIPTION,
35
+ features=datasets.Features(
36
+ {
37
+ "id": datasets.Value("string"),
38
+ "title": datasets.Value("string"),
39
+ "context": datasets.Value("string"),
40
+ "question": datasets.Value("string"),
41
+ "answers": datasets.features.Sequence(
42
+ {
43
+ "text": datasets.Value("string"),
44
+ "answer_start": datasets.Value("int32"),
45
+ }
46
+ ),
47
+ }
48
+ ),
49
+ supervised_keys=None,
50
+ homepage="https://turkunlp.org/",
51
+ task_templates=[
52
+ QuestionAnsweringExtractive(
53
+ question_column="question", context_column="context", answers_column="answers"
54
+ )
55
+ ],
56
+ )
57
+
58
+ def _split_generators(self, dl_manager):
59
+ """Returns SplitGenerators."""
60
+
61
+ return [
62
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={
63
+ "filepath": "train-v2.0.json"}),
64
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={
65
+ "filepath": "dev-v2.0.json"}),
66
+ ]
67
+
68
+ def _generate_examples(self, filepath):
69
+ """Yields examples."""
70
+ with open(filepath, encoding="utf-8") as f:
71
+ squad = json.load(f)
72
+ for example in squad["data"]:
73
+ title = example.get("title", "")
74
+ for paragraph in example["paragraphs"]:
75
+ context = paragraph["context"]
76
+ for qa in paragraph["qas"]:
77
+ question = qa["question"]
78
+ id_ = qa["id"]
79
+
80
+ answer_starts = [answer["answer_start"]
81
+ for answer in qa["answers"]]
82
+ answers = [answer["text"].strip(
83
+ ' .,-:') for answer in qa["answers"]]
84
+
85
+ yield id_, {
86
+ "title": title,
87
+ "context": context,
88
+ "question": question,
89
+ "id": id_,
90
+ "answers": {
91
+ "answer_start": answer_starts,
92
+ "text": answers,
93
+ },
94
+ }
train-v2.0.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ccf811e33d3f794a39b9a7da0a60e8302ec3304d08224478c8d5756f4d073ea8
3
+ size 55320231