Datasets:
First commit
Browse files- .gitignore +3 -0
- README.md +29 -0
- dev.jsonl +0 -0
- inspec.py +160 -0
- test.jsonl +0 -0
- train.jsonl +0 -0
.gitignore
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
**.DS_Store
|
| 2 |
+
.idea
|
| 3 |
+
src
|
README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Inspec Benchmark Dataset for Keyphrase Generation
|
| 2 |
+
|
| 3 |
+
## About
|
| 4 |
+
|
| 5 |
+
Inspec is a dataset for benchmarking keyphrase extraction and generation models.
|
| 6 |
+
The dataset is composed of 2,000 abstracts of scientific papers collected from the [Inspec database](https://www.theiet.org/resources/inspec/).
|
| 7 |
+
Keyphrases were annotated by professional indexers in an uncontrolled setting, that is, they are not limited to entries in a thesaurus.
|
| 8 |
+
Details about the inspec dataset can be found in the original paper:
|
| 9 |
+
- Anette Hulth. 2003.
|
| 10 |
+
[Improved automatic keyword extraction given more linguistic knowledge](https://aclanthology.org/W03-1028).
|
| 11 |
+
In Proceedings of the 2003 Conference on Empirical Methods in Natural Language Processing, pages 216-223.
|
| 12 |
+
|
| 13 |
+
## Content
|
| 14 |
+
|
| 15 |
+
The dataset is divided into the following three splits:
|
| 16 |
+
|
| 17 |
+
| Split | # documents |
|
| 18 |
+
| :--------- |-----------: |
|
| 19 |
+
| Train | 1,000 |
|
| 20 |
+
| Test | 500 |
|
| 21 |
+
| Validation | 500 |
|
| 22 |
+
|
| 23 |
+
The following data fields are available :
|
| 24 |
+
|
| 25 |
+
- **id**: unique identifier of the document.
|
| 26 |
+
- **title**: title of the document.
|
| 27 |
+
- **abstract**: abstract of the document.
|
| 28 |
+
- **keyphrases**: list of reference keyphrases (uncontrolled).
|
| 29 |
+
|
dev.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
inspec.py
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Inspec benchmark dataset for keyphrase extraction an generation."""
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import csv
|
| 5 |
+
import json
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
import datasets
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
# TODO: Add BibTeX citation
|
| 12 |
+
# Find for instance the citation on arxiv or on the dataset repo/website
|
| 13 |
+
_CITATION = """\
|
| 14 |
+
@inproceedings{hulth2003improved,
|
| 15 |
+
title={Improved automatic keyword extraction given more linguistic knowledge},
|
| 16 |
+
author={Hulth, Anette},
|
| 17 |
+
booktitle={Proceedings of the 2003 conference on Empirical methods in natural language processing},
|
| 18 |
+
pages={216--223},
|
| 19 |
+
year={2003}
|
| 20 |
+
}
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
# You can copy an official description
|
| 24 |
+
_DESCRIPTION = """\
|
| 25 |
+
Inspec benchmark dataset for keyphrase extraction an generation.
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
# TODO: Add a link to an official homepage for the dataset here
|
| 29 |
+
_HOMEPAGE = "https://aclanthology.org/W03-1028.pdf"
|
| 30 |
+
|
| 31 |
+
# TODO: Add the licence for the dataset here if you can find it
|
| 32 |
+
_LICENSE = "Apache 2.0 License"
|
| 33 |
+
|
| 34 |
+
# TODO: Add link to the official dataset URLs here
|
| 35 |
+
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
| 36 |
+
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
| 37 |
+
_URLS = {
|
| 38 |
+
"test": "test.jsonl",
|
| 39 |
+
"train": "train.jsonl",
|
| 40 |
+
"dev": "dev.jsonl"
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
| 44 |
+
class Inspec(datasets.GeneratorBasedBuilder):
|
| 45 |
+
"""TODO: Short description of my dataset."""
|
| 46 |
+
|
| 47 |
+
VERSION = datasets.Version("1.1.0")
|
| 48 |
+
|
| 49 |
+
# This is an example of a dataset with multiple configurations.
|
| 50 |
+
# If you don't want/need to define several sub-sets in your dataset,
|
| 51 |
+
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
| 52 |
+
|
| 53 |
+
# If you need to make complex sub-parts in the datasets with configurable options
|
| 54 |
+
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
| 55 |
+
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
| 56 |
+
|
| 57 |
+
# You will be able to load one or the other configurations in the following list with
|
| 58 |
+
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 59 |
+
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 60 |
+
BUILDER_CONFIGS = [
|
| 61 |
+
datasets.BuilderConfig(name="raw", version=VERSION, description="This part of my dataset covers the raw data."),
|
| 62 |
+
datasets.BuilderConfig(name="preprocessed", version=VERSION, description="This part of my dataset covers the preprocessed data."),
|
| 63 |
+
]
|
| 64 |
+
|
| 65 |
+
DEFAULT_CONFIG_NAME = "raw" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
| 66 |
+
|
| 67 |
+
def _info(self):
|
| 68 |
+
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
| 69 |
+
if self.config.name == "raw": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
| 70 |
+
features = datasets.Features(
|
| 71 |
+
{
|
| 72 |
+
"id": datasets.Value("int64"),
|
| 73 |
+
"title": datasets.Value("string"),
|
| 74 |
+
"abstract": datasets.Value("string"),
|
| 75 |
+
"keyphrases": datasets.features.Sequence(datasets.Value("string")),
|
| 76 |
+
}
|
| 77 |
+
)
|
| 78 |
+
else:
|
| 79 |
+
features = datasets.Features(
|
| 80 |
+
{
|
| 81 |
+
"id": datasets.Value("int64"),
|
| 82 |
+
"title": datasets.Value("string"),
|
| 83 |
+
"abstract": datasets.Value("string"),
|
| 84 |
+
"keyphrases": datasets.features.Sequence(datasets.Value("string")),
|
| 85 |
+
}
|
| 86 |
+
)
|
| 87 |
+
return datasets.DatasetInfo(
|
| 88 |
+
# This is the description that will appear on the datasets page.
|
| 89 |
+
description=_DESCRIPTION,
|
| 90 |
+
# This defines the different columns of the dataset and their types
|
| 91 |
+
features=features, # Here we define them above because they are different between the two configurations
|
| 92 |
+
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
| 93 |
+
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
| 94 |
+
# supervised_keys=("sentence", "label"),
|
| 95 |
+
# Homepage of the dataset for documentation
|
| 96 |
+
homepage=_HOMEPAGE,
|
| 97 |
+
# License for the dataset if available
|
| 98 |
+
license=_LICENSE,
|
| 99 |
+
# Citation for the dataset
|
| 100 |
+
citation=_CITATION,
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
def _split_generators(self, dl_manager):
|
| 104 |
+
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
| 105 |
+
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
| 106 |
+
|
| 107 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
| 108 |
+
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
| 109 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 110 |
+
urls = _URLS
|
| 111 |
+
data_dir = dl_manager.download_and_extract(urls)
|
| 112 |
+
return [
|
| 113 |
+
datasets.SplitGenerator(
|
| 114 |
+
name=datasets.Split.TRAIN,
|
| 115 |
+
# These kwargs will be passed to _generate_examples
|
| 116 |
+
gen_kwargs={
|
| 117 |
+
"filepath": os.path.join(data_dir["train"]),
|
| 118 |
+
"split": "train",
|
| 119 |
+
},
|
| 120 |
+
),
|
| 121 |
+
datasets.SplitGenerator(
|
| 122 |
+
name=datasets.Split.TEST,
|
| 123 |
+
# These kwargs will be passed to _generate_examples
|
| 124 |
+
gen_kwargs={
|
| 125 |
+
"filepath": os.path.join(data_dir["test"]),
|
| 126 |
+
"split": "test"
|
| 127 |
+
},
|
| 128 |
+
),
|
| 129 |
+
datasets.SplitGenerator(
|
| 130 |
+
name=datasets.Split.VALIDATION,
|
| 131 |
+
# These kwargs will be passed to _generate_examples
|
| 132 |
+
gen_kwargs={
|
| 133 |
+
"filepath": os.path.join(data_dir["dev"]),
|
| 134 |
+
"split": "dev",
|
| 135 |
+
},
|
| 136 |
+
),
|
| 137 |
+
]
|
| 138 |
+
|
| 139 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 140 |
+
def _generate_examples(self, filepath, split):
|
| 141 |
+
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
| 142 |
+
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 143 |
+
with open(filepath, encoding="utf-8") as f:
|
| 144 |
+
for key, row in enumerate(f):
|
| 145 |
+
data = json.loads(row)
|
| 146 |
+
if self.config.name == "raw":
|
| 147 |
+
# Yields examples as (key, example) tuples
|
| 148 |
+
yield key, {
|
| 149 |
+
"id": data["id"],
|
| 150 |
+
"title": data["title"],
|
| 151 |
+
"abstract": data["abstract"],
|
| 152 |
+
"keyphrases": data["keyphrases"],
|
| 153 |
+
}
|
| 154 |
+
else:
|
| 155 |
+
yield key, {
|
| 156 |
+
"id": data["id"],
|
| 157 |
+
"title": data["title"],
|
| 158 |
+
"abstract": data["abstract"],
|
| 159 |
+
"keyphrases": data["keyphrases"],
|
| 160 |
+
}
|
test.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
train.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|