kasnerz commited on
Commit
1acc5c8
1 Parent(s): 5e8f4e0

Upload _eventnarrative.py

Browse files
Files changed (1) hide show
  1. _eventnarrative.py +77 -0
_eventnarrative.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+
3
+ """
4
+ The script used to load the dataset from the original source.
5
+ """
6
+
7
+ import os
8
+ from collections import defaultdict
9
+
10
+ import json
11
+ import datasets
12
+
13
+ _CITATION = """\
14
+ @inproceedings{colas2021eventnarrative,
15
+ title={EventNarrative: A Large-scale Event-centric Dataset for Knowledge Graph-to-Text Generation},
16
+ author={Colas, Anthony and Sadeghian, Ali and Wang, Yue and Wang, Daisy Zhe},
17
+ booktitle={Thirty-fifth Conference on Neural Information Processing Systems Datasets and Benchmarks Track (Round 1)},
18
+ year={2021}
19
+ }
20
+ """
21
+
22
+ _DESCRIPTION = """\
23
+ EventNarrative is a knowledge graph-to-text dataset from publicly available open-world knowledge graphs, focusing on event-centric data.
24
+ EventNarrative consists of approximately 230,000 graphs and their corresponding natural language text, 6 times larger than the current largest parallel dataset.
25
+ It makes use of a rich ontology and all of the KGs entities are linked to the text."""
26
+
27
+ _URL = "https://www.kaggle.com/datasets/acolas1/eventnarration"
28
+ _LICENSE = "CC BY 4.0"
29
+
30
+ class EventNarrative(datasets.GeneratorBasedBuilder):
31
+ VERSION = datasets.Version("1.0.0")
32
+
33
+ def _info(self):
34
+ return datasets.DatasetInfo(
35
+ description=_DESCRIPTION,
36
+ features=datasets.Features({
37
+ "Event_Name": datasets.Value("string"),
38
+ "entity_ref_dict": datasets.Value("large_string"),
39
+ "keep_triples": datasets.Value("large_string"),
40
+ "narration": datasets.Value("large_string"),
41
+ "types": datasets.Value("string"),
42
+ "wikipediaLabel": datasets.Value("string"),
43
+ }),
44
+ supervised_keys=None,
45
+ homepage=_URL,
46
+ citation=_CITATION,
47
+ license=_LICENSE,
48
+ )
49
+
50
+ def _split_generators(self, dl_manager):
51
+ """Returns SplitGenerators."""
52
+ return [
53
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"split" : "train"}),
54
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"split" : "dev"}),
55
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"split" : "test"}),
56
+ ]
57
+
58
+ def _generate_examples(self, split):
59
+ """Yields examples."""
60
+ id_ = 0
61
+
62
+ with open(f"{split}_data.json") as f:
63
+ j = json.load(f)
64
+
65
+ for example in j:
66
+ e = { key : str(value) for key, value in example.items()}
67
+ id_ += 1
68
+ yield id_, e
69
+
70
+
71
+
72
+ if __name__ == '__main__':
73
+ dataset = datasets.load_dataset(__file__)
74
+
75
+ import pdb; pdb.set_trace() # breakpoint ffb6df83 //
76
+
77
+ # dataset.push_to_hub("kasnerz/eventnarrative")