ratishsp commited on
Commit
f4d65ce
1 Parent(s): 8ff4d70
Files changed (1) hide show
  1. newshead.py +50 -0
newshead.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import datasets
3
+ from datasets import DownloadManager
4
+ _URL = "data.zip"
5
+
6
+ class NewsHeadDataset(datasets.GeneratorBasedBuilder):
7
+ def _info(self):
8
+ return datasets.DatasetInfo(
9
+ description = "newshead multi document summarisation dataset",
10
+ features = datasets.Features(
11
+ {
12
+ "documents": datasets.Value("string"),
13
+ "summary": datasets.Value("string")
14
+ }
15
+ )
16
+ )
17
+
18
+ def _split_generators(self, dl_manager: DownloadManager):
19
+ return [
20
+ datasets.SplitGenerator(
21
+ name=datasets.Split.TRAIN,
22
+ gen_kwargs = {
23
+ "filepath": os.path.join(_URL, "train.jsonl"),
24
+ "split": "train"
25
+ }
26
+ ),
27
+ datasets.SplitGenerator(
28
+ name=datasets.Split.VALIDATION,
29
+ gen_kwargs = {
30
+ "filepath": os.path.join(_URL, "validation.jsonl"),
31
+ "split": "validation"
32
+ }
33
+ ),
34
+ datasets.SplitGenerator(
35
+ name=datasets.Split.TEST,
36
+ gen_kwargs = {
37
+ "filepath": os.path.join(_URL, "validation.jsonl"),
38
+ "split": "test"
39
+ }
40
+ )
41
+ ]
42
+
43
+ def _generate_examples(self, filepath, split):
44
+ with open(filepath, encoding="utf-8") as f:
45
+ for id_, row in enumerate(f):
46
+ data = json.loads(row)
47
+ yield id_, {
48
+ "documents": data["text"],
49
+ "summary": data["summary"]
50
+ }