Files changed (1) hide show
  1. mslr2022.py +171 -0
mslr2022.py ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ The Multidocument Summarization for Literature Review (MSLR) Shared Task aims to study how medical
17
+ evidence from different clinical studies are summarized in literature reviews. Reviews provide the
18
+ highest quality of evidence for clinical care, but are expensive to produce manually.
19
+ (Semi-)automation via NLP may facilitate faster evidence synthesis without sacrificing rigor. The
20
+ MSLR shared task uses two datasets to assess the current state of multidocument summarization for
21
+ this task, and to encourage the development of modeling contributions, scaffolding tasks, methods
22
+ for model interpretability, and improved automated evaluation methods in this domain.
23
+ """
24
+
25
+
26
+ import os
27
+
28
+ import pandas as pd
29
+
30
+ import datasets
31
+
32
+
33
+ _CITATION = """\
34
+ @inproceedings{DeYoung2021MS2MS,
35
+ title = {MSˆ2: Multi-Document Summarization of Medical Studies},
36
+ author = {Jay DeYoung and Iz Beltagy and Madeleine van Zuylen and Bailey Kuehl and Lucy Lu Wang},
37
+ booktitle = {EMNLP},
38
+ year = {2021}
39
+ }
40
+ @article{Wallace2020GeneratingN,
41
+ title = {Generating (Factual?) Narrative Summaries of RCTs: Experiments with Neural Multi-Document Summarization},
42
+ author = {Byron C. Wallace and Sayantani Saha and Frank Soboczenski and Iain James Marshall},
43
+ year = 2020,
44
+ journal = {AMIA Annual Symposium},
45
+ volume = {abs/2008.11293}
46
+ }
47
+ """
48
+
49
+ _DATASETNAME = "mslr2022"
50
+
51
+ _DESCRIPTION = """\
52
+ The Multidocument Summarization for Literature Review (MSLR) Shared Task aims to study how medical
53
+ evidence from different clinical studies are summarized in literature reviews. Reviews provide the
54
+ highest quality of evidence for clinical care, but are expensive to produce manually.
55
+ (Semi-)automation via NLP may facilitate faster evidence synthesis without sacrificing rigor.
56
+ The MSLR shared task uses two datasets to assess the current state of multidocument summarization
57
+ for this task, and to encourage the development of modeling contributions, scaffolding tasks, methods
58
+ for model interpretability, and improved automated evaluation methods in this domain.
59
+ """
60
+
61
+ _HOMEPAGE = "https://github.com/allenai/mslr-shared-task"
62
+
63
+ _LICENSE = "Apache-2.0"
64
+
65
+ _URLS = {
66
+ _DATASETNAME: "https://ai2-s2-mslr.s3.us-west-2.amazonaws.com/mslr_data.tar.gz",
67
+ }
68
+
69
+
70
+ class MSLR2022(datasets.GeneratorBasedBuilder):
71
+ """MSLR2022 Shared Task."""
72
+
73
+ VERSION = datasets.Version("1.0.0")
74
+
75
+ BUILDER_CONFIGS = [
76
+ datasets.BuilderConfig(
77
+ name="ms2",
78
+ version=VERSION,
79
+ description="This dataset consists of around 20K reviews and 470K studies collected from PubMed. For details on dataset contents and construction, please read the MS^2 paper (https://arxiv.org/abs/2104.06486).",
80
+ ),
81
+ datasets.BuilderConfig(
82
+ name="cochrane",
83
+ version=VERSION,
84
+ description="This is a dataset of 4.5K reviews collected from Cochrane systematic reviews. For details on dataset contents and construction, please read the AMIA paper (https://arxiv.org/abs/2008.11293).",
85
+ ),
86
+ ]
87
+
88
+ def _info(self):
89
+ fields = {
90
+ "review_id": datasets.Value("string"),
91
+ "pmid": datasets.Sequence(datasets.Value("string")),
92
+ "title": datasets.Sequence(datasets.Value("string")),
93
+ "abstract": datasets.Sequence(datasets.Value("string")),
94
+ "target": datasets.Value("string"),
95
+ }
96
+ # These are unique to MS^2
97
+ if self.config.name == "ms2":
98
+ fields["background"] = datasets.Value("string")
99
+
100
+ features = datasets.Features(fields)
101
+
102
+ return datasets.DatasetInfo(
103
+ description=_DESCRIPTION,
104
+ features=features,
105
+ homepage=_HOMEPAGE,
106
+ license=_LICENSE,
107
+ citation=_CITATION,
108
+ )
109
+
110
+ def _split_generators(self, dl_manager):
111
+ urls = _URLS[_DATASETNAME]
112
+ data_dir = dl_manager.download_and_extract(urls)
113
+ mslr_data_dir = os.path.join(data_dir, "mslr_data", self.config.name)
114
+ return [
115
+ datasets.SplitGenerator(
116
+ name=datasets.Split.TRAIN,
117
+ gen_kwargs={
118
+ "data_dir": mslr_data_dir,
119
+ "split": "train",
120
+ },
121
+ ),
122
+ datasets.SplitGenerator(
123
+ name=datasets.Split.TEST,
124
+ gen_kwargs={"data_dir": mslr_data_dir, "split": "test"},
125
+ ),
126
+ datasets.SplitGenerator(
127
+ name=datasets.Split.VALIDATION,
128
+ gen_kwargs={
129
+ "data_dir": mslr_data_dir,
130
+ "split": "dev",
131
+ },
132
+ ),
133
+ ]
134
+
135
+ def _generate_examples(self, data_dir, split):
136
+ inputs_filepath = os.path.join(data_dir, f"{split}-inputs.csv")
137
+ # At least one element in ReviewID is not a string, so explicitly cast it as such
138
+ inputs_df = pd.read_csv(inputs_filepath, index_col=0, dtype={"ReviewID": "string"})
139
+
140
+ # Only the train and dev splits have targets
141
+ if split != "test":
142
+ targets_filepath = os.path.join(data_dir, f"{split}-targets.csv")
143
+ targets_df = pd.read_csv(targets_filepath, index_col=0, dtype={"ReviewID": "string"})
144
+
145
+ # Only MS^2 has the *-reviews-info.csv files
146
+ if self.config.name == "ms2":
147
+ reviews_info_filepath = os.path.join(data_dir, f"{split}-reviews-info.csv")
148
+ reviews_info_df = pd.read_csv(reviews_info_filepath, index_col=0, dtype={"ReviewID": "string"})
149
+
150
+ for review_id in inputs_df.ReviewID.unique():
151
+ inputs = inputs_df[inputs_df.ReviewID == review_id]
152
+
153
+ example = {
154
+ "review_id": review_id,
155
+ "pmid": inputs.PMID.values.tolist(),
156
+ "title": inputs.Title.values.tolist(),
157
+ "abstract": inputs.Abstract.values.tolist(),
158
+ "target": "",
159
+ }
160
+
161
+ # Only the train and dev splits have targets
162
+ if split != "test":
163
+ targets = targets_df[targets_df.ReviewID == review_id]
164
+ example["target"] = targets.Target.values[0]
165
+
166
+ # Only MS^2 has the background section
167
+ if self.config.name == "ms2":
168
+ reviews_info = reviews_info_df[reviews_info_df.ReviewID == review_id]
169
+ example["background"] = reviews_info.Background.values[0]
170
+
171
+ yield review_id, example