adding test/dev
Browse files- .gitattributes +2 -0
- .gitignore +5 -0
- README.md +73 -0
- dev.jsonl +3 -0
- kptimes.py +166 -0
- test.jsonl +3 -0
.gitattributes
CHANGED
|
@@ -35,3 +35,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 35 |
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 36 |
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 35 |
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 36 |
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
dev.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
test.jsonl filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
**.DS_Store
|
| 3 |
+
.idea
|
| 4 |
+
.ipynb_checkpoints
|
| 5 |
+
src/
|
README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
annotations_creators:
|
| 3 |
+
- unknown
|
| 4 |
+
language_creators:
|
| 5 |
+
- unknown
|
| 6 |
+
languages:
|
| 7 |
+
- en
|
| 8 |
+
licenses:
|
| 9 |
+
- cc-by-4-0
|
| 10 |
+
multilinguality:
|
| 11 |
+
- monolingual
|
| 12 |
+
task_categories:
|
| 13 |
+
- text-mining
|
| 14 |
+
- text-generation
|
| 15 |
+
task_ids:
|
| 16 |
+
- keyphrase-generation
|
| 17 |
+
- keyphrase-extraction
|
| 18 |
+
size_categories:
|
| 19 |
+
- 100K<n<1M
|
| 20 |
+
pretty_name: KPTimes
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
# KPTimes Benchmark Dataset for Keyphrase Generation
|
| 24 |
+
|
| 25 |
+
## About
|
| 26 |
+
|
| 27 |
+
KPTimes is a dataset for benchmarking keyphrase extraction and generation models.
|
| 28 |
+
The dataset is composed of 290K news articles in English collected from the [New York Times](https://www.nytimes.com/) and the [Japan
|
| 29 |
+
Times](https://www.japantimes.co.jp/).
|
| 30 |
+
Keyphrases were annotated by editors in a semi-automated manner (that is, editors revise a set of keyphrases proposed by an algorithm and provide additional keyphrases).
|
| 31 |
+
Details about the dataset can be found in the original paper [(Gallina et al., 2019)][gallina-2019].
|
| 32 |
+
|
| 33 |
+
Reference (indexer-assigned) keyphrases are also categorized under the PRMU (<u>P</u>resent-<u>R</u>eordered-<u>M</u>ixed-<u>U</u>nseen) scheme as proposed in [(Boudin and Gallina, 2021)][boudin-2021].
|
| 34 |
+
|
| 35 |
+
Text pre-processing (tokenization) is carried out using `spacy` (`en_core_web_sm` model) with a special rule to avoid splitting words with hyphens (e.g. graph-based is kept as one token).
|
| 36 |
+
Stemming (Porter's stemmer implementation provided in `nltk`) is applied before reference keyphrases are matched against the source text.
|
| 37 |
+
Details about the process can be found in `prmu.py`.
|
| 38 |
+
|
| 39 |
+
## Content and statistics
|
| 40 |
+
|
| 41 |
+
The dataset contains the following test split:
|
| 42 |
+
|
| 43 |
+
| Split | # documents | #words | # keyphrases | % Present | % Reordered | % Mixed | % Unseen |
|
| 44 |
+
| :--------- | ----------: | -----: | -----------: | --------: | ----------: | ------: | -------: |
|
| 45 |
+
| Train | 259,923 | - | - | - | - | - | - |
|
| 46 |
+
| Validation | 10,000 | - | - | - | - | - | - |
|
| 47 |
+
| Test | 20,000 | - | - | - | - | - | - |
|
| 48 |
+
|
| 49 |
+
The following data fields are available :
|
| 50 |
+
|
| 51 |
+
- **id**: unique identifier of the document.
|
| 52 |
+
- **title**: title of the document.
|
| 53 |
+
- **abstract**: abstract of the document.
|
| 54 |
+
- **keyphrases**: list of reference keyphrases.
|
| 55 |
+
- **prmu**: list of <u>P</u>resent-<u>R</u>eordered-<u>M</u>ixed-<u>U</u>nseen categories for reference keyphrases.
|
| 56 |
+
- **date**: publishing date (YYYY/MM/DD)
|
| 57 |
+
- **author**: author of the article (<meta name="author"/>)
|
| 58 |
+
- **categories**: categories of the article (1 or 2 categories)
|
| 59 |
+
- **headline**: self-explanatory (<meta property="og:description"/>)
|
| 60 |
+
- **file_name**: last part of the url, this is not a primary key
|
| 61 |
+
- **url**: original url of the document
|
| 62 |
+
|
| 63 |
+
## References
|
| 64 |
+
|
| 65 |
+
- (Gallina et al., 2019) Ygor Gallina, Florian Boudin, and Beatrice Daille. 2019.
|
| 66 |
+
[KPTimes: A Large-Scale Dataset for Keyphrase Generation on News Documents][gallina-2019].
|
| 67 |
+
In Proceedings of the 12th International Conference on Natural Language Generation, pages 130–135, Tokyo, Japan. Association for Computational Linguistics.
|
| 68 |
+
- (Boudin and Gallina, 2021) Florian Boudin and Ygor Gallina. 2021.
|
| 69 |
+
[Redefining Absent Keyphrases and their Effect on Retrieval Effectiveness][boudin-2021].
|
| 70 |
+
In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 4185–4193, Online. Association for Computational Linguistics.
|
| 71 |
+
|
| 72 |
+
[gallina-2019]: https://aclanthology.org/W19-8617/
|
| 73 |
+
[boudin-2021]: https://aclanthology.org/2021.naacl-main.330/
|
dev.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:da31abf3768ec7acb3dfd5b0f6d6a9761edd232163475af12a528a5e2765975c
|
| 3 |
+
size 51044613
|
kptimes.py
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""KPTimes 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{gallina-etal-2019-kptimes,
|
| 15 |
+
title = "{KPT}imes: A Large-Scale Dataset for Keyphrase Generation on News Documents",
|
| 16 |
+
author = "Gallina, Ygor and
|
| 17 |
+
Boudin, Florian and
|
| 18 |
+
Daille, Beatrice",
|
| 19 |
+
booktitle = "Proceedings of the 12th International Conference on Natural Language Generation",
|
| 20 |
+
month = oct # "{--}" # nov,
|
| 21 |
+
year = "2019",
|
| 22 |
+
address = "Tokyo, Japan",
|
| 23 |
+
publisher = "Association for Computational Linguistics",
|
| 24 |
+
url = "https://aclanthology.org/W19-8617",
|
| 25 |
+
doi = "10.18653/v1/W19-8617",
|
| 26 |
+
pages = "130--135",
|
| 27 |
+
abstract = "Keyphrase generation is the task of predicting a set of lexical units that conveys the main content of a source text. Existing datasets for keyphrase generation are only readily available for the scholarly domain and include non-expert annotations. In this paper we present KPTimes, a large-scale dataset of news texts paired with editor-curated keyphrases. Exploring the dataset, we show how editors tag documents, and how their annotations differ from those found in existing datasets. We also train and evaluate state-of-the-art neural keyphrase generation models on KPTimes to gain insights on how well they perform on the news domain. The dataset is available online at https:// github.com/ygorg/KPTimes.",
|
| 28 |
+
}
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
# You can copy an official description
|
| 32 |
+
_DESCRIPTION = """\
|
| 33 |
+
KPTimes benchmark dataset for keyphrase extraction an generation.
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
# TODO: Add a link to an official homepage for the dataset here
|
| 37 |
+
_HOMEPAGE = "https://aclanthology.org/W03-1028.pdf"
|
| 38 |
+
|
| 39 |
+
# TODO: Add the licence for the dataset here if you can find it
|
| 40 |
+
_LICENSE = "Apache 2.0 License"
|
| 41 |
+
|
| 42 |
+
# TODO: Add link to the official dataset URLs here
|
| 43 |
+
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
| 44 |
+
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
| 45 |
+
_URLS = {
|
| 46 |
+
"test": "test.jsonl",
|
| 47 |
+
"train": "train.jsonl",
|
| 48 |
+
"dev": "dev.jsonl"
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
| 53 |
+
class KPTimes(datasets.GeneratorBasedBuilder):
|
| 54 |
+
"""TODO: Short description of my dataset."""
|
| 55 |
+
|
| 56 |
+
VERSION = datasets.Version("1.1.0")
|
| 57 |
+
|
| 58 |
+
# This is an example of a dataset with multiple configurations.
|
| 59 |
+
# If you don't want/need to define several sub-sets in your dataset,
|
| 60 |
+
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
| 61 |
+
|
| 62 |
+
# If you need to make complex sub-parts in the datasets with configurable options
|
| 63 |
+
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
| 64 |
+
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
| 65 |
+
|
| 66 |
+
# You will be able to load one or the other configurations in the following list with
|
| 67 |
+
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 68 |
+
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 69 |
+
BUILDER_CONFIGS = [
|
| 70 |
+
datasets.BuilderConfig(name="raw", version=VERSION, description="This part of my dataset covers the raw data."),
|
| 71 |
+
]
|
| 72 |
+
|
| 73 |
+
DEFAULT_CONFIG_NAME = "raw" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
| 74 |
+
|
| 75 |
+
def _info(self):
|
| 76 |
+
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
| 77 |
+
if self.config.name == "raw": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
| 78 |
+
features = datasets.Features(
|
| 79 |
+
{
|
| 80 |
+
"id": datasets.Value("string"),
|
| 81 |
+
"title": datasets.Value("string"),
|
| 82 |
+
"abstract": datasets.Value("string"),
|
| 83 |
+
"keyphrases": datasets.features.Sequence(datasets.Value("string")),
|
| 84 |
+
"prmu": datasets.features.Sequence(datasets.Value("string")),
|
| 85 |
+
"date": datasets.Value("string"),
|
| 86 |
+
"author": datasets.Value("string"),
|
| 87 |
+
"categories": datasets.features.Sequence(datasets.Value("string")),
|
| 88 |
+
"headline": datasets.Value("string"),
|
| 89 |
+
"file_name": datasets.Value("string"),
|
| 90 |
+
"url": datasets.Value("string"),
|
| 91 |
+
}
|
| 92 |
+
)
|
| 93 |
+
return datasets.DatasetInfo(
|
| 94 |
+
# This is the description that will appear on the datasets page.
|
| 95 |
+
description=_DESCRIPTION,
|
| 96 |
+
# This defines the different columns of the dataset and their types
|
| 97 |
+
features=features, # Here we define them above because they are different between the two configurations
|
| 98 |
+
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
| 99 |
+
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
| 100 |
+
# supervised_keys=("sentence", "label"),
|
| 101 |
+
# Homepage of the dataset for documentation
|
| 102 |
+
homepage=_HOMEPAGE,
|
| 103 |
+
# License for the dataset if available
|
| 104 |
+
license=_LICENSE,
|
| 105 |
+
# Citation for the dataset
|
| 106 |
+
citation=_CITATION,
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
def _split_generators(self, dl_manager):
|
| 110 |
+
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
| 111 |
+
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
| 112 |
+
|
| 113 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
| 114 |
+
# 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.
|
| 115 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 116 |
+
urls = _URLS
|
| 117 |
+
data_dir = dl_manager.download_and_extract(urls)
|
| 118 |
+
return [
|
| 119 |
+
datasets.SplitGenerator(
|
| 120 |
+
name=datasets.Split.TRAIN,
|
| 121 |
+
# These kwargs will be passed to _generate_examples
|
| 122 |
+
gen_kwargs={
|
| 123 |
+
"filepath": os.path.join(data_dir["train"]),
|
| 124 |
+
"split": "train",
|
| 125 |
+
},
|
| 126 |
+
),
|
| 127 |
+
datasets.SplitGenerator(
|
| 128 |
+
name=datasets.Split.TEST,
|
| 129 |
+
# These kwargs will be passed to _generate_examples
|
| 130 |
+
gen_kwargs={
|
| 131 |
+
"filepath": os.path.join(data_dir["test"]),
|
| 132 |
+
"split": "test"
|
| 133 |
+
},
|
| 134 |
+
),
|
| 135 |
+
datasets.SplitGenerator(
|
| 136 |
+
name=datasets.Split.VALIDATION,
|
| 137 |
+
# These kwargs will be passed to _generate_examples
|
| 138 |
+
gen_kwargs={
|
| 139 |
+
"filepath": os.path.join(data_dir["dev"]),
|
| 140 |
+
"split": "dev",
|
| 141 |
+
},
|
| 142 |
+
),
|
| 143 |
+
]
|
| 144 |
+
|
| 145 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 146 |
+
def _generate_examples(self, filepath, split):
|
| 147 |
+
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
| 148 |
+
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 149 |
+
with open(filepath, encoding="utf-8") as f:
|
| 150 |
+
for key, row in enumerate(f):
|
| 151 |
+
data = json.loads(row)
|
| 152 |
+
# Yields examples as (key, example) tuples
|
| 153 |
+
yield key, {
|
| 154 |
+
"id": data["id"],
|
| 155 |
+
"title": data["title"],
|
| 156 |
+
"abstract": data["abstract"],
|
| 157 |
+
"keyphrases": data["keyphrases"],
|
| 158 |
+
"prmu": data["prmu"],
|
| 159 |
+
"date": data["date"],
|
| 160 |
+
"author": data["author"],
|
| 161 |
+
"categories": data["categories"],
|
| 162 |
+
"headline": data["headline"],
|
| 163 |
+
"file_name": data["file_name"],
|
| 164 |
+
"url": data["url"],
|
| 165 |
+
}
|
| 166 |
+
|
test.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d4865feb314e9a19e58b25cb12c7d24ea7608375822ab928ecaf0d50175fd79a
|
| 3 |
+
size 85085194
|