Datasets:
Commit
·
5ee2de3
1
Parent(s):
6958faa
Delete loading script
Browse files- aquamuse.py +0 -154
aquamuse.py
DELETED
|
@@ -1,154 +0,0 @@
|
|
| 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 |
-
"""AQuaMuSe is a novel scalable approach to automatically mine dual query based multi-document summarization datasets for extractive and abstractive summaries using question answering dataset (Google Natural Questions) and large document corpora (Common Crawl)"""
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
import os
|
| 19 |
-
from os import listdir
|
| 20 |
-
from os.path import isfile, join
|
| 21 |
-
|
| 22 |
-
import tensorflow as tf
|
| 23 |
-
|
| 24 |
-
import datasets
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
_CITATION = """\
|
| 28 |
-
@misc{kulkarni2020aquamuse,
|
| 29 |
-
title={AQuaMuSe: Automatically Generating Datasets for Query-Based Multi-Document Summarization},
|
| 30 |
-
author={Sayali Kulkarni and Sheide Chammas and Wan Zhu and Fei Sha and Eugene Ie},
|
| 31 |
-
year={2020},
|
| 32 |
-
eprint={2010.12694},
|
| 33 |
-
archivePrefix={arXiv},
|
| 34 |
-
primaryClass={cs.CL}
|
| 35 |
-
}
|
| 36 |
-
"""
|
| 37 |
-
|
| 38 |
-
_DESCRIPTION = """AQuaMuSe is a novel scalable approach to automatically mine dual query based multi-document summarization datasets for extractive and abstractive summaries using question answering dataset (Google Natural Questions) and large document corpora (Common Crawl)"""
|
| 39 |
-
|
| 40 |
-
_HOMEPAGE = "https://github.com/google-research-datasets/aquamuse"
|
| 41 |
-
|
| 42 |
-
_LICENSE = ""
|
| 43 |
-
|
| 44 |
-
zipped_data_url = "https://github.com/google-research-datasets/aquamuse/raw/main/v2/aquamuse_v2.zip"
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
class Aquamuse(datasets.GeneratorBasedBuilder):
|
| 48 |
-
"""Dataset for Query-based Multi-Document Summarization"""
|
| 49 |
-
|
| 50 |
-
VERSION = datasets.Version("2.3.0")
|
| 51 |
-
|
| 52 |
-
BUILDER_CONFIGS = [
|
| 53 |
-
datasets.BuilderConfig(
|
| 54 |
-
name="abstractive", version=VERSION, description="Abstractive query-based multi-document summarization"
|
| 55 |
-
),
|
| 56 |
-
datasets.BuilderConfig(
|
| 57 |
-
name="extractive", version=VERSION, description="Extractive query-based multi-document summarization"
|
| 58 |
-
),
|
| 59 |
-
]
|
| 60 |
-
|
| 61 |
-
# DEFAULT_CONFIG_NAME = "abstractive" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
| 62 |
-
|
| 63 |
-
def _info(self):
|
| 64 |
-
features = datasets.Features(
|
| 65 |
-
{
|
| 66 |
-
"query": datasets.Value("string"),
|
| 67 |
-
"input_urls": datasets.Sequence(datasets.Value("string")),
|
| 68 |
-
"target": datasets.Value("string"),
|
| 69 |
-
}
|
| 70 |
-
)
|
| 71 |
-
|
| 72 |
-
return datasets.DatasetInfo(
|
| 73 |
-
description=_DESCRIPTION,
|
| 74 |
-
features=features,
|
| 75 |
-
supervised_keys=None,
|
| 76 |
-
homepage=_HOMEPAGE,
|
| 77 |
-
license=_LICENSE,
|
| 78 |
-
citation=_CITATION,
|
| 79 |
-
)
|
| 80 |
-
|
| 81 |
-
def _split_generators(self, dl_manager):
|
| 82 |
-
"""Returns SplitGenerators."""
|
| 83 |
-
|
| 84 |
-
if self.config.name == "abstractive":
|
| 85 |
-
data_dir = dl_manager.download_and_extract(zipped_data_url)
|
| 86 |
-
return [
|
| 87 |
-
datasets.SplitGenerator(
|
| 88 |
-
name=datasets.Split.TRAIN,
|
| 89 |
-
# These kwargs will be passed to _generate_examples
|
| 90 |
-
gen_kwargs={
|
| 91 |
-
"filepath": os.path.join(data_dir, "v2.3/abstractive/train/"),
|
| 92 |
-
"split": "train",
|
| 93 |
-
},
|
| 94 |
-
),
|
| 95 |
-
datasets.SplitGenerator(
|
| 96 |
-
name=datasets.Split.TEST,
|
| 97 |
-
# These kwargs will be passed to _generate_examples
|
| 98 |
-
gen_kwargs={
|
| 99 |
-
"filepath": os.path.join(data_dir, "v2.3/abstractive/test/"),
|
| 100 |
-
"split": "test",
|
| 101 |
-
},
|
| 102 |
-
),
|
| 103 |
-
datasets.SplitGenerator(
|
| 104 |
-
name=datasets.Split.VALIDATION,
|
| 105 |
-
# These kwargs will be passed to _generate_examples
|
| 106 |
-
gen_kwargs={
|
| 107 |
-
"filepath": os.path.join(data_dir, "v2.3/abstractive/dev/"),
|
| 108 |
-
"split": "dev",
|
| 109 |
-
},
|
| 110 |
-
),
|
| 111 |
-
]
|
| 112 |
-
|
| 113 |
-
else:
|
| 114 |
-
data_dir = dl_manager.download_and_extract(zipped_data_url)
|
| 115 |
-
return [
|
| 116 |
-
datasets.SplitGenerator(
|
| 117 |
-
name=datasets.Split.TRAIN,
|
| 118 |
-
# These kwargs will be passed to _generate_examples
|
| 119 |
-
gen_kwargs={
|
| 120 |
-
"filepath": os.path.join(data_dir, "v2.3/extractive/train/"),
|
| 121 |
-
"split": "train",
|
| 122 |
-
},
|
| 123 |
-
),
|
| 124 |
-
datasets.SplitGenerator(
|
| 125 |
-
name=datasets.Split.TEST,
|
| 126 |
-
# These kwargs will be passed to _generate_examples
|
| 127 |
-
gen_kwargs={
|
| 128 |
-
"filepath": os.path.join(data_dir, "v2.3/extractive/test/"),
|
| 129 |
-
"split": "test",
|
| 130 |
-
},
|
| 131 |
-
),
|
| 132 |
-
datasets.SplitGenerator(
|
| 133 |
-
name=datasets.Split.VALIDATION,
|
| 134 |
-
# These kwargs will be passed to _generate_examples
|
| 135 |
-
gen_kwargs={
|
| 136 |
-
"filepath": os.path.join(data_dir, "v2.3/extractive/dev/"),
|
| 137 |
-
"split": "dev",
|
| 138 |
-
},
|
| 139 |
-
),
|
| 140 |
-
]
|
| 141 |
-
|
| 142 |
-
def _generate_examples(self, filepath, split):
|
| 143 |
-
"""Yields examples."""
|
| 144 |
-
filepath = [join(filepath, f) for f in listdir(filepath) if isfile(join(filepath, f))]
|
| 145 |
-
filepath = sorted(filepath)
|
| 146 |
-
raw_dataset = tf.data.TFRecordDataset(filepath)
|
| 147 |
-
for id_, raw_record in enumerate(raw_dataset):
|
| 148 |
-
example = tf.train.Example()
|
| 149 |
-
example.ParseFromString(raw_record.numpy())
|
| 150 |
-
yield id_, {
|
| 151 |
-
"query": example.features.feature["query"].bytes_list.value[0].decode(),
|
| 152 |
-
"input_urls": example.features.feature["input_urls"].bytes_list.value[0].decode().split("<EOD>"),
|
| 153 |
-
"target": example.features.feature["target"].bytes_list.value[0].decode(),
|
| 154 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|