# coding=utf-8 # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """VLSP: Very Long Scientific Papers""" import os import glob import datasets _CITATION = """""" _DESCRIPTION = """\ Very Long version of the scientific papers summarization dataset. Only includes theses over 10,000 tokens long. """ _HOMEPAGE = "https://github.com/ghomasHudson/very_long_scientific_papers" _URL = "https://github.com/ghomasHudson/very_long_scientific_papers/archive/master.zip" class VLSP(datasets.GeneratorBasedBuilder): """VLSP: Very Long Scientific Papers""" VERSION = datasets.Version("1.1.0") BUILDER_CONFIGS = [ datasets.BuilderConfig(name="arxiv", description="Arxiv theses"), ] DEFAULT_CONFIG_NAME = "arxiv" def _info(self): return datasets.DatasetInfo( description=_DESCRIPTION, features=datasets.Features( { "abstract": datasets.features.Sequence( datasets.Value("string") ), "article": datasets.Value("string"), } ), homepage=_HOMEPAGE, citation=_CITATION, ) def _split_generators(self, dl_manager): data_dir = dl_manager.download_and_extract(_URL) return [ datasets.SplitGenerator( name=datasets.Split.TEST, gen_kwargs={ "filepath": os.path.join(data_dir,"very_long_scientific_papers-master", "deduped-test"), } ) ] def _generate_examples(self, filepath): for key, fn in enumerate(glob.glob(os.path.join(filepath, "*.main.txt"))): summary = [] summ_fn = fn.replace(".main.", ".abstract.") if os.path.exists(summ_fn): summary.append(open(summ_fn).read()) summ_fn = fn.replace(".main.", ".abstract-long.") if os.path.exists(summ_fn): summary.append(open(summ_fn).read()) yield key, { "article": open(fn).read(), "abstract": summary }