albertvillanova HF staff commited on
Commit
764e63f
1 Parent(s): 9bd700c

Delete loading script

Browse files
Files changed (1) hide show
  1. arxiv-summarization.py +0 -130
arxiv-summarization.py DELETED
@@ -1,130 +0,0 @@
1
- import json
2
- import os
3
-
4
- import datasets
5
- from datasets.tasks import TextClassification
6
-
7
- _CITATION = None
8
-
9
-
10
- _DESCRIPTION = """
11
- Arxiv dataset for summarization.
12
- From paper: A Discourse-Aware Attention Model for Abstractive Summarization of Long Documents" by A. Cohan et al.
13
- See: https://aclanthology.org/N18-2097.pdf
14
- See: https://github.com/armancohan/long-summarization
15
- """
16
- _CITATION = """\
17
- @inproceedings{cohan-etal-2018-discourse,
18
- title = "A Discourse-Aware Attention Model for Abstractive Summarization of Long Documents",
19
- author = "Cohan, Arman and
20
- Dernoncourt, Franck and
21
- Kim, Doo Soon and
22
- Bui, Trung and
23
- Kim, Seokhwan and
24
- Chang, Walter and
25
- Goharian, Nazli",
26
- booktitle = "Proceedings of the 2018 Conference of the North {A}merican Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers)",
27
- month = jun,
28
- year = "2018",
29
- address = "New Orleans, Louisiana",
30
- publisher = "Association for Computational Linguistics",
31
- url = "https://aclanthology.org/N18-2097",
32
- doi = "10.18653/v1/N18-2097",
33
- pages = "615--621",
34
- abstract = "Neural abstractive summarization models have led to promising results in summarizing relatively short documents. We propose the first model for abstractive summarization of single, longer-form documents (e.g., research papers). Our approach consists of a new hierarchical encoder that models the discourse structure of a document, and an attentive discourse-aware decoder to generate the summary. Empirical results on two large-scale datasets of scientific papers show that our model significantly outperforms state-of-the-art models.",
35
- }
36
- """
37
- _ABSTRACT = "abstract"
38
- _ARTICLE = "article"
39
-
40
- class ArxivSummarizationConfig(datasets.BuilderConfig):
41
- """BuilderConfig for ArxivSummarization."""
42
-
43
- def __init__(self, **kwargs):
44
- """BuilderConfig for ArxivSummarization.
45
- Args:
46
- **kwargs: keyword arguments forwarded to super.
47
- """
48
- super(ArxivSummarizationConfig, self).__init__(**kwargs)
49
-
50
-
51
- class ArxivSummarizationDataset(datasets.GeneratorBasedBuilder):
52
- """ArxivSummarization Dataset."""
53
-
54
- _TRAIN_FILE = "train.zip"
55
- _VAL_FILE = "val.zip"
56
- _TEST_FILE = "test.zip"
57
-
58
- BUILDER_CONFIGS = [
59
- ArxivSummarizationConfig(
60
- name="section",
61
- version=datasets.Version("1.0.0"),
62
- description="Arxiv dataset for summarization, concatenated sections",
63
- ),
64
- ArxivSummarizationConfig(
65
- name="document",
66
- version=datasets.Version("1.0.0"),
67
- description="Arxiv dataset for summarization, document",
68
- ),
69
- ]
70
-
71
- DEFAULT_CONFIG_NAME = "section"
72
-
73
- def _info(self):
74
- # Should return a datasets.DatasetInfo object
75
- return datasets.DatasetInfo(
76
- description=_DESCRIPTION,
77
- features=datasets.Features(
78
- {
79
- _ARTICLE: datasets.Value("string"),
80
- _ABSTRACT: datasets.Value("string"),
81
- #"id": datasets.Value("string"),
82
- }
83
- ),
84
- supervised_keys=None,
85
- homepage="https://github.com/armancohan/long-summarization",
86
- citation=_CITATION,
87
- )
88
-
89
- def _split_generators(self, dl_manager):
90
-
91
- train_path = os.path.join(dl_manager.download_and_extract(self._TRAIN_FILE), "train.txt")
92
- val_path = os.path.join(dl_manager.download_and_extract(self._VAL_FILE), "val.txt")
93
- test_path = os.path.join(dl_manager.download_and_extract(self._TEST_FILE), "test.txt")
94
-
95
- return [
96
- datasets.SplitGenerator(
97
- name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}
98
- ),
99
- datasets.SplitGenerator(
100
- name=datasets.Split.VALIDATION, gen_kwargs={"filepath": val_path}
101
- ),
102
- datasets.SplitGenerator(
103
- name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}
104
- ),
105
- ]
106
-
107
- def _generate_examples(self, filepath):
108
- """Generate ArxivSummarization examples."""
109
- with open(filepath, encoding="utf-8") as f:
110
- for id_, row in enumerate(f):
111
- data = json.loads(row)
112
-
113
- """
114
- 'article_id': str,
115
- 'abstract_text': List[str],
116
- 'article_text': List[str],
117
- 'section_names': List[str],
118
- 'sections': List[List[str]]
119
- """
120
-
121
- if self.config.name == "document":
122
- article = [d.strip() for d in data["article_text"]]
123
- article = " ".join(article)
124
- else:
125
- article = [item.strip() for sublist in data["sections"] for item in sublist]
126
- article = " \n ".join(article)
127
-
128
- abstract = [ab.replace("<S>", "").replace("</S>", "").strip() for ab in data["abstract_text"]]
129
- abstract = " \n ".join(abstract)
130
- yield id_, {"article": article, "abstract": abstract}