kasnerz commited on
Commit
e26a8a7
·
1 Parent(s): 028c6c5

Upload hitab.py

Browse files
Files changed (1) hide show
  1. hitab.py +47 -0
hitab.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """HiTab : A Hierarchical Table Dataset for Question Answering and Natural Language Generation"""
2
+
3
+ import json
4
+ import datasets
5
+
6
+ _CITATION = """\
7
+ @article{cheng2021hitab,
8
+ title={HiTab: A Hierarchical Table Dataset for Question Answering and Natural Language Generation},
9
+ author={Cheng, Zhoujun and Dong, Haoyu and Wang, Zhiruo and Jia, Ran and Guo, Jiaqi and Gao, Yan and Han, Shi and Lou, Jian-Guang and Zhang, Dongmei},
10
+ journal={arXiv preprint arXiv:2108.06712},
11
+ year={2021}
12
+ }
13
+ """
14
+ _DESCRIPTION = """\
15
+ HiTab is a dataset for question answering and data-to-text over hierarchical tables . It contains 10,672 samples and 3,597 tables from statistical reports (StatCan, NSF) and Wikipedia (ToTTo). 98.1% of the tables in HiTab are with hierarchies.
16
+ """
17
+
18
+ _URL = "https://github.com/microsoft/HiTab"
19
+
20
+ class HiTab(datasets.GeneratorBasedBuilder):
21
+ def _info(self):
22
+ return datasets.DatasetInfo(
23
+ description=_DESCRIPTION,
24
+ features=datasets.Features(
25
+ {
26
+ "meaning_representation": datasets.Value("string"),
27
+ "human_reference": datasets.Value("string"),
28
+ }
29
+ ),
30
+ supervised_keys=None,
31
+ homepage="https://www.microsoft.com/en-us/research/publication/hitab-a-hierarchical-table-dataset-for-question-answering-and-natural-language-generation/",
32
+ citation=_CITATION,
33
+ )
34
+
35
+ def _split_generators(self, dl_manager):
36
+ """Returns SplitGenerators."""
37
+ return [
38
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": "train.jsonl"}),
39
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": "dev.jsonl"}),
40
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": "test.jsonl"}),
41
+ ]
42
+
43
+ def _generate_examples(self, filepath):
44
+ with open(filepath, encoding="utf-8") as f:
45
+ for line in f.readlines():
46
+ j = json.loads(line)
47
+ yield example_idx, j