Datasets:
Tasks:
Question Answering
Modalities:
Text
Languages:
English
Size:
10K - 100K
Tags:
knowledge-base-qa
License:
awalesushil
commited on
Commit
•
2bbc310
1
Parent(s):
857a6c6
First commit
Browse files- DBLP-QuAD.py +121 -0
- README.md +120 -1
DBLP-QuAD.py
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"""DBLP-QuAD: A Question Answering Dataset over the DBLP Scholarly Knowledge Graph."""
|
18 |
+
|
19 |
+
|
20 |
+
import json
|
21 |
+
import os
|
22 |
+
|
23 |
+
import datasets
|
24 |
+
|
25 |
+
|
26 |
+
logger = datasets.logging.get_logger(__name__)
|
27 |
+
|
28 |
+
|
29 |
+
_CITATION = """
|
30 |
+
@article{DBLP-QuAD,
|
31 |
+
title={DBLP-QuAD: A Question Answering Dataset over the DBLP Scholarly Knowledge Graph},
|
32 |
+
author={Banerjee, Debayan and Awale, Sushil and Usbeck, Ricardo and Biemann, Chris},
|
33 |
+
year={2023}
|
34 |
+
"""
|
35 |
+
|
36 |
+
_DESCRIPTION = """\
|
37 |
+
DBLP-QuAD is a scholarly knowledge graph question answering dataset with \
|
38 |
+
10,000 question - SPARQL query pairs targeting the DBLP knowledge graph. \
|
39 |
+
The dataset is split into 7,000 training, 1,000 validation and 2,000 test \
|
40 |
+
questions.
|
41 |
+
"""
|
42 |
+
|
43 |
+
_URL = "https://zenodo.org/record/7554379/files/DBLP-QuAD.zip"
|
44 |
+
|
45 |
+
|
46 |
+
class DBLPQuAD(datasets.GeneratorBasedBuilder):
|
47 |
+
"""
|
48 |
+
DBLP-QuAD: A Question Answering Dataset over the DBLP Scholarly Knowledge Graph.
|
49 |
+
Version 1.0.0
|
50 |
+
"""
|
51 |
+
|
52 |
+
VERSION = datasets.Version("1.0.0")
|
53 |
+
|
54 |
+
def _info(self):
|
55 |
+
return datasets.DatasetInfo(
|
56 |
+
# This is the description that will appear on the datasets page.
|
57 |
+
description=_DESCRIPTION,
|
58 |
+
# datasets.features.FeatureConnectors
|
59 |
+
features=datasets.Features(
|
60 |
+
{
|
61 |
+
"id": datasets.Value("string"),
|
62 |
+
"query_type": datasets.Value("string"),
|
63 |
+
"question": datasets.dataset_dict.DatasetDict({
|
64 |
+
"string": datasets.Value("string")
|
65 |
+
}),
|
66 |
+
"paraphrased_question": datasets.dataset_dict.DatasetDict({
|
67 |
+
"string": datasets.Value("string")
|
68 |
+
}),
|
69 |
+
"query": datasets.dataset_dict.DatasetDict({
|
70 |
+
"sparql": datasets.Value("string")
|
71 |
+
}),
|
72 |
+
"template_id": datasets.Value("string"),
|
73 |
+
"entities": datasets.features.Sequence(datasets.Value("string")),
|
74 |
+
"relations": datasets.features.Sequence(datasets.Value("string")),
|
75 |
+
"temporal": datasets.Value("bool"),
|
76 |
+
"held_out": datasets.Value("bool")
|
77 |
+
}
|
78 |
+
),
|
79 |
+
supervised_keys=None,
|
80 |
+
citation=_CITATION,
|
81 |
+
)
|
82 |
+
|
83 |
+
def _split_generators(self, dl_manager):
|
84 |
+
"""Returns SplitGenerators."""
|
85 |
+
|
86 |
+
dl_dir = dl_manager.download_and_extract(_URL)
|
87 |
+
dl_dir = os.path.join(dl_dir, "DBLP-QuAD")
|
88 |
+
|
89 |
+
return [
|
90 |
+
datasets.SplitGenerator(
|
91 |
+
name=datasets.Split.TRAIN,
|
92 |
+
gen_kwargs={"filepath": os.path.join(dl_dir, "train", "questions.json")},
|
93 |
+
),
|
94 |
+
datasets.SplitGenerator(
|
95 |
+
name=datasets.Split.VALID,
|
96 |
+
gen_kwargs={"filepath": os.path.join(dl_dir, "valid", "questions.json")},
|
97 |
+
),
|
98 |
+
datasets.SplitGenerator(
|
99 |
+
name=datasets.Split.TEST,
|
100 |
+
gen_kwargs={"filepath": os.path.join(dl_dir, "test", "questions.json")},
|
101 |
+
),
|
102 |
+
]
|
103 |
+
|
104 |
+
def _generate_examples(self, filepath):
|
105 |
+
"""Yields examples."""
|
106 |
+
|
107 |
+
with open(filepath, encoding="utf-8") as f:
|
108 |
+
data = json.load(f)["questions"]
|
109 |
+
for id_, row in enumerate(data):
|
110 |
+
yield id_, {
|
111 |
+
"id": row["id"],
|
112 |
+
"query_type": row["query_type"],
|
113 |
+
"question": row["question"],
|
114 |
+
"paraphrased_question": row["paraphrased_question"],
|
115 |
+
"query": row["query"],
|
116 |
+
"template_id": row["template_id"],
|
117 |
+
"entities": row["entities"],
|
118 |
+
"relations": row["relations"],
|
119 |
+
"temporal": row["temporal"],
|
120 |
+
"held_out": row["held_out"]
|
121 |
+
}
|
README.md
CHANGED
@@ -1,3 +1,122 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
annotations_creators:
|
3 |
+
- expert-generated
|
4 |
+
language:
|
5 |
+
- en
|
6 |
+
language_creators:
|
7 |
+
- machine-generated
|
8 |
+
license:
|
9 |
+
- cc-by-4.0
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
pretty_name: 'DBLP-QuAD: A Question Answering Dataset over the DBLP Scholarly Knowledge Graph'
|
13 |
+
size_categories:
|
14 |
+
- 1K<n<10K
|
15 |
+
source_datasets:
|
16 |
+
- original
|
17 |
+
tags:
|
18 |
+
- knowledge-base-qa
|
19 |
+
task_categories:
|
20 |
+
- question-answering
|
21 |
+
task_ids: []
|
22 |
---
|
23 |
+
|
24 |
+
# Dataset Card for DBLP-QuAD
|
25 |
+
|
26 |
+
## Table of Contents
|
27 |
+
- [Dataset Description](#dataset-description)
|
28 |
+
- [Dataset Summary](#dataset-summary)
|
29 |
+
- [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
|
30 |
+
- [Languages](#languages)
|
31 |
+
- [Dataset Structure](#dataset-structure)
|
32 |
+
- [Data Instances](#data-instances)
|
33 |
+
- [Data Fields](#data-fields)
|
34 |
+
- [Data Splits](#data-splits)
|
35 |
+
- [Dataset Creation](#dataset-creation)
|
36 |
+
- [Curation Rationale](#curation-rationale)
|
37 |
+
- [Source Data](#source-data)
|
38 |
+
- [Annotations](#annotations)
|
39 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
40 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
41 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
42 |
+
- [Discussion of Biases](#discussion-of-biases)
|
43 |
+
- [Other Known Limitations](#other-known-limitations)
|
44 |
+
- [Additional Information](#additional-information)
|
45 |
+
- [Dataset Curators](#dataset-curators)
|
46 |
+
- [Licensing Information](#licensing-information)
|
47 |
+
- [Citation Information](#citation-information)
|
48 |
+
- [Contributions](#contributions)
|
49 |
+
|
50 |
+
## Dataset Description
|
51 |
+
|
52 |
+
- **Homepage:** [DBLP-QuAD Homepage]()
|
53 |
+
- **Repository:** [DBLP-QuAD Repository](https://github.com/awalesushil/DBLP-QuAD)
|
54 |
+
- **Paper:** DBLP-QuAD: A Question Answering Dataset over the DBLP Scholarly Knowledge Graph
|
55 |
+
- **Point of Contact:** [Sushil Awale](mailto:[email protected])
|
56 |
+
|
57 |
+
### Dataset Summary
|
58 |
+
|
59 |
+
DBLP-QuAD is a scholarly knowledge graph question answering dataset with 10,000 question - SPARQL query pairs targeting the DBLP knowledge graph. The dataset is split into 7,000 training, 1,000 validation and 2,000 test questions.
|
60 |
+
|
61 |
+
## Dataset Structure
|
62 |
+
|
63 |
+
### Data Instances
|
64 |
+
|
65 |
+
An example of a question is given below:
|
66 |
+
|
67 |
+
```
|
68 |
+
{
|
69 |
+
"id": "Q0577",
|
70 |
+
"query_type": "MULTI_FACT",
|
71 |
+
"question": {
|
72 |
+
"string": "What are the primary affiliations of the authors of the paper 'Graphical Partitions and Graphical Relations'?"
|
73 |
+
},
|
74 |
+
"paraphrased_question": {
|
75 |
+
"string": "List the primary affiliations of the authors of 'Graphical Partitions and Graphical Relations'."
|
76 |
+
},
|
77 |
+
"query": {
|
78 |
+
"sparql": "SELECT DISTINCT ?answer WHERE { <https://dblp.org/rec/journals/fuin/ShaheenS19> <https://dblp.org/rdf/schema#authoredBy> ?x . ?x <https://dblp.org/rdf/schema#primaryAffiliation> ?answer }"
|
79 |
+
},
|
80 |
+
"template_id": "TP11",
|
81 |
+
"entities": [
|
82 |
+
"<https://dblp.org/rec/journals/fuin/ShaheenS19>"
|
83 |
+
],
|
84 |
+
"relations": [
|
85 |
+
"<https://dblp.org/rdf/schema#authoredBy>",
|
86 |
+
"<https://dblp.org/rdf/schema#primaryAffiliation>"
|
87 |
+
],
|
88 |
+
"temporal": false,
|
89 |
+
"held_out": true
|
90 |
+
}
|
91 |
+
|
92 |
+
```
|
93 |
+
### Data Fields
|
94 |
+
|
95 |
+
- `id`: the id of the question
|
96 |
+
- `question`: a string containing the question
|
97 |
+
- `paraphrased_question`: a paraphrased version of the question
|
98 |
+
- `query`: a SPARQL query that answers the question
|
99 |
+
- `query_type`: the type of the query
|
100 |
+
- `query_template`: the template of the query
|
101 |
+
- `entities`: a list of entities in the question
|
102 |
+
- `relations`: a list of relations in the question
|
103 |
+
- `temporal`: a boolean indicating whether the question contains a temporal expression
|
104 |
+
- `held_out`: a boolean indicating whether the question is held out from the training set
|
105 |
+
|
106 |
+
### Data Splits
|
107 |
+
|
108 |
+
The dataset is split into 7,000 training, 1,000 validation and 2,000 test questions.
|
109 |
+
|
110 |
+
## Additional Information
|
111 |
+
|
112 |
+
### Licensing Information
|
113 |
+
|
114 |
+
DBLP-QuAD is licensed under the [Creative Commons Attribution 4.0 International License (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/).
|
115 |
+
|
116 |
+
### Citation Information
|
117 |
+
|
118 |
+
In review.
|
119 |
+
|
120 |
+
### Contributions
|
121 |
+
|
122 |
+
Thanks to [@awalesushil](https://github.com/awalesushil) for adding this dataset.
|