Commit
·
5eafe8f
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 +148 -0
- dataset_infos.json +1 -0
- dummy/annotated/1.0.0/dummy_data.zip +3 -0
- dummy/freebase2m/1.0.0/dummy_data.zip +3 -0
- dummy/freebase5m/1.0.0/dummy_data.zip +3 -0
- simple_questions_v2.py +168 -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,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- machine-generated
|
4 |
+
language_creators:
|
5 |
+
- found
|
6 |
+
languages:
|
7 |
+
- en
|
8 |
+
licenses:
|
9 |
+
- cc-by-3-0-at
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- 100K<n<1M
|
14 |
+
source_datasets: []
|
15 |
+
task_categories:
|
16 |
+
- question-answering
|
17 |
+
task_ids:
|
18 |
+
- open-domain-qa
|
19 |
+
---
|
20 |
+
|
21 |
+
# Dataset Card Creation Guide
|
22 |
+
|
23 |
+
## Table of Contents
|
24 |
+
- [Dataset Description](#dataset-description)
|
25 |
+
- [Dataset Summary](#dataset-summary)
|
26 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
27 |
+
- [Languages](#languages)
|
28 |
+
- [Dataset Structure](#dataset-structure)
|
29 |
+
- [Data Instances](#data-instances)
|
30 |
+
- [Data Fields](#data-instances)
|
31 |
+
- [Data Splits](#data-instances)
|
32 |
+
- [Dataset Creation](#dataset-creation)
|
33 |
+
- [Curation Rationale](#curation-rationale)
|
34 |
+
- [Source Data](#source-data)
|
35 |
+
- [Annotations](#annotations)
|
36 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
37 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
38 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
39 |
+
- [Discussion of Biases](#discussion-of-biases)
|
40 |
+
- [Other Known Limitations](#other-known-limitations)
|
41 |
+
- [Additional Information](#additional-information)
|
42 |
+
- [Dataset Curators](#dataset-curators)
|
43 |
+
- [Licensing Information](#licensing-information)
|
44 |
+
- [Citation Information](#citation-information)
|
45 |
+
|
46 |
+
## Dataset Description
|
47 |
+
|
48 |
+
- **Homepage:** https://research.fb.com/downloads/babi/
|
49 |
+
- **Repository:** https://github.com/fbougares/TSAC
|
50 |
+
- **Paper:** https://research.fb.com/publications/large-scale-simple-question-answering-with-memory-networks/
|
51 |
+
- **Leaderboard:** [If the dataset supports an active leaderboard, add link here]()
|
52 |
+
- **Point of Contact:** Antoine Bordes ([email protected]) Nicolas Usunier ([email protected]) Sumit Chopra ([email protected]), Jason Weston([email protected])
|
53 |
+
|
54 |
+
### Dataset Summary
|
55 |
+
|
56 |
+
[More Information Needed]
|
57 |
+
|
58 |
+
### Supported Tasks and Leaderboards
|
59 |
+
|
60 |
+
[More Information Needed]
|
61 |
+
|
62 |
+
### Languages
|
63 |
+
|
64 |
+
[More Information Needed]
|
65 |
+
|
66 |
+
## Dataset Structure
|
67 |
+
|
68 |
+
### Data Instances
|
69 |
+
|
70 |
+
Here are some examples of questions and facts:
|
71 |
+
|
72 |
+
* What American cartoonist is the creator of Andy Lippincott?
|
73 |
+
Fact: (andy_lippincott, character_created_by, garry_trudeau)
|
74 |
+
* Which forest is Fires Creek in?
|
75 |
+
Fact: (fires_creek, containedby, nantahala_national_forest)
|
76 |
+
* What does Jimmy Neutron do?
|
77 |
+
Fact: (jimmy_neutron, fictional_character_occupation, inventor)
|
78 |
+
* What dietary restriction is incompatible with kimchi?
|
79 |
+
Fact: (kimchi, incompatible_with_dietary_restrictions, veganism)
|
80 |
+
|
81 |
+
### Data Fields
|
82 |
+
|
83 |
+
[More Information Needed]
|
84 |
+
|
85 |
+
### Data Splits
|
86 |
+
|
87 |
+
[More Information Needed]
|
88 |
+
## Dataset Creation
|
89 |
+
|
90 |
+
### Curation Rationale
|
91 |
+
|
92 |
+
[More Information Needed]
|
93 |
+
|
94 |
+
### Source Data
|
95 |
+
|
96 |
+
[More Information Needed]
|
97 |
+
|
98 |
+
#### Initial Data Collection and Normalization
|
99 |
+
|
100 |
+
[More Information Needed]
|
101 |
+
|
102 |
+
#### Who are the source language producers?
|
103 |
+
|
104 |
+
[More Information Needed]
|
105 |
+
|
106 |
+
### Annotations
|
107 |
+
|
108 |
+
[More Information Needed]
|
109 |
+
|
110 |
+
#### Annotation process
|
111 |
+
|
112 |
+
[More Information Needed]
|
113 |
+
|
114 |
+
#### Who are the annotators?
|
115 |
+
|
116 |
+
[More Information Needed]
|
117 |
+
|
118 |
+
### Personal and Sensitive Information
|
119 |
+
|
120 |
+
[More Information Needed]
|
121 |
+
|
122 |
+
## Considerations for Using the Data
|
123 |
+
|
124 |
+
### Social Impact of Dataset
|
125 |
+
|
126 |
+
[More Information Needed]
|
127 |
+
|
128 |
+
### Discussion of Biases
|
129 |
+
|
130 |
+
[More Information Needed]
|
131 |
+
|
132 |
+
### Other Known Limitations
|
133 |
+
|
134 |
+
[More Information Needed]
|
135 |
+
|
136 |
+
## Additional Information
|
137 |
+
|
138 |
+
### Dataset Curators
|
139 |
+
|
140 |
+
[More Information Needed]
|
141 |
+
|
142 |
+
### Licensing Information
|
143 |
+
|
144 |
+
[More Information Needed]
|
145 |
+
|
146 |
+
### Citation Information
|
147 |
+
|
148 |
+
[More Information Needed]
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"annotated": {"description": "SimpleQuestions is a dataset for simple QA, which consists\nof a total of 108,442 questions written in natural language by human\nEnglish-speaking annotators each paired with a corresponding fact,\nformatted as (subject, relationship, object), that provides the answer\nbut also a complete explanation. Fast have been extracted from the\nKnowledge Base Freebase (freebase.com). We randomly shuffle these\nquestions and use 70% of them (75910) as training set, 10% as\nvalidation set (10845), and the remaining 20% as test set.\n", "citation": "@misc{bordes2015largescale,\n title={Large-scale Simple Question Answering with Memory Networks},\n author={Antoine Bordes and Nicolas Usunier and Sumit Chopra and Jason Weston},\n year={2015},\n eprint={1506.02075},\n archivePrefix={arXiv},\n primaryClass={cs.LG}\n}\n", "homepage": "https://research.fb.com/downloads/babi/", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "subject_entity": {"dtype": "string", "id": null, "_type": "Value"}, "relationship": {"dtype": "string", "id": null, "_type": "Value"}, "object_entity": {"dtype": "string", "id": null, "_type": "Value"}, "question": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "simple_questions_v2", "config_name": "annotated", "version": {"version_str": "1.0.0", "description": "", "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 12376039, "num_examples": 75910, "dataset_name": "simple_questions_v2"}, "validation": {"name": "validation", "num_bytes": 12376039, "num_examples": 75910, "dataset_name": "simple_questions_v2"}, "test": {"name": "test", "num_bytes": 12376039, "num_examples": 75910, "dataset_name": "simple_questions_v2"}}, "download_checksums": {"https://www.dropbox.com/s/tohrsllcfy7rch4/SimpleQuestions_v2.tgz?dl=1": {"num_bytes": 423435590, "checksum": "58f65630895de4f9712eeb33458ca20538972436fd48bf5913df4765e6788bf5"}}, "download_size": 423435590, "post_processing_size": null, "dataset_size": 37128117, "size_in_bytes": 460563707}, "freebase2m": {"description": "SimpleQuestions is a dataset for simple QA, which consists\nof a total of 108,442 questions written in natural language by human\nEnglish-speaking annotators each paired with a corresponding fact,\nformatted as (subject, relationship, object), that provides the answer\nbut also a complete explanation. Fast have been extracted from the\nKnowledge Base Freebase (freebase.com). We randomly shuffle these\nquestions and use 70% of them (75910) as training set, 10% as\nvalidation set (10845), and the remaining 20% as test set.\n", "citation": "@misc{bordes2015largescale,\n title={Large-scale Simple Question Answering with Memory Networks},\n author={Antoine Bordes and Nicolas Usunier and Sumit Chopra and Jason Weston},\n year={2015},\n eprint={1506.02075},\n archivePrefix={arXiv},\n primaryClass={cs.LG}\n}\n", "homepage": "https://research.fb.com/downloads/babi/", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "subject_entity": {"dtype": "string", "id": null, "_type": "Value"}, "relationship": {"dtype": "string", "id": null, "_type": "Value"}, "object_entities": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "simple_questions_v2", "config_name": "freebase2m", "version": {"version_str": "1.0.0", "description": "", "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1964037256, "num_examples": 10843106, "dataset_name": "simple_questions_v2"}}, "download_checksums": {"https://www.dropbox.com/s/tohrsllcfy7rch4/SimpleQuestions_v2.tgz?dl=1": {"num_bytes": 423435590, "checksum": "58f65630895de4f9712eeb33458ca20538972436fd48bf5913df4765e6788bf5"}}, "download_size": 423435590, "post_processing_size": null, "dataset_size": 1964037256, "size_in_bytes": 2387472846}, "freebase5m": {"description": "SimpleQuestions is a dataset for simple QA, which consists\nof a total of 108,442 questions written in natural language by human\nEnglish-speaking annotators each paired with a corresponding fact,\nformatted as (subject, relationship, object), that provides the answer\nbut also a complete explanation. Fast have been extracted from the\nKnowledge Base Freebase (freebase.com). We randomly shuffle these\nquestions and use 70% of them (75910) as training set, 10% as\nvalidation set (10845), and the remaining 20% as test set.\n", "citation": "@misc{bordes2015largescale,\n title={Large-scale Simple Question Answering with Memory Networks},\n author={Antoine Bordes and Nicolas Usunier and Sumit Chopra and Jason Weston},\n year={2015},\n eprint={1506.02075},\n archivePrefix={arXiv},\n primaryClass={cs.LG}\n}\n", "homepage": "https://research.fb.com/downloads/babi/", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "subject_entity": {"dtype": "string", "id": null, "_type": "Value"}, "relationship": {"dtype": "string", "id": null, "_type": "Value"}, "object_entities": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "simple_questions_v2", "config_name": "freebase5m", "version": {"version_str": "1.0.0", "description": "", "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2481753516, "num_examples": 12010500, "dataset_name": "simple_questions_v2"}}, "download_checksums": {"https://www.dropbox.com/s/tohrsllcfy7rch4/SimpleQuestions_v2.tgz?dl=1": {"num_bytes": 423435590, "checksum": "58f65630895de4f9712eeb33458ca20538972436fd48bf5913df4765e6788bf5"}}, "download_size": 423435590, "post_processing_size": null, "dataset_size": 2481753516, "size_in_bytes": 2905189106}}
|
dummy/annotated/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:94a639b60add41dc2a4ffea1428fc54753c7e60380ced03f914201ef9d3e3e4a
|
3 |
+
size 3823
|
dummy/freebase2m/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fb0477bef6d3627325e60a4e3f31b0e26e94e6b4dba221a421979f7dd968fb58
|
3 |
+
size 3823
|
dummy/freebase5m/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1f55b4a30ccdfd98b212818a628d37fe5be7d6b2139493dd8a1c1fafe6acbe4c
|
3 |
+
size 3823
|
simple_questions_v2.py
ADDED
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 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 |
+
import os
|
18 |
+
|
19 |
+
import datasets
|
20 |
+
|
21 |
+
|
22 |
+
_DESCRIPTION = """\
|
23 |
+
SimpleQuestions is a dataset for simple QA, which consists
|
24 |
+
of a total of 108,442 questions written in natural language by human
|
25 |
+
English-speaking annotators each paired with a corresponding fact,
|
26 |
+
formatted as (subject, relationship, object), that provides the answer
|
27 |
+
but also a complete explanation. Fast have been extracted from the
|
28 |
+
Knowledge Base Freebase (freebase.com). We randomly shuffle these
|
29 |
+
questions and use 70% of them (75910) as training set, 10% as
|
30 |
+
validation set (10845), and the remaining 20% as test set.
|
31 |
+
"""
|
32 |
+
_HOMEPAGE_URL = "https://research.fb.com/downloads/babi/"
|
33 |
+
_CITATION = """\
|
34 |
+
@misc{bordes2015largescale,
|
35 |
+
title={Large-scale Simple Question Answering with Memory Networks},
|
36 |
+
author={Antoine Bordes and Nicolas Usunier and Sumit Chopra and Jason Weston},
|
37 |
+
year={2015},
|
38 |
+
eprint={1506.02075},
|
39 |
+
archivePrefix={arXiv},
|
40 |
+
primaryClass={cs.LG}
|
41 |
+
}
|
42 |
+
"""
|
43 |
+
|
44 |
+
_URL = "https://www.dropbox.com/s/tohrsllcfy7rch4/SimpleQuestions_v2.tgz?dl=1"
|
45 |
+
|
46 |
+
|
47 |
+
class SimpleQuestionsV2Config(datasets.BuilderConfig):
|
48 |
+
def __init__(self, *args, data_type=None, **kwargs):
|
49 |
+
super().__init__(*args, version=datasets.Version("1.0.0", ""), **kwargs)
|
50 |
+
self.data_type = data_type
|
51 |
+
|
52 |
+
|
53 |
+
class SimpleQuestionsV2(datasets.GeneratorBasedBuilder):
|
54 |
+
BUILDER_CONFIGS = [
|
55 |
+
SimpleQuestionsV2Config(name="annotated", data_type="annotated", description=f"Annotated dataset"),
|
56 |
+
SimpleQuestionsV2Config(name="freebase2m", data_type="freebase2m", description=f"Freebase subset 2M"),
|
57 |
+
SimpleQuestionsV2Config(name="freebase5m", data_type="freebase5m", description=f"Freebase subset 5M"),
|
58 |
+
]
|
59 |
+
BUILDER_CONFIG_CLASS = SimpleQuestionsV2Config
|
60 |
+
DEFAULT_CONFIG_NAME = "annotated"
|
61 |
+
|
62 |
+
def _info(self):
|
63 |
+
if self.config.data_type == "annotated":
|
64 |
+
features = datasets.Features(
|
65 |
+
{
|
66 |
+
"id": datasets.Value("string"),
|
67 |
+
"subject_entity": datasets.Value("string"),
|
68 |
+
"relationship": datasets.Value("string"),
|
69 |
+
"object_entity": datasets.Value("string"),
|
70 |
+
"question": datasets.Value("string"),
|
71 |
+
},
|
72 |
+
)
|
73 |
+
else:
|
74 |
+
features = datasets.Features(
|
75 |
+
{
|
76 |
+
"id": datasets.Value("string"),
|
77 |
+
"subject_entity": datasets.Value("string"),
|
78 |
+
"relationship": datasets.Value("string"),
|
79 |
+
"object_entities": datasets.Sequence(datasets.Value("string")),
|
80 |
+
},
|
81 |
+
)
|
82 |
+
|
83 |
+
return datasets.DatasetInfo(
|
84 |
+
description=_DESCRIPTION,
|
85 |
+
features=features,
|
86 |
+
supervised_keys=None,
|
87 |
+
homepage=_HOMEPAGE_URL,
|
88 |
+
citation=_CITATION,
|
89 |
+
)
|
90 |
+
|
91 |
+
def _split_generators(self, dl_manager):
|
92 |
+
path = dl_manager.download_and_extract(_URL)
|
93 |
+
if self.config.data_type == "annotated":
|
94 |
+
return [
|
95 |
+
datasets.SplitGenerator(
|
96 |
+
name=datasets.Split.TRAIN,
|
97 |
+
gen_kwargs={"datapath": os.path.join(path, "SimpleQuestions_v2", "annotated_fb_data_train.txt")},
|
98 |
+
),
|
99 |
+
datasets.SplitGenerator(
|
100 |
+
name=datasets.Split.VALIDATION,
|
101 |
+
gen_kwargs={"datapath": os.path.join(path, "SimpleQuestions_v2", "annotated_fb_data_train.txt")},
|
102 |
+
),
|
103 |
+
datasets.SplitGenerator(
|
104 |
+
name=datasets.Split.TEST,
|
105 |
+
gen_kwargs={"datapath": os.path.join(path, "SimpleQuestions_v2", "annotated_fb_data_train.txt")},
|
106 |
+
),
|
107 |
+
]
|
108 |
+
elif self.config.data_type == "freebase2m":
|
109 |
+
return [
|
110 |
+
datasets.SplitGenerator(
|
111 |
+
name=datasets.Split.TRAIN,
|
112 |
+
gen_kwargs={
|
113 |
+
"datapath": os.path.join(
|
114 |
+
path,
|
115 |
+
"SimpleQuestions_v2",
|
116 |
+
"freebase-subsets",
|
117 |
+
"freebase-FB2M.txt",
|
118 |
+
)
|
119 |
+
},
|
120 |
+
)
|
121 |
+
]
|
122 |
+
elif self.config.data_type == "freebase5m":
|
123 |
+
return [
|
124 |
+
datasets.SplitGenerator(
|
125 |
+
name=datasets.Split.TRAIN,
|
126 |
+
gen_kwargs={
|
127 |
+
"datapath": os.path.join(
|
128 |
+
path,
|
129 |
+
"SimpleQuestions_v2",
|
130 |
+
"freebase-subsets",
|
131 |
+
"freebase-FB5M.txt",
|
132 |
+
)
|
133 |
+
},
|
134 |
+
)
|
135 |
+
]
|
136 |
+
else:
|
137 |
+
raise Exception("Unknown data type. Try one of: annotated, freebase2m and freebase5m")
|
138 |
+
|
139 |
+
def _generate_examples(self, datapath):
|
140 |
+
if self.config.data_type == "annotated":
|
141 |
+
with open(datapath, encoding="utf-8") as f:
|
142 |
+
for sentence_counter, row in enumerate(f):
|
143 |
+
row = row.split("\t")
|
144 |
+
result = (
|
145 |
+
sentence_counter,
|
146 |
+
{
|
147 |
+
"id": str(sentence_counter),
|
148 |
+
"subject_entity": row[0],
|
149 |
+
"relationship": row[1],
|
150 |
+
"object_entity": row[2],
|
151 |
+
"question": row[3],
|
152 |
+
},
|
153 |
+
)
|
154 |
+
yield result
|
155 |
+
else:
|
156 |
+
with open(datapath, encoding="utf-8") as f:
|
157 |
+
for sentence_counter, row in enumerate(f):
|
158 |
+
row = row.split("\t")
|
159 |
+
result = (
|
160 |
+
sentence_counter,
|
161 |
+
{
|
162 |
+
"id": str(sentence_counter),
|
163 |
+
"subject_entity": row[0],
|
164 |
+
"relationship": row[1],
|
165 |
+
"object_entities": row[2].split(),
|
166 |
+
},
|
167 |
+
)
|
168 |
+
yield result
|