File size: 1,944 Bytes
104c443 7260201 104c443 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
import datasets
import os
_DESCRIPTION = """\
Dataset of meeting transcriptions and summaries of AMI courpus.
"""
_CITATION = """\
@InProceedings{Zhu_2015_ICCV,
title = {AMI for summarization task},
author = {Filipp Abapolov},
month = {Fubruary},
year = {2023}
}
"""
_REPO = "https://huggingface.co/datasets/pheepa/ami-summary/resolve/main"
_URL = f"{_REPO}/data/ami-summary.tar.gz"
class AmiSummary(datasets.GeneratorBasedBuilder):
"""AmiSummary dataset."""
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name='ami-summary',
version=datasets.Version("1.0.0"),
description=_DESCRIPTION
)
]
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"text": datasets.Value("string"),
"summary": datasets.Value("string")
}
),
supervised_keys=None,
citation=_CITATION
)
def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
data_dir = dl_manager.download_and_extract(_URL)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={"filepath": os.path.join(data_dir, "train_ami.txt")}
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={"filepath": os.path.join(data_dir, "test_ami.txt")}
)
]
def _generate_examples(self, filepath):
"""Yields examples."""
with open(filepath, 'r') as f:
lines = f.read().split('\n')
pairs = []
for i in range(0, len(lines[:-1]), 2):
pairs.append((lines[i], lines[i + 1]))
for i, comment in enumerate(pairs):
yield i, {'text': pairs[0], 'summary': pairs[1]}
|