Upload AMIsum.py
Browse files
AMIsum.py
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
|
4 |
+
import datasets
|
5 |
+
|
6 |
+
|
7 |
+
class ERRNewsConfig(datasets.BuilderConfig):
|
8 |
+
def __init__(self, data_url, features, **kwargs):
|
9 |
+
super().__init__(version=datasets.Version("1.0.0"), **kwargs)
|
10 |
+
self.features = features
|
11 |
+
self.data_url = data_url
|
12 |
+
|
13 |
+
|
14 |
+
class ERRNews(datasets.GeneratorBasedBuilder):
|
15 |
+
features = ["transcript", "summary", "id"]
|
16 |
+
data_url = "https://cs.taltech.ee/staff/heharm/AMIsum/"
|
17 |
+
|
18 |
+
BUILDER_CONFIGS = [
|
19 |
+
ERRNewsConfig(
|
20 |
+
name="full",
|
21 |
+
features=features,
|
22 |
+
data_url=data_url
|
23 |
+
)
|
24 |
+
]
|
25 |
+
|
26 |
+
DEFAULT_CONFIG_NAME = "full"
|
27 |
+
|
28 |
+
def _info(self):
|
29 |
+
features = datasets.Features(
|
30 |
+
{
|
31 |
+
"transcript": datasets.Value("string"),
|
32 |
+
"summary": datasets.Value("string"),
|
33 |
+
"id": datasets.Value("string"),
|
34 |
+
})
|
35 |
+
|
36 |
+
description = """\
|
37 |
+
AMI Summarization Dataset (AMIsum) is a meeting summarization dataset, consisting of meeting transcripts \
|
38 |
+
and abstract summaries from the AMI Corpus: https://groups.inf.ed.ac.uk/ami/corpus/.
|
39 |
+
"""
|
40 |
+
|
41 |
+
return datasets.DatasetInfo(
|
42 |
+
features=features,
|
43 |
+
description=description,
|
44 |
+
supervised_keys=None,
|
45 |
+
version=self.config.version,
|
46 |
+
)
|
47 |
+
|
48 |
+
def _split_generators(self, dl_manager):
|
49 |
+
"""Returns SplitGenerators."""
|
50 |
+
train = "train.json"
|
51 |
+
test = "test.json"
|
52 |
+
val = "val.json"
|
53 |
+
|
54 |
+
return [
|
55 |
+
datasets.SplitGenerator(
|
56 |
+
name=datasets.Split.TRAIN,
|
57 |
+
gen_kwargs={
|
58 |
+
"file_path": dl_manager.download(self.config.data_url + train),
|
59 |
+
},
|
60 |
+
),
|
61 |
+
datasets.SplitGenerator(
|
62 |
+
name=datasets.Split.VALIDATION,
|
63 |
+
gen_kwargs={
|
64 |
+
"file_path": dl_manager.download(self.config.data_url + val),
|
65 |
+
},
|
66 |
+
),
|
67 |
+
datasets.SplitGenerator(
|
68 |
+
name=datasets.Split.TEST,
|
69 |
+
gen_kwargs={
|
70 |
+
"file_path": dl_manager.download(self.config.data_url + test),
|
71 |
+
},
|
72 |
+
),
|
73 |
+
]
|
74 |
+
|
75 |
+
def create_dict(self, data):
|
76 |
+
res = dict()
|
77 |
+
for key in self.config.features:
|
78 |
+
res[key] = data[key]
|
79 |
+
return res
|
80 |
+
|
81 |
+
def _generate_examples(self, file_path):
|
82 |
+
with open(file_path) as f:
|
83 |
+
data = json.load(f)
|
84 |
+
for idx, transcript in enumerate(data["transcript"]):
|
85 |
+
id_ = data["id"][idx]
|
86 |
+
yield id_, {
|
87 |
+
"transcript": transcript,
|
88 |
+
"summary": data["summary"][idx],
|
89 |
+
"id": id_,
|
90 |
+
}
|