Datasets:
Commit
•
3735fe5
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 +177 -0
- dataset_infos.json +1 -0
- dummy/plain_text/1.0.0/dummy_data.zip +3 -0
- qa_srl.py +182 -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,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- expert-generated
|
4 |
+
language_creators:
|
5 |
+
- expert-generated
|
6 |
+
languages:
|
7 |
+
- en
|
8 |
+
licenses:
|
9 |
+
- unknown
|
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 |
+
- multiple-choice-qa
|
20 |
+
- open-domain-qa
|
21 |
+
---
|
22 |
+
|
23 |
+
# Dataset Card for QA-SRL
|
24 |
+
|
25 |
+
## Table of Contents
|
26 |
+
- [Dataset Description](#dataset-description)
|
27 |
+
- [Dataset Summary](#dataset-summary)
|
28 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
29 |
+
- [Languages](#languages)
|
30 |
+
- [Dataset Structure](#dataset-structure)
|
31 |
+
- [Data Instances](#data-instances)
|
32 |
+
- [Data Fields](#data-fields)
|
33 |
+
- [Data Splits](#data-splits)
|
34 |
+
- [Dataset Creation](#dataset-creation)
|
35 |
+
- [Curation Rationale](#curation-rationale)
|
36 |
+
- [Source Data](#source-data)
|
37 |
+
- [Annotations](#annotations)
|
38 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
39 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
40 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
41 |
+
- [Discussion of Biases](#discussion-of-biases)
|
42 |
+
- [Other Known Limitations](#other-known-limitations)
|
43 |
+
- [Additional Information](#additional-information)
|
44 |
+
- [Dataset Curators](#dataset-curators)
|
45 |
+
- [Licensing Information](#licensing-information)
|
46 |
+
- [Citation Information](#citation-information)
|
47 |
+
|
48 |
+
## Dataset Description
|
49 |
+
|
50 |
+
- **Homepage:** [Homepage](https://dada.cs.washington.edu/qasrl/#page-top)
|
51 |
+
- **Annotation Tool:** [Annotation tool](https://github.com/luheng/qasrl_annotation)
|
52 |
+
- **Repository:** [Repository](https://dada.cs.washington.edu/qasrl/#dataset)
|
53 |
+
- **Paper:** [Qa_srl paper](https://www.aclweb.org/anthology/D15-1076.pdf)
|
54 |
+
- **Point of Contact:** [Luheng He](luheng@cs.washington.edu)
|
55 |
+
|
56 |
+
|
57 |
+
### Dataset Summary
|
58 |
+
|
59 |
+
we model predicate-argument structure of a sentence with a set of question-answer pairs. our method allows practical large-scale annotation of training data. We focus on semantic rather than syntactic annotation, and introduce a scalable method for gathering data that allows both training and evaluation.
|
60 |
+
|
61 |
+
### Supported Tasks and Leaderboards
|
62 |
+
|
63 |
+
[More Information Needed]
|
64 |
+
|
65 |
+
### Languages
|
66 |
+
|
67 |
+
This dataset is in english language.
|
68 |
+
|
69 |
+
## Dataset Structure
|
70 |
+
|
71 |
+
### Data Instances
|
72 |
+
|
73 |
+
|
74 |
+
We use question-answer pairs to model verbal predicate-argument structure. The questions start with wh-words (Who, What, Where, What, etc.) and contains a verb predicate in the sentence; the answers are phrases in the sentence. For example:
|
75 |
+
|
76 |
+
`UCD finished the 2006 championship as Dublin champions , by beating St Vincents in the final .`
|
77 |
+
|
78 |
+
Predicate | Question | Answer
|
79 |
+
---|---|---|
|
80 |
+
|Finished|Who finished something? | UCD
|
81 |
+
|Finished|What did someone finish?|the 2006 championship
|
82 |
+
|Finished|What did someone finish something as? |Dublin champions
|
83 |
+
|Finished|How did someone finish something? |by beating St Vincents in the final
|
84 |
+
|beating | Who beat someone? | UCD
|
85 |
+
|beating|When did someone beat someone? |in the final
|
86 |
+
|beating|Who did someone beat?| St Vincents
|
87 |
+
|
88 |
+
### Data Fields
|
89 |
+
|
90 |
+
Annotations provided are as follows:
|
91 |
+
|
92 |
+
- `sentence`: contains tokenized sentence
|
93 |
+
- `sent_id`: is the sentence identifier
|
94 |
+
- `predicate_idx`:the index of the predicate (its position in the sentence)
|
95 |
+
- `predicate`: the predicate token
|
96 |
+
- `question`: contains the question which is a list of tokens. The question always consists of seven slots, as defined in the paper. The empty slots are represented with a marker “_”. The question ends with question mark.
|
97 |
+
- `answer`: list of answers to the question
|
98 |
+
|
99 |
+
|
100 |
+
### Data Splits
|
101 |
+
|
102 |
+
Dataset | Sentences | Verbs | QAs
|
103 |
+
--- | --- | --- |---|
|
104 |
+
**newswire-train**|744|2020|4904|
|
105 |
+
**newswire-dev**|249|664|1606|
|
106 |
+
**newswire-test**|248|652|1599
|
107 |
+
**Wikipedia-train**|`1174`|`2647`|`6414`|
|
108 |
+
**Wikipedia-dev**|`392`|`895`|`2183`|
|
109 |
+
**Wikipedia-test**|`393`|`898`|`2201`|
|
110 |
+
|
111 |
+
**Please note**
|
112 |
+
This dataset only has wikipedia data. Newswire dataset needs CoNLL-2009 English training data to get the complete data. This training data is under license. Thus, newswire dataset is not included in this data.
|
113 |
+
|
114 |
+
## Dataset Creation
|
115 |
+
|
116 |
+
### Curation Rationale
|
117 |
+
|
118 |
+
[More Information Needed]
|
119 |
+
|
120 |
+
### Source Data
|
121 |
+
|
122 |
+
#### Initial Data Collection and Normalization
|
123 |
+
|
124 |
+
We annotated over 3000 sentences (nearly 8,000 verbs) in total across two domains: newswire (PropBank) and Wikipedia.
|
125 |
+
#### Who are the source language producers?
|
126 |
+
|
127 |
+
[More Information Needed]
|
128 |
+
|
129 |
+
### Annotations
|
130 |
+
|
131 |
+
#### Annotation process
|
132 |
+
|
133 |
+
non-expert annotators were given a short tutorial and a small set of sample annotations (about 10 sentences). Annotators were hired if they showed good understanding of English and the task. The entire screening process usually took less than 2 hours.
|
134 |
+
|
135 |
+
#### Who are the annotators?
|
136 |
+
|
137 |
+
10 part-time, non-exper annotators from Upwork (Previously oDesk)
|
138 |
+
|
139 |
+
### Personal and Sensitive Information
|
140 |
+
|
141 |
+
[More Information Needed]
|
142 |
+
|
143 |
+
## Considerations for Using the Data
|
144 |
+
|
145 |
+
### Social Impact of Dataset
|
146 |
+
|
147 |
+
[More Information Needed]
|
148 |
+
|
149 |
+
### Discussion of Biases
|
150 |
+
|
151 |
+
[More Information Needed]
|
152 |
+
|
153 |
+
### Other Known Limitations
|
154 |
+
|
155 |
+
[More Information Needed]
|
156 |
+
|
157 |
+
## Additional Information
|
158 |
+
|
159 |
+
### Dataset Curators
|
160 |
+
|
161 |
+
[Luheng He](luheng@cs.washington.edu)
|
162 |
+
|
163 |
+
### Licensing Information
|
164 |
+
|
165 |
+
[More Information Needed]
|
166 |
+
|
167 |
+
### Citation Information
|
168 |
+
|
169 |
+
```
|
170 |
+
@InProceedings{huggingface:dataset,
|
171 |
+
title = {QA-SRL: Question-Answer Driven Semantic Role Labeling},
|
172 |
+
authors={Luheng He, Mike Lewis, Luke Zettlemoyer},
|
173 |
+
year={2015}
|
174 |
+
publisher = {cs.washington.edu},
|
175 |
+
howpublished={\\url{https://dada.cs.washington.edu/qasrl/#page-top}},
|
176 |
+
}
|
177 |
+
```
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"plain_text": {"description": "The dataset contains question-answer pairs to model verbal predicate-argument structure. The questions start with wh-words (Who, What, Where, What, etc.) and contain a verb predicate in the sentence; the answers are phrases in the sentence. \nThere were 2 datsets used in the paper, newswire and wikipedia. Unfortunately the newswiredataset is built from CoNLL-2009 English training set that is covered under license\nThus, we are providing only Wikipedia training set here. Please check README.md for more details on newswire dataset.\nFor the Wikipedia domain, randomly sampled sentences from the English Wikipedia (excluding questions and sentences with fewer than 10 or more than 60 words) were taken.\nThis new dataset is designed to solve this great NLP task and is crafted with a lot of care. \n", "citation": "@InProceedings{huggingface:dataset,\ntitle = {QA-SRL: Question-Answer Driven Semantic Role Labeling},\nauthors={Luheng He, Mike Lewis, Luke Zettlemoyer},\nyear={2015}\npublisher = {cs.washington.edu},\nhowpublished={\\url{https://dada.cs.washington.edu/qasrl/#page-top}},\n}\n", "homepage": "https://dada.cs.washington.edu/qasrl/#page-top", "license": "", "features": {"sentence": {"dtype": "string", "id": null, "_type": "Value"}, "sent_id": {"dtype": "string", "id": null, "_type": "Value"}, "predicate_idx": {"dtype": "int32", "id": null, "_type": "Value"}, "predicate": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "answers": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "qa_srl", "config_name": "plain_text", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1835549, "num_examples": 6414, "dataset_name": "qa_srl"}, "validation": {"name": "validation", "num_bytes": 632992, "num_examples": 2183, "dataset_name": "qa_srl"}, "test": {"name": "test", "num_bytes": 637317, "num_examples": 2201, "dataset_name": "qa_srl"}}, "download_checksums": {"https://dada.cs.washington.edu/qasrl/data/wiki1.train.qa": {"num_bytes": 646763, "checksum": "f927417e94e67b7ae17e33dd882989a5556d7ff37376f8bf5c78ece7d17a6c64"}, "https://dada.cs.washington.edu/qasrl/data/wiki1.dev.qa": {"num_bytes": 222666, "checksum": "caa94beaaf22304422cdc1a2fd8732b1a47401c9555a81e1f4da81e0a7557a8b"}, "https://dada.cs.washington.edu/qasrl/data/wiki1.test.qa": {"num_bytes": 218300, "checksum": "b43a998344fbd520955fb8f0f7b3691ace363daa8628552cf5cf5c8d84df6cca"}}, "download_size": 1087729, "post_processing_size": null, "dataset_size": 3105858, "size_in_bytes": 4193587}}
|
dummy/plain_text/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:84383e89d04d45c9a69eabed98dca2b5fe60980b87e19a707637f6cbf03cb54b
|
3 |
+
size 1205
|
qa_srl.py
ADDED
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets 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 |
+
"""TODO: Add a description here."""
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import datasets
|
20 |
+
|
21 |
+
|
22 |
+
_CITATION = """\
|
23 |
+
@InProceedings{huggingface:dataset,
|
24 |
+
title = {QA-SRL: Question-Answer Driven Semantic Role Labeling},
|
25 |
+
authors={Luheng He, Mike Lewis, Luke Zettlemoyer},
|
26 |
+
year={2015}
|
27 |
+
publisher = {cs.washington.edu},
|
28 |
+
howpublished={\\url{https://dada.cs.washington.edu/qasrl/#page-top}},
|
29 |
+
}
|
30 |
+
"""
|
31 |
+
|
32 |
+
|
33 |
+
_DESCRIPTION = """\
|
34 |
+
The dataset contains question-answer pairs to model verbal predicate-argument structure. The questions start with wh-words (Who, What, Where, What, etc.) and contain a verb predicate in the sentence; the answers are phrases in the sentence.
|
35 |
+
There were 2 datsets used in the paper, newswire and wikipedia. Unfortunately the newswiredataset is built from CoNLL-2009 English training set that is covered under license
|
36 |
+
Thus, we are providing only Wikipedia training set here. Please check README.md for more details on newswire dataset.
|
37 |
+
For the Wikipedia domain, randomly sampled sentences from the English Wikipedia (excluding questions and sentences with fewer than 10 or more than 60 words) were taken.
|
38 |
+
This new dataset is designed to solve this great NLP task and is crafted with a lot of care.
|
39 |
+
"""
|
40 |
+
|
41 |
+
_HOMEPAGE = "https://dada.cs.washington.edu/qasrl/#page-top"
|
42 |
+
|
43 |
+
# TODO: Add the licence for the dataset here if you can find it
|
44 |
+
_LICENSE = ""
|
45 |
+
|
46 |
+
|
47 |
+
_URLs = {
|
48 |
+
"wiki_train": "https://dada.cs.washington.edu/qasrl/data/wiki1.train.qa",
|
49 |
+
"wiki_dev": "https://dada.cs.washington.edu/qasrl/data/wiki1.dev.qa",
|
50 |
+
"wiki_test": "https://dada.cs.washington.edu/qasrl/data/wiki1.test.qa",
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
55 |
+
class QaSrl(datasets.GeneratorBasedBuilder):
|
56 |
+
"""QA-SRL: Question-Answer Driven Semantic Role Labeling (qa_srl) corpus"""
|
57 |
+
|
58 |
+
VERSION = datasets.Version("1.0.0")
|
59 |
+
|
60 |
+
BUILDER_CONFIGS = [
|
61 |
+
datasets.BuilderConfig(
|
62 |
+
name="plain_text", version=VERSION, description="This provides WIKIPEDIA dataset for qa_srl corpus"
|
63 |
+
),
|
64 |
+
]
|
65 |
+
|
66 |
+
DEFAULT_CONFIG_NAME = (
|
67 |
+
"plain_text" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
68 |
+
)
|
69 |
+
|
70 |
+
def _info(self):
|
71 |
+
features = datasets.Features(
|
72 |
+
{
|
73 |
+
"sentence": datasets.Value("string"),
|
74 |
+
"sent_id": datasets.Value("string"),
|
75 |
+
"predicate_idx": datasets.Value("int32"),
|
76 |
+
"predicate": datasets.Value("string"),
|
77 |
+
"question": datasets.Sequence(datasets.Value("string")),
|
78 |
+
"answers": datasets.Sequence(datasets.Value("string")),
|
79 |
+
}
|
80 |
+
)
|
81 |
+
return datasets.DatasetInfo(
|
82 |
+
# This is the description that will appear on the datasets page.
|
83 |
+
description=_DESCRIPTION,
|
84 |
+
# This defines the different columns of the dataset and their types
|
85 |
+
features=features, # Here we define them above because they are different between the two configurations
|
86 |
+
# If there's a common (input, target) tuple from the features,
|
87 |
+
# specify them here. They'll be used if as_supervised=True in
|
88 |
+
# builder.as_dataset.
|
89 |
+
supervised_keys=None,
|
90 |
+
# Homepage of the dataset for documentation
|
91 |
+
homepage=_HOMEPAGE,
|
92 |
+
# License for the dataset if available
|
93 |
+
license=_LICENSE,
|
94 |
+
# Citation for the dataset
|
95 |
+
citation=_CITATION,
|
96 |
+
)
|
97 |
+
|
98 |
+
def _split_generators(self, dl_manager):
|
99 |
+
"""Returns SplitGenerators."""
|
100 |
+
|
101 |
+
train_fpath = dl_manager.download(_URLs["wiki_train"])
|
102 |
+
dev_fpath = dl_manager.download(_URLs["wiki_dev"])
|
103 |
+
test_fpath = dl_manager.download(_URLs["wiki_test"])
|
104 |
+
|
105 |
+
return [
|
106 |
+
datasets.SplitGenerator(
|
107 |
+
name=datasets.Split.TRAIN,
|
108 |
+
# These kwargs will be passed to _generate_examples
|
109 |
+
gen_kwargs={
|
110 |
+
"filepath": train_fpath,
|
111 |
+
},
|
112 |
+
),
|
113 |
+
datasets.SplitGenerator(
|
114 |
+
name=datasets.Split.VALIDATION,
|
115 |
+
# These kwargs will be passed to _generate_examples
|
116 |
+
gen_kwargs={
|
117 |
+
"filepath": dev_fpath,
|
118 |
+
},
|
119 |
+
),
|
120 |
+
datasets.SplitGenerator(
|
121 |
+
name=datasets.Split.TEST,
|
122 |
+
# These kwargs will be passed to _generate_examples
|
123 |
+
gen_kwargs={
|
124 |
+
"filepath": test_fpath,
|
125 |
+
},
|
126 |
+
),
|
127 |
+
]
|
128 |
+
|
129 |
+
def _generate_examples(self, filepath):
|
130 |
+
|
131 |
+
""" Yields examples. """
|
132 |
+
|
133 |
+
with open(filepath, encoding="utf-8") as f:
|
134 |
+
|
135 |
+
qa_counter = 0
|
136 |
+
# Start reading entries
|
137 |
+
sent_id, predicates_cnt = f.readline().rstrip("\n").split("\t")
|
138 |
+
while True:
|
139 |
+
|
140 |
+
sentence = f.readline().rstrip("\n")
|
141 |
+
|
142 |
+
# Loop for every predicate
|
143 |
+
predicates_counter = int(predicates_cnt)
|
144 |
+
while predicates_counter != 0:
|
145 |
+
predicates_counter -= 1
|
146 |
+
predicate_details = f.readline().rstrip("\n").split("\t")
|
147 |
+
predicate_idx, predicate, qa_pairs_cnt = (
|
148 |
+
predicate_details[0],
|
149 |
+
predicate_details[1],
|
150 |
+
predicate_details[2],
|
151 |
+
)
|
152 |
+
pairs = int(qa_pairs_cnt)
|
153 |
+
|
154 |
+
while pairs != 0:
|
155 |
+
pairs -= 1
|
156 |
+
line = f.readline().rstrip("\n").split("\t")
|
157 |
+
question = line[:8]
|
158 |
+
answers_list = line[8:]
|
159 |
+
qa_counter += 1
|
160 |
+
|
161 |
+
if "###" in answers_list[0]:
|
162 |
+
answers = [answer.strip() for answer in answers_list[0].split("###")]
|
163 |
+
else:
|
164 |
+
answers = answers_list
|
165 |
+
|
166 |
+
yield qa_counter, {
|
167 |
+
"sentence": sentence,
|
168 |
+
"sent_id": sent_id,
|
169 |
+
"predicate_idx": predicate_idx,
|
170 |
+
"predicate": predicate,
|
171 |
+
"question": question,
|
172 |
+
"answers": answers,
|
173 |
+
}
|
174 |
+
|
175 |
+
# Pass the blank line
|
176 |
+
f.readline()
|
177 |
+
nextline = f.readline()
|
178 |
+
if not nextline:
|
179 |
+
|
180 |
+
break
|
181 |
+
else:
|
182 |
+
sent_id, predicates_cnt = nextline.rstrip("\n").split("\t")
|