| """HiTab : A Hierarchical Table Dataset for Question Answering and Natural Language Generation""" |
|
|
| import json |
| import datasets |
|
|
| _CITATION = """\ |
| @article{cheng2021hitab, |
| title={HiTab: A Hierarchical Table Dataset for Question Answering and Natural Language Generation}, |
| 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}, |
| journal={arXiv preprint arXiv:2108.06712}, |
| year={2021} |
| } |
| """ |
| _DESCRIPTION = """\ |
| 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. |
| """ |
|
|
| _URL = "https://github.com/microsoft/HiTab" |
|
|
| class HiTab(datasets.GeneratorBasedBuilder): |
| def _info(self): |
| return datasets.DatasetInfo( |
| description=_DESCRIPTION, |
| features=datasets.Features( |
| { |
| "meaning_representation": datasets.Value("string"), |
| "human_reference": datasets.Value("string"), |
| } |
| ), |
| supervised_keys=None, |
| homepage="https://www.microsoft.com/en-us/research/publication/hitab-a-hierarchical-table-dataset-for-question-answering-and-natural-language-generation/", |
| citation=_CITATION, |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| """Returns SplitGenerators.""" |
| return [ |
| datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": "train.jsonl"}), |
| datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": "dev.jsonl"}), |
| datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": "test.jsonl"}), |
| ] |
|
|
| def _generate_examples(self, filepath): |
| with open(filepath, encoding="utf-8") as f: |
| for line in f.readlines(): |
| j = json.loads(line) |
| yield example_idx, j |
|
|