Commit
•
ff0df65
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 +165 -0
- dataset_infos.json +1 -0
- dummy/0.0.0/dummy_data.zip +3 -0
- msr_sqa.py +167 -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,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- crowdsourced
|
4 |
+
language_creators:
|
5 |
+
- found
|
6 |
+
languages:
|
7 |
+
- en
|
8 |
+
licenses:
|
9 |
+
- ms-pl
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- 10K<n<100K
|
14 |
+
source_datasets:
|
15 |
+
- original
|
16 |
+
task_categories:
|
17 |
+
- question-answering
|
18 |
+
task_ids:
|
19 |
+
- extractive-qa
|
20 |
+
---
|
21 |
+
|
22 |
+
# Dataset Card for Microsoft Research Sequential Question Answering
|
23 |
+
|
24 |
+
## Table of Contents
|
25 |
+
|
26 |
+
- [Dataset Card for Microsoft Research Sequential Question Answering](#dataset-card-for-microsoft-research-sequential-question-answering)
|
27 |
+
- [Table of Contents](#table-of-contents)
|
28 |
+
- [Dataset Description](#dataset-description)
|
29 |
+
- [Dataset Summary](#dataset-summary)
|
30 |
+
- [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
|
31 |
+
- [Languages](#languages)
|
32 |
+
- [Dataset Structure](#dataset-structure)
|
33 |
+
- [Data Instances](#data-instances)
|
34 |
+
- [Data Fields](#data-fields)
|
35 |
+
- [Data Splits](#data-splits)
|
36 |
+
- [Dataset Creation](#dataset-creation)
|
37 |
+
- [Curation Rationale](#curation-rationale)
|
38 |
+
- [Source Data](#source-data)
|
39 |
+
- [Initial Data Collection and Normalization](#initial-data-collection-and-normalization)
|
40 |
+
- [Who are the source language producers?](#who-are-the-source-language-producers)
|
41 |
+
- [Annotations](#annotations)
|
42 |
+
- [Annotation process](#annotation-process)
|
43 |
+
- [Who are the annotators?](#who-are-the-annotators)
|
44 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
45 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
46 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
47 |
+
- [Discussion of Biases](#discussion-of-biases)
|
48 |
+
- [Other Known Limitations](#other-known-limitations)
|
49 |
+
- [Additional Information](#additional-information)
|
50 |
+
- [Dataset Curators](#dataset-curators)
|
51 |
+
- [Licensing Information](#licensing-information)
|
52 |
+
- [Citation Information](#citation-information)
|
53 |
+
|
54 |
+
## Dataset Description
|
55 |
+
|
56 |
+
- **Homepage:[Microsoft Research Sequential Question Answering (SQA) Dataset](https://msropendata.com/datasets/b25190ed-0f59-47b1-9211-5962858142c2)**
|
57 |
+
- **Repository:**
|
58 |
+
- **Paper:[https://www.microsoft.com/en-us/research/wp-content/uploads/2017/05/acl17-dynsp.pdf](https://www.microsoft.com/en-us/research/wp-content/uploads/2017/05/acl17-dynsp.pdf)**
|
59 |
+
- **Leaderboard:**
|
60 |
+
- **Point of Contact:**
|
61 |
+
- Scott Wen-tau Yih [email protected]
|
62 |
+
- Mohit Iyyer [email protected]
|
63 |
+
- Ming-Wei Chang [email protected]
|
64 |
+
|
65 |
+
### Dataset Summary
|
66 |
+
|
67 |
+
Recent work in semantic parsing for question answering has focused on long and complicated questions, many of which would seem unnatural if asked in a normal conversation between two humans. In an effort to explore a conversational QA setting, we present a more realistic task: answering sequences of simple but inter-related questions.
|
68 |
+
|
69 |
+
We created SQA by asking crowdsourced workers to decompose 2,022 questions from WikiTableQuestions (WTQ)*, which contains highly-compositional questions about tables from Wikipedia. We had three workers decompose each WTQ question, resulting in a dataset of 6,066 sequences that contain 17,553 questions in total. Each question is also associated with answers in the form of cell locations in the tables.
|
70 |
+
|
71 |
+
- Panupong Pasupat, Percy Liang. "Compositional Semantic Parsing on Semi-Structured Tables" ACL-2015.
|
72 |
+
[http://www-nlp.stanford.edu/software/sempre/wikitable/](http://www-nlp.stanford.edu/software/sempre/wikitable/)
|
73 |
+
|
74 |
+
### Supported Tasks and Leaderboards
|
75 |
+
|
76 |
+
[More Information Needed]
|
77 |
+
|
78 |
+
### Languages
|
79 |
+
|
80 |
+
English
|
81 |
+
|
82 |
+
## Dataset Structure
|
83 |
+
|
84 |
+
### Data Instances
|
85 |
+
|
86 |
+
[More Information Needed]
|
87 |
+
|
88 |
+
### Data Fields
|
89 |
+
|
90 |
+
- `id` (`str`): question sequence id (the id is consistent with those in WTQ)
|
91 |
+
- `annotator` (`int`): `0`, `1`, `2` (the 3 annotators who annotated the question intent)
|
92 |
+
- `position` (`int`): the position of the question in the sequence
|
93 |
+
- `question` (`str`): the question given by the annotator
|
94 |
+
- `table_file` (`str`): the associated table
|
95 |
+
- `table_header` (`List[str]`): a list of headers in the table
|
96 |
+
- `table_data` (`List[List[str]]`): 2d array of data in the table
|
97 |
+
- `answer_coordinates` (`List[Dict]`): the table cell coordinates of the answers (0-based, where 0 is the first row after the table header)
|
98 |
+
- `row_index`
|
99 |
+
- `column_index`
|
100 |
+
- `answer_text` (`List[str]`): the content of the answer cells
|
101 |
+
|
102 |
+
Note that some text fields may contain Tab or LF characters and thus start with quotes.
|
103 |
+
It is recommended to use a CSV parser like the Python CSV package to process the data.
|
104 |
+
|
105 |
+
### Data Splits
|
106 |
+
|
107 |
+
[More Information Needed]
|
108 |
+
|
109 |
+
## Dataset Creation
|
110 |
+
|
111 |
+
### Curation Rationale
|
112 |
+
|
113 |
+
[More Information Needed]
|
114 |
+
|
115 |
+
### Source Data
|
116 |
+
|
117 |
+
#### Initial Data Collection and Normalization
|
118 |
+
|
119 |
+
[More Information Needed]
|
120 |
+
|
121 |
+
#### Who are the source language producers?
|
122 |
+
|
123 |
+
[More Information Needed]
|
124 |
+
|
125 |
+
### Annotations
|
126 |
+
|
127 |
+
#### Annotation process
|
128 |
+
|
129 |
+
[More Information Needed]
|
130 |
+
|
131 |
+
#### Who are the annotators?
|
132 |
+
|
133 |
+
[More Information Needed]
|
134 |
+
|
135 |
+
### Personal and Sensitive Information
|
136 |
+
|
137 |
+
[More Information Needed]
|
138 |
+
|
139 |
+
## Considerations for Using the Data
|
140 |
+
|
141 |
+
### Social Impact of Dataset
|
142 |
+
|
143 |
+
[More Information Needed]
|
144 |
+
|
145 |
+
### Discussion of Biases
|
146 |
+
|
147 |
+
[More Information Needed]
|
148 |
+
|
149 |
+
### Other Known Limitations
|
150 |
+
|
151 |
+
[More Information Needed]
|
152 |
+
|
153 |
+
## Additional Information
|
154 |
+
|
155 |
+
### Dataset Curators
|
156 |
+
|
157 |
+
[More Information Needed]
|
158 |
+
|
159 |
+
### Licensing Information
|
160 |
+
|
161 |
+
[More Information Needed]
|
162 |
+
|
163 |
+
### Citation Information
|
164 |
+
|
165 |
+
[More Information Needed]
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"default": {"description": "Recent work in semantic parsing for question answering has focused on long and complicated questions, many of which would seem unnatural if asked in a normal conversation between two humans. In an effort to explore a conversational QA setting, we present a more realistic task: answering sequences of simple but inter-related questions. We created SQA by asking crowdsourced workers to decompose 2,022 questions from WikiTableQuestions (WTQ), which contains highly-compositional questions about tables from Wikipedia. We had three workers decompose each WTQ question, resulting in a dataset of 6,066 sequences that contain 17,553 questions in total. Each question is also associated with answers in the form of cell locations in the tables.\n", "citation": "@inproceedings{iyyer2017search,\n title={Search-based neural structured learning for sequential question answering},\n author={Iyyer, Mohit and Yih, Wen-tau and Chang, Ming-Wei},\n booktitle={Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},\n pages={1821--1831},\n year={2017}\n}\n", "homepage": "https://msropendata.com/datasets/b25190ed-0f59-47b1-9211-5962858142c2", "license": "Microsoft Research Data License Agreement", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "annotator": {"dtype": "int32", "id": null, "_type": "Value"}, "position": {"dtype": "int32", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}, "table_file": {"dtype": "string", "id": null, "_type": "Value"}, "table_header": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "table_data": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "answer_coordinates": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "answer_text": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "msr_sqa", "config_name": "default", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 22605449, "num_examples": 14541, "dataset_name": "msr_sqa"}, "test": {"name": "test", "num_bytes": 4924516, "num_examples": 3012, "dataset_name": "msr_sqa"}}, "download_checksums": {"https://download.microsoft.com/download/1/D/C/1DC270D2-1B53-4A61-A2E3-88AB3E4E6E1F/SQA%20Release%201.0.zip": {"num_bytes": 4796932, "checksum": "791a07ef90d6e736c186b25009d3c10cb38624b879bb668033445a3ab8892f64"}}, "download_size": 4796932, "post_processing_size": null, "dataset_size": 27529965, "size_in_bytes": 32326897}}
|
dummy/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7e46d5f939a1049a45c605ba21355084b0043e84b5dc6c7dec2717e0aa326510
|
3 |
+
size 2732
|
msr_sqa.py
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors, The Google AI Language Team Authors and the current dataset script contributor.
|
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 |
+
"""Microsoft Research Sequential Question Answering (SQA) Dataset"""
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import ast
|
20 |
+
import csv
|
21 |
+
import os
|
22 |
+
|
23 |
+
import datasets
|
24 |
+
|
25 |
+
|
26 |
+
# TODO: Add BibTeX citation
|
27 |
+
# Find for instance the citation on arxiv or on the dataset repo/website
|
28 |
+
_CITATION = """\
|
29 |
+
@inproceedings{iyyer2017search,
|
30 |
+
title={Search-based neural structured learning for sequential question answering},
|
31 |
+
author={Iyyer, Mohit and Yih, Wen-tau and Chang, Ming-Wei},
|
32 |
+
booktitle={Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)},
|
33 |
+
pages={1821--1831},
|
34 |
+
year={2017}
|
35 |
+
}
|
36 |
+
"""
|
37 |
+
|
38 |
+
_DESCRIPTION = """\
|
39 |
+
Recent work in semantic parsing for question answering has focused on long and complicated questions, \
|
40 |
+
many of which would seem unnatural if asked in a normal conversation between two humans. \
|
41 |
+
In an effort to explore a conversational QA setting, we present a more realistic task: \
|
42 |
+
answering sequences of simple but inter-related questions. We created SQA by asking crowdsourced workers \
|
43 |
+
to decompose 2,022 questions from WikiTableQuestions (WTQ), which contains highly-compositional questions about \
|
44 |
+
tables from Wikipedia. We had three workers decompose each WTQ question, resulting in a dataset of 6,066 sequences \
|
45 |
+
that contain 17,553 questions in total. Each question is also associated with answers in the form of cell \
|
46 |
+
locations in the tables.
|
47 |
+
"""
|
48 |
+
|
49 |
+
_HOMEPAGE = "https://msropendata.com/datasets/b25190ed-0f59-47b1-9211-5962858142c2"
|
50 |
+
|
51 |
+
_LICENSE = "Microsoft Research Data License Agreement"
|
52 |
+
|
53 |
+
_URL = "https://download.microsoft.com/download/1/D/C/1DC270D2-1B53-4A61-A2E3-88AB3E4E6E1F/SQA%20Release%201.0.zip"
|
54 |
+
|
55 |
+
|
56 |
+
def _load_table_data(table_file):
|
57 |
+
"""Load additional data from a csv table file.
|
58 |
+
|
59 |
+
Args:
|
60 |
+
table_file: Path to the csv file.
|
61 |
+
|
62 |
+
Returns:
|
63 |
+
header: a list of headers in the table.
|
64 |
+
data: 2d array of data in the table.
|
65 |
+
"""
|
66 |
+
with open(table_file, encoding="utf-8") as f:
|
67 |
+
lines = f.readlines()
|
68 |
+
header = lines[0].strip().split(",")
|
69 |
+
data = [line.strip().split(",") for line in lines[1:]]
|
70 |
+
return header, data
|
71 |
+
|
72 |
+
|
73 |
+
def _parse_answer_coordinates(answer_coordinate_str):
|
74 |
+
"""Parsing answer_coordinates field to a list of answer coordinates.
|
75 |
+
The original code is from https://github.com/google-research/tapas.
|
76 |
+
|
77 |
+
Args:
|
78 |
+
answer_coordinate_str: A string representation of a Python list of tuple
|
79 |
+
strings.
|
80 |
+
For example: "['(1, 4)','(1, 3)', ...]"
|
81 |
+
|
82 |
+
Returns:
|
83 |
+
answer_coordinates: A list of answer cordinates.
|
84 |
+
"""
|
85 |
+
try:
|
86 |
+
answer_coordinates = []
|
87 |
+
coords = ast.literal_eval(answer_coordinate_str)
|
88 |
+
for row_index, column_index in sorted(ast.literal_eval(coord) for coord in coords):
|
89 |
+
answer_coordinates.append({"row_index": row_index, "column_index": column_index})
|
90 |
+
return answer_coordinates
|
91 |
+
except SyntaxError:
|
92 |
+
raise ValueError("Unable to evaluate %s" % answer_coordinate_str)
|
93 |
+
|
94 |
+
|
95 |
+
def _parse_answer_text(answer_text_str):
|
96 |
+
"""Parsing `answer_text` field to list of answers.
|
97 |
+
The original code is from https://github.com/google-research/tapas.
|
98 |
+
Args:
|
99 |
+
answer_text_str: A string representation of a Python list of strings.
|
100 |
+
For example: "[u'test', u'hello', ...]"
|
101 |
+
|
102 |
+
Returns:
|
103 |
+
answer_texts: A list of answers.
|
104 |
+
"""
|
105 |
+
try:
|
106 |
+
answer_texts = []
|
107 |
+
for value in ast.literal_eval(answer_text_str):
|
108 |
+
answer_texts.append(value)
|
109 |
+
return answer_texts
|
110 |
+
except SyntaxError:
|
111 |
+
raise ValueError("Unable to evaluate %s" % answer_text_str)
|
112 |
+
|
113 |
+
|
114 |
+
class MsrSQA(datasets.GeneratorBasedBuilder):
|
115 |
+
"""Microsoft Research Sequential Question Answering (SQA) Dataset"""
|
116 |
+
|
117 |
+
def _info(self):
|
118 |
+
return datasets.DatasetInfo(
|
119 |
+
description=_DESCRIPTION,
|
120 |
+
features=datasets.Features(
|
121 |
+
{
|
122 |
+
"id": datasets.Value("string"),
|
123 |
+
"annotator": datasets.Value("int32"),
|
124 |
+
"position": datasets.Value("int32"),
|
125 |
+
"question": datasets.Value("string"),
|
126 |
+
"table_file": datasets.Value("string"),
|
127 |
+
"table_header": datasets.features.Sequence(datasets.Value("string")),
|
128 |
+
"table_data": datasets.features.Sequence(datasets.features.Sequence(datasets.Value("string"))),
|
129 |
+
"answer_coordinates": datasets.features.Sequence(
|
130 |
+
{"row_index": datasets.Value("int32"), "column_index": datasets.Value("int32")}
|
131 |
+
),
|
132 |
+
"answer_text": datasets.features.Sequence(datasets.Value("string")),
|
133 |
+
}
|
134 |
+
),
|
135 |
+
supervised_keys=None,
|
136 |
+
homepage=_HOMEPAGE,
|
137 |
+
license=_LICENSE,
|
138 |
+
citation=_CITATION,
|
139 |
+
)
|
140 |
+
|
141 |
+
def _split_generators(self, dl_manager):
|
142 |
+
"""Returns SplitGenerators."""
|
143 |
+
data_dir = os.path.join(dl_manager.download_and_extract(_URL), "SQA Release 1.0")
|
144 |
+
return [
|
145 |
+
datasets.SplitGenerator(
|
146 |
+
name=datasets.Split.TRAIN,
|
147 |
+
gen_kwargs={"filepath": os.path.join(data_dir, "train.tsv"), "data_dir": data_dir},
|
148 |
+
),
|
149 |
+
datasets.SplitGenerator(
|
150 |
+
name=datasets.Split.TEST,
|
151 |
+
gen_kwargs={"filepath": os.path.join(data_dir, "test.tsv"), "data_dir": data_dir},
|
152 |
+
),
|
153 |
+
]
|
154 |
+
|
155 |
+
def _generate_examples(self, filepath, data_dir):
|
156 |
+
""" Yields examples. """
|
157 |
+
|
158 |
+
with open(filepath, encoding="utf-8") as f:
|
159 |
+
reader = csv.DictReader(f, delimiter="\t")
|
160 |
+
for row in reader:
|
161 |
+
item = dict(row)
|
162 |
+
item["answer_text"] = _parse_answer_text(item["answer_text"])
|
163 |
+
item["answer_coordinates"] = _parse_answer_coordinates(item["answer_coordinates"])
|
164 |
+
header, table_data = _load_table_data(os.path.join(data_dir, item["table_file"]))
|
165 |
+
item["table_header"] = header
|
166 |
+
item["table_data"] = table_data
|
167 |
+
yield item["id"], item
|