add _preprended
Browse files- README.md +4 -1
- mediasum.py +32 -8
README.md
CHANGED
@@ -22,11 +22,14 @@ This dataset is compatible with the [`run_summarization.py`](https://github.com/
|
|
22 |
|
23 |
# Configs
|
24 |
4 possibles configs:
|
25 |
-
- `roberta` will concatenate documents with "\</s\>"
|
26 |
- `newline` will concatenate documents with "\n"
|
27 |
- `bert` will concatenate documents with "[SEP]"
|
28 |
- `list` will return the list of documents instead of a single string
|
29 |
|
|
|
|
|
|
|
30 |
### Data Fields
|
31 |
|
32 |
- `id`: paper id
|
|
|
22 |
|
23 |
# Configs
|
24 |
4 possibles configs:
|
25 |
+
- `roberta` will concatenate documents with "\</s\>"
|
26 |
- `newline` will concatenate documents with "\n"
|
27 |
- `bert` will concatenate documents with "[SEP]"
|
28 |
- `list` will return the list of documents instead of a single string
|
29 |
|
30 |
+
Add `_prepended` to config name to prepend the speaker name before each dialogue: `speaker: text` \
|
31 |
+
Default is `roberta_prepended` (compatible with BART).
|
32 |
+
|
33 |
### Data Fields
|
34 |
|
35 |
- `id`: paper id
|
mediasum.py
CHANGED
@@ -62,9 +62,29 @@ class MediaSumSummarizationDataset(datasets.GeneratorBasedBuilder):
|
|
62 |
version=datasets.Version("1.0.0"),
|
63 |
description="MediaSum dataset for summarization, document",
|
64 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
]
|
66 |
|
67 |
-
DEFAULT_CONFIG_NAME = "
|
68 |
|
69 |
def _info(self):
|
70 |
# Should return a datasets.DatasetInfo object
|
@@ -102,12 +122,12 @@ class MediaSumSummarizationDataset(datasets.GeneratorBasedBuilder):
|
|
102 |
|
103 |
def _generate_examples(self, filepath):
|
104 |
"""Generate MediaSumSummarization examples."""
|
105 |
-
if self.config.name
|
106 |
join_ = "\n"
|
107 |
-
elif self.config.name
|
108 |
join_ = "</s>"
|
109 |
-
elif self.config.name
|
110 |
-
join_ = "[SEP]"
|
111 |
|
112 |
with open(filepath, encoding="utf-8") as f:
|
113 |
for id_, row in enumerate(f):
|
@@ -118,9 +138,13 @@ class MediaSumSummarizationDataset(datasets.GeneratorBasedBuilder):
|
|
118 |
'document': List[str],
|
119 |
"""
|
120 |
|
121 |
-
|
|
|
|
|
|
|
|
|
122 |
|
123 |
if self.config.name != "list":
|
124 |
-
|
125 |
summary = data["summary"]
|
126 |
-
yield id_, {"document":
|
|
|
62 |
version=datasets.Version("1.0.0"),
|
63 |
description="MediaSum dataset for summarization, document",
|
64 |
),
|
65 |
+
MediaSumSummarizationConfig(
|
66 |
+
name="newline_prepended",
|
67 |
+
version=datasets.Version("1.0.0"),
|
68 |
+
description="MediaSum dataset for summarization, concat sections",
|
69 |
+
),
|
70 |
+
MediaSumSummarizationConfig(
|
71 |
+
name="roberta_prepended",
|
72 |
+
version=datasets.Version("1.0.0"),
|
73 |
+
description="MediaSum dataset for summarization, document",
|
74 |
+
),
|
75 |
+
MediaSumSummarizationConfig(
|
76 |
+
name="bert_prepended",
|
77 |
+
version=datasets.Version("1.0.0"),
|
78 |
+
description="MediaSum dataset for summarization, document",
|
79 |
+
),
|
80 |
+
MediaSumSummarizationConfig(
|
81 |
+
name="list_prepended",
|
82 |
+
version=datasets.Version("1.0.0"),
|
83 |
+
description="MediaSum dataset for summarization, document",
|
84 |
+
),
|
85 |
]
|
86 |
|
87 |
+
DEFAULT_CONFIG_NAME = "roberta_prepended"
|
88 |
|
89 |
def _info(self):
|
90 |
# Should return a datasets.DatasetInfo object
|
|
|
122 |
|
123 |
def _generate_examples(self, filepath):
|
124 |
"""Generate MediaSumSummarization examples."""
|
125 |
+
if "newline" in self.config.name:
|
126 |
join_ = "\n"
|
127 |
+
elif "roberta" in self.config.name:
|
128 |
join_ = "</s>"
|
129 |
+
elif "bert" in self.config.name:
|
130 |
+
join_ = " [SEP] "
|
131 |
|
132 |
with open(filepath, encoding="utf-8") as f:
|
133 |
for id_, row in enumerate(f):
|
|
|
138 |
'document': List[str],
|
139 |
"""
|
140 |
|
141 |
+
documents = data["utt"]
|
142 |
+
|
143 |
+
if "_prepended" in self.config.name:
|
144 |
+
names = data["speaker"]
|
145 |
+
documents = [name + ": " + document for name, document in zip(names, documents)]
|
146 |
|
147 |
if self.config.name != "list":
|
148 |
+
documents = join_.join(documents)
|
149 |
summary = data["summary"]
|
150 |
+
yield id_, {"document": documents, "summary": summary}
|