Datasets:
Tasks:
Question Answering
Languages:
English
Size:
10K<n<100K
ArXiv:
Tags:
knowledge-base-qa
License:
Commit
•
93611e5
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +184 -0
- dataset_infos.json +1 -0
- dummy/0.0.0/dummy_data.zip +3 -0
- grail_qa.py +146 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- crowdsourced
|
4 |
+
language_creators:
|
5 |
+
- found
|
6 |
+
languages:
|
7 |
+
- en
|
8 |
+
licenses:
|
9 |
+
- unknown
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- n<1K
|
14 |
+
source_datasets:
|
15 |
+
- original
|
16 |
+
task_categories:
|
17 |
+
- question-answering
|
18 |
+
task_ids:
|
19 |
+
- question-answering-other-knowledge-base-qa
|
20 |
+
---
|
21 |
+
|
22 |
+
# Dataset Card for Grail QA
|
23 |
+
|
24 |
+
## Table of Contents
|
25 |
+
|
26 |
+
- [Dataset Card for Grail QA](#dataset-card-for-grail-qa)
|
27 |
+
- [Table of Contents](#table-of-contents)
|
28 |
+
- [Dataset Description](#dataset-description)
|
29 |
+
- [Dataset Summary](#dataset-summary)
|
30 |
+
- [What is GrailQA?](#what-is-grailqa)
|
31 |
+
- [Why GrailQA?](#why-grailqa)
|
32 |
+
- [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
|
33 |
+
- [Languages](#languages)
|
34 |
+
- [Dataset Structure](#dataset-structure)
|
35 |
+
- [Data Instances](#data-instances)
|
36 |
+
- [Data Fields](#data-fields)
|
37 |
+
- [Data Splits](#data-splits)
|
38 |
+
- [Dataset Creation](#dataset-creation)
|
39 |
+
- [Curation Rationale](#curation-rationale)
|
40 |
+
- [Source Data](#source-data)
|
41 |
+
- [Initial Data Collection and Normalization](#initial-data-collection-and-normalization)
|
42 |
+
- [Who are the source language producers?](#who-are-the-source-language-producers)
|
43 |
+
- [Annotations](#annotations)
|
44 |
+
- [Annotation process](#annotation-process)
|
45 |
+
- [Who are the annotators?](#who-are-the-annotators)
|
46 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
47 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
48 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
49 |
+
- [Discussion of Biases](#discussion-of-biases)
|
50 |
+
- [Other Known Limitations](#other-known-limitations)
|
51 |
+
- [Additional Information](#additional-information)
|
52 |
+
- [Dataset Curators](#dataset-curators)
|
53 |
+
- [Licensing Information](#licensing-information)
|
54 |
+
- [Citation Information](#citation-information)
|
55 |
+
|
56 |
+
## Dataset Description
|
57 |
+
|
58 |
+
- **Homepage: [Grail QA](https://dki-lab.github.io/GrailQA/)**
|
59 |
+
- **Repository:**
|
60 |
+
- **Paper:[GrailQA paper (Gu et al. '20)](https://arxiv.org/abs/2011.07743)**
|
61 |
+
- **Leaderboard:**
|
62 |
+
- **Point of Contact:**
|
63 |
+
|
64 |
+
### Dataset Summary
|
65 |
+
|
66 |
+
#### What is GrailQA?
|
67 |
+
|
68 |
+
Strongly Generalizable Question Answering (GrailQA) is a new large-scale, high-quality dataset for question answering on knowledge bases (KBQA) on Freebase with 64,331 questions annotated with both answers and corresponding logical forms in different syntax (i.e., SPARQL, S-expression, etc.). It can be used to test three levels of generalization in KBQA: i.i.d., compositional, and zero-shot.
|
69 |
+
|
70 |
+
#### Why GrailQA?
|
71 |
+
|
72 |
+
GrailQA is by far the largest crowdsourced KBQA dataset with questions of high diversity (i.e., questions in GrailQA can have up to 4 relations and optionally have a function from counting, superlatives and comparatives). It also has the highest coverage over Freebase; it widely covers 3,720 relations and 86 domains from Freebase. Last but not least, our meticulous data split allows GrailQA to test not only i.i.d. generalization, but also compositional generalization and zero-shot generalization, which are critical for practical KBQA systems.
|
73 |
+
|
74 |
+
### Supported Tasks and Leaderboards
|
75 |
+
|
76 |
+
[More Information Needed]
|
77 |
+
|
78 |
+
### Languages
|
79 |
+
|
80 |
+
English and Graph query
|
81 |
+
|
82 |
+
## Dataset Structure
|
83 |
+
|
84 |
+
### Data Instances
|
85 |
+
|
86 |
+
[More Information Needed]
|
87 |
+
|
88 |
+
### Data Fields
|
89 |
+
|
90 |
+
- `qid` (`str`)
|
91 |
+
- `question` (`str`)
|
92 |
+
- `answer` (`List`): Defaults to `[]` in test split.
|
93 |
+
- `answer_type` (`str`)
|
94 |
+
- `answer_argument` (`str`)
|
95 |
+
- `entity_name` (`str`): Defauts to `""` if `answer_type` is not `Entity`.
|
96 |
+
- `function` (`string`): Defaults to `""` in test split.
|
97 |
+
- `num_node` (`int`): Defaults to `-1` in test split.
|
98 |
+
- `num_edge` (`int`): Defaults to `-1` in test split.
|
99 |
+
- `graph_query` (`Dict`)
|
100 |
+
- `nodes` (`List`): Defaults to `[]` in test split.
|
101 |
+
- `nid` (`int`)
|
102 |
+
- `node_type` (`str`)
|
103 |
+
- `id` (`str`)
|
104 |
+
- `class` (`str`)
|
105 |
+
- `friendly_name` (`str`)
|
106 |
+
- `question_node` (`int`)
|
107 |
+
- `function` (`str`)
|
108 |
+
- `edges` (`List`): Defaults to `[]` in test split.
|
109 |
+
- `start` (`int`)
|
110 |
+
- `end` (`int`)
|
111 |
+
- `relation` (`str`)
|
112 |
+
- `friendly_name` (`str`)
|
113 |
+
- `sqarql_query` (`str`): Defaults to `""` in test split.
|
114 |
+
- `domains` (`List[str]`): Defaults to `[]` in test split.
|
115 |
+
- `level` (`str`): Only available in validation split. Defaults to `""` in others.
|
116 |
+
- `s_expression` (`str`): Defaults to `""` in test split.
|
117 |
+
|
118 |
+
**Notes:** Only `qid` and `question` available in test split.
|
119 |
+
|
120 |
+
### Data Splits
|
121 |
+
|
122 |
+
Dataset Split | Number of Instances in Split
|
123 |
+
--------------|--------------------------------------------
|
124 |
+
Train | 44,337
|
125 |
+
Validation | 6,763
|
126 |
+
Test | 13,231
|
127 |
+
|
128 |
+
## Dataset Creation
|
129 |
+
|
130 |
+
### Curation Rationale
|
131 |
+
|
132 |
+
[More Information Needed]
|
133 |
+
|
134 |
+
### Source Data
|
135 |
+
|
136 |
+
#### Initial Data Collection and Normalization
|
137 |
+
|
138 |
+
[More Information Needed]
|
139 |
+
|
140 |
+
#### Who are the source language producers?
|
141 |
+
|
142 |
+
[More Information Needed]
|
143 |
+
|
144 |
+
### Annotations
|
145 |
+
|
146 |
+
#### Annotation process
|
147 |
+
|
148 |
+
[More Information Needed]
|
149 |
+
|
150 |
+
#### Who are the annotators?
|
151 |
+
|
152 |
+
[More Information Needed]
|
153 |
+
|
154 |
+
### Personal and Sensitive Information
|
155 |
+
|
156 |
+
[More Information Needed]
|
157 |
+
|
158 |
+
## Considerations for Using the Data
|
159 |
+
|
160 |
+
### Social Impact of Dataset
|
161 |
+
|
162 |
+
[More Information Needed]
|
163 |
+
|
164 |
+
### Discussion of Biases
|
165 |
+
|
166 |
+
[More Information Needed]
|
167 |
+
|
168 |
+
### Other Known Limitations
|
169 |
+
|
170 |
+
[More Information Needed]
|
171 |
+
|
172 |
+
## Additional Information
|
173 |
+
|
174 |
+
### Dataset Curators
|
175 |
+
|
176 |
+
[More Information Needed]
|
177 |
+
|
178 |
+
### Licensing Information
|
179 |
+
|
180 |
+
[More Information Needed]
|
181 |
+
|
182 |
+
### Citation Information
|
183 |
+
|
184 |
+
[More Information Needed]
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"default": {"description": "Strongly Generalizable Question Answering (GrailQA) is a new large-scale, high-quality dataset for question answering on knowledge bases (KBQA) on Freebase with 64,331 questions annotated with both answers and corresponding logical forms in different syntax (i.e., SPARQL, S-expression, etc.). It can be used to test three levels of generalization in KBQA: i.i.d., compositional, and zero-shot.\n", "citation": "@misc{gu2020iid,\n title={Beyond I.I.D.: Three Levels of Generalization for Question Answering on Knowledge Bases},\n author={Yu Gu and Sue Kase and Michelle Vanni and Brian Sadler and Percy Liang and Xifeng Yan and Yu Su},\n year={2020},\n eprint={2011.07743},\n archivePrefix={arXiv},\n primaryClass={cs.CL}\n}\n", "homepage": "https://rajpurkar.github.io/SQuAD-explorer/", "license": "", "features": {"qid": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "answer": {"feature": {"answer_type": {"dtype": "string", "id": null, "_type": "Value"}, "answer_argument": {"dtype": "string", "id": null, "_type": "Value"}, "entity_name": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}, "function": {"dtype": "string", "id": null, "_type": "Value"}, "num_node": {"dtype": "int32", "id": null, "_type": "Value"}, "num_edge": {"dtype": "int32", "id": null, "_type": "Value"}, "graph_query": {"nodes": {"feature": {"nid": {"dtype": "int32", "id": null, "_type": "Value"}, "node_type": {"dtype": "string", "id": null, "_type": "Value"}, "id": {"dtype": "string", "id": null, "_type": "Value"}, "class": {"dtype": "string", "id": null, "_type": "Value"}, "friendly_name": {"dtype": "string", "id": null, "_type": "Value"}, "question_node": {"dtype": "int32", "id": null, "_type": "Value"}, "function": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}, "edges": {"feature": {"start": {"dtype": "int32", "id": null, "_type": "Value"}, "end": {"dtype": "int32", "id": null, "_type": "Value"}, "relation": {"dtype": "string", "id": null, "_type": "Value"}, "friendly_name": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "sparql_query": {"dtype": "string", "id": null, "_type": "Value"}, "domains": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "level": {"dtype": "string", "id": null, "_type": "Value"}, "s_expression": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "grail_qa", "config_name": "default", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 69433121, "num_examples": 44337, "dataset_name": "grail_qa"}, "validation": {"name": "validation", "num_bytes": 9800544, "num_examples": 6763, "dataset_name": "grail_qa"}, "test": {"name": "test", "num_bytes": 2167256, "num_examples": 13231, "dataset_name": "grail_qa"}}, "download_checksums": {"https://dl.orangedox.com/WyaCpL?dl=1": {"num_bytes": 17636773, "checksum": "7717dbae47ba4f6aa8b9df0810db8211460116647c0c06bb26a6b198d0aaa992"}}, "download_size": 17636773, "post_processing_size": null, "dataset_size": 81400921, "size_in_bytes": 99037694}}
|
dummy/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c83c9f81b07b18cbea2b1e52fc1799225410525b3bc1ca303c1652e27238339f
|
3 |
+
size 4838
|
grail_qa.py
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
# Lint as: python3
|
17 |
+
"""GrailQA: The Strongly Generalizable Question Answering Dataset"""
|
18 |
+
|
19 |
+
from __future__ import absolute_import, division, print_function
|
20 |
+
|
21 |
+
import json
|
22 |
+
import logging
|
23 |
+
import os
|
24 |
+
|
25 |
+
import datasets
|
26 |
+
|
27 |
+
|
28 |
+
_CITATION = """\
|
29 |
+
@misc{gu2020iid,
|
30 |
+
title={Beyond I.I.D.: Three Levels of Generalization for Question Answering on Knowledge Bases},
|
31 |
+
author={Yu Gu and Sue Kase and Michelle Vanni and Brian Sadler and Percy Liang and Xifeng Yan and Yu Su},
|
32 |
+
year={2020},
|
33 |
+
eprint={2011.07743},
|
34 |
+
archivePrefix={arXiv},
|
35 |
+
primaryClass={cs.CL}
|
36 |
+
}
|
37 |
+
"""
|
38 |
+
|
39 |
+
_DESCRIPTION = """\
|
40 |
+
Strongly Generalizable Question Answering (GrailQA) is a new large-scale, \
|
41 |
+
high-quality dataset for question answering on knowledge bases (KBQA) on Freebase with 64,331 questions annotated \
|
42 |
+
with both answers and corresponding logical forms in different syntax (i.e., SPARQL, S-expression, etc.). \
|
43 |
+
It can be used to test three levels of generalization in KBQA: i.i.d., compositional, and zero-shot.
|
44 |
+
"""
|
45 |
+
|
46 |
+
_URL = "https://dl.orangedox.com/WyaCpL?dl=1"
|
47 |
+
|
48 |
+
|
49 |
+
class GrailQA(datasets.GeneratorBasedBuilder):
|
50 |
+
"""GrailQA: The Strongly Generalizable Question Answering Dataset"""
|
51 |
+
|
52 |
+
def _info(self):
|
53 |
+
return datasets.DatasetInfo(
|
54 |
+
description=_DESCRIPTION,
|
55 |
+
features=datasets.Features(
|
56 |
+
{
|
57 |
+
"qid": datasets.Value("string"),
|
58 |
+
"question": datasets.Value("string"),
|
59 |
+
"answer": datasets.features.Sequence(
|
60 |
+
{
|
61 |
+
"answer_type": datasets.Value("string"),
|
62 |
+
"answer_argument": datasets.Value("string"),
|
63 |
+
"entity_name": datasets.Value("string"),
|
64 |
+
}
|
65 |
+
),
|
66 |
+
"function": datasets.Value("string"),
|
67 |
+
"num_node": datasets.Value("int32"),
|
68 |
+
"num_edge": datasets.Value("int32"),
|
69 |
+
"graph_query": {
|
70 |
+
"nodes": datasets.features.Sequence(
|
71 |
+
{
|
72 |
+
"nid": datasets.Value("int32"),
|
73 |
+
"node_type": datasets.Value("string"),
|
74 |
+
"id": datasets.Value("string"),
|
75 |
+
"class": datasets.Value("string"),
|
76 |
+
"friendly_name": datasets.Value("string"),
|
77 |
+
"question_node": datasets.Value("int32"),
|
78 |
+
"function": datasets.Value("string"),
|
79 |
+
}
|
80 |
+
),
|
81 |
+
"edges": datasets.features.Sequence(
|
82 |
+
{
|
83 |
+
"start": datasets.Value("int32"),
|
84 |
+
"end": datasets.Value("int32"),
|
85 |
+
"relation": datasets.Value("string"),
|
86 |
+
"friendly_name": datasets.Value("string"),
|
87 |
+
}
|
88 |
+
),
|
89 |
+
},
|
90 |
+
"sparql_query": datasets.Value("string"),
|
91 |
+
"domains": datasets.features.Sequence(datasets.Value("string")),
|
92 |
+
"level": datasets.Value("string"),
|
93 |
+
"s_expression": datasets.Value("string"),
|
94 |
+
}
|
95 |
+
),
|
96 |
+
# No default supervised_keys (as we have to pass both question
|
97 |
+
# and context as input).
|
98 |
+
supervised_keys=None,
|
99 |
+
homepage="https://dki-lab.github.io/GrailQA/",
|
100 |
+
citation=_CITATION,
|
101 |
+
)
|
102 |
+
|
103 |
+
def _split_generators(self, dl_manager):
|
104 |
+
dl_path = os.path.join(dl_manager.download_and_extract(_URL), "GrailQA_v1.0")
|
105 |
+
|
106 |
+
return [
|
107 |
+
datasets.SplitGenerator(
|
108 |
+
name=datasets.Split.TRAIN,
|
109 |
+
gen_kwargs={"filepath": os.path.join(dl_path, "grailqa_v1.0_train.json")},
|
110 |
+
),
|
111 |
+
datasets.SplitGenerator(
|
112 |
+
name=datasets.Split.VALIDATION,
|
113 |
+
gen_kwargs={"filepath": os.path.join(dl_path, "grailqa_v1.0_dev.json")},
|
114 |
+
),
|
115 |
+
datasets.SplitGenerator(
|
116 |
+
name=datasets.Split.TEST,
|
117 |
+
gen_kwargs={"filepath": os.path.join(dl_path, "grailqa_v1.0_test_public.json")},
|
118 |
+
),
|
119 |
+
]
|
120 |
+
|
121 |
+
def _generate_examples(self, filepath):
|
122 |
+
"""This function returns the examples in the raw (text) form."""
|
123 |
+
logging.info("generating examples from = %s", filepath)
|
124 |
+
with open(filepath, encoding="utf-8") as f:
|
125 |
+
samples = json.load(f)
|
126 |
+
for sample in samples:
|
127 |
+
features = {
|
128 |
+
"qid": str(sample["qid"]),
|
129 |
+
"question": sample["question"],
|
130 |
+
"function": sample.get("function", ""),
|
131 |
+
"num_node": sample.get("num_node", -1),
|
132 |
+
"num_edge": sample.get("num_edge", -1),
|
133 |
+
"graph_query": sample.get("graph_query", {"nodes": [], "edges": []}),
|
134 |
+
"sparql_query": sample.get("sparql_query", ""),
|
135 |
+
"domains": sample.get("domains", []),
|
136 |
+
"level": sample.get("level", ""),
|
137 |
+
"s_expression": sample.get("s_expression", ""),
|
138 |
+
}
|
139 |
+
|
140 |
+
answers = sample.get("answer", [])
|
141 |
+
for answer in answers:
|
142 |
+
if "entity_name" not in answer:
|
143 |
+
answer["entity_name"] = ""
|
144 |
+
|
145 |
+
features["answer"] = answers
|
146 |
+
yield sample["qid"], features
|