Datasets:
Tasks:
Text Classification
Sub-tasks:
fact-checking
Languages:
English
Size:
100K<n<1M
ArXiv:
License:
Commit
•
ab90b5b
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +149 -0
- dataset_infos.json +1 -0
- dummy/blind_test/1.0.0/dummy_data.zip +3 -0
- dummy/tab_fact/1.0.0/dummy_data.zip +3 -0
- tab_fact.py +166 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- crowdsourced
|
4 |
+
language_creators:
|
5 |
+
- crowdsourced
|
6 |
+
languages:
|
7 |
+
- en
|
8 |
+
licenses:
|
9 |
+
- cc-by-4-0
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- 100K<n<1M
|
14 |
+
source_datasets:
|
15 |
+
- original
|
16 |
+
task_categories:
|
17 |
+
- text-classification
|
18 |
+
task_ids:
|
19 |
+
- fact-checking
|
20 |
+
---
|
21 |
+
|
22 |
+
# Dataset Card Creation Guide
|
23 |
+
|
24 |
+
## Table of Contents
|
25 |
+
- [Dataset Description](#dataset-description)
|
26 |
+
- [Dataset Summary](#dataset-summary)
|
27 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
28 |
+
- [Languages](#languages)
|
29 |
+
- [Dataset Structure](#dataset-structure)
|
30 |
+
- [Data Instances](#data-instances)
|
31 |
+
- [Data Fields](#data-instances)
|
32 |
+
- [Data Splits](#data-instances)
|
33 |
+
- [Dataset Creation](#dataset-creation)
|
34 |
+
- [Curation Rationale](#curation-rationale)
|
35 |
+
- [Source Data](#source-data)
|
36 |
+
- [Annotations](#annotations)
|
37 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
38 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
39 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
40 |
+
- [Discussion of Biases](#discussion-of-biases)
|
41 |
+
- [Other Known Limitations](#other-known-limitations)
|
42 |
+
- [Additional Information](#additional-information)
|
43 |
+
- [Dataset Curators](#dataset-curators)
|
44 |
+
- [Licensing Information](#licensing-information)
|
45 |
+
- [Citation Information](#citation-information)
|
46 |
+
|
47 |
+
## Dataset Description
|
48 |
+
|
49 |
+
- **Homepage:** [TabFact](https://tabfact.github.io/index.html)
|
50 |
+
- **Repository:** [GitHub](https://github.com/wenhuchen/Table-Fact-Checking)
|
51 |
+
- **Paper:** [TabFact: A Large-scale Dataset for Table-based Fact Verification](https://arxiv.org/abs/1909.02164)
|
52 |
+
- **Leaderboard:** [Leaderboard](https://competitions.codalab.org/competitions/21611)
|
53 |
+
- **Point of Contact:** [Wenhu Chen](wenhuchen@cs.ucsb.edu)
|
54 |
+
|
55 |
+
### Dataset Summary
|
56 |
+
|
57 |
+
The problem of verifying whether a textual hypothesis holds the truth based on the given evidence, also known as fact verification, plays an important role in the study of natural language understanding and semantic representation. However, existing studies are restricted to dealing with unstructured textual evidence (e.g., sentences and passages, a pool of passages), while verification using structured forms of evidence, such as tables, graphs, and databases, remains unexplored. TABFACT is large scale dataset with 16k Wikipedia tables as evidence for 118k human annotated statements designed for fact verification with semi-structured evidence. The statements are labeled as either ENTAILED or REFUTED. TABFACT is challenging since it involves both soft linguistic reasoning and hard symbolic reasoning.
|
58 |
+
|
59 |
+
### Supported Tasks and Leaderboards
|
60 |
+
|
61 |
+
[More Information Needed]
|
62 |
+
|
63 |
+
### Languages
|
64 |
+
|
65 |
+
[More Information Needed]
|
66 |
+
|
67 |
+
## Dataset Structure
|
68 |
+
|
69 |
+
### Data Instances
|
70 |
+
|
71 |
+
[More Information Needed]
|
72 |
+
|
73 |
+
### Data Fields
|
74 |
+
|
75 |
+
[More Information Needed]
|
76 |
+
|
77 |
+
### Data Splits
|
78 |
+
|
79 |
+
[More Information Needed]
|
80 |
+
## Dataset Creation
|
81 |
+
|
82 |
+
### Curation Rationale
|
83 |
+
|
84 |
+
[More Information Needed]
|
85 |
+
|
86 |
+
### Source Data
|
87 |
+
|
88 |
+
[More Information Needed]
|
89 |
+
|
90 |
+
#### Initial Data Collection and Normalization
|
91 |
+
|
92 |
+
[More Information Needed]
|
93 |
+
|
94 |
+
#### Who are the source language producers?
|
95 |
+
|
96 |
+
[More Information Needed]
|
97 |
+
|
98 |
+
### Annotations
|
99 |
+
|
100 |
+
[More Information Needed]
|
101 |
+
|
102 |
+
#### Annotation process
|
103 |
+
|
104 |
+
[More Information Needed]
|
105 |
+
|
106 |
+
#### Who are the annotators?
|
107 |
+
|
108 |
+
[More Information Needed]
|
109 |
+
|
110 |
+
### Personal and Sensitive Information
|
111 |
+
|
112 |
+
[More Information Needed]
|
113 |
+
|
114 |
+
## Considerations for Using the Data
|
115 |
+
|
116 |
+
### Social Impact of Dataset
|
117 |
+
|
118 |
+
[More Information Needed]
|
119 |
+
|
120 |
+
### Discussion of Biases
|
121 |
+
|
122 |
+
[More Information Needed]
|
123 |
+
|
124 |
+
### Other Known Limitations
|
125 |
+
|
126 |
+
[More Information Needed]
|
127 |
+
|
128 |
+
## Additional Information
|
129 |
+
|
130 |
+
### Dataset Curators
|
131 |
+
|
132 |
+
[More Information Needed]
|
133 |
+
|
134 |
+
### Licensing Information
|
135 |
+
|
136 |
+
[More Information Needed]
|
137 |
+
|
138 |
+
### Citation Information
|
139 |
+
|
140 |
+
```
|
141 |
+
@inproceedings{2019TabFactA,
|
142 |
+
title={TabFact : A Large-scale Dataset for Table-based Fact Verification},
|
143 |
+
author={Wenhu Chen, Hongmin Wang, Jianshu Chen, Yunkai Zhang, Hong Wang, Shiyang Li, Xiyou Zhou and William Yang Wang},
|
144 |
+
booktitle = {International Conference on Learning Representations (ICLR)},
|
145 |
+
address = {Addis Ababa, Ethiopia},
|
146 |
+
month = {April},
|
147 |
+
year = {2020}
|
148 |
+
}
|
149 |
+
```
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"tab_fact": {"description": "The problem of verifying whether a textual hypothesis holds the truth based on the given evidence, also known as fact verification, plays an important role in the study of natural language understanding and semantic representation. However, existing studies are restricted to dealing with unstructured textual evidence (e.g., sentences and passages, a pool of passages), while verification using structured forms of evidence, such as tables, graphs, and databases, remains unexplored. TABFACT is large scale dataset with 16k Wikipedia tables as evidence for 118k human annotated statements designed for fact verification with semi-structured evidence. The statements are labeled as either ENTAILED or REFUTED. TABFACT is challenging since it involves both soft linguistic reasoning and hard symbolic reasoning.\n", "citation": "@inproceedings{2019TabFactA,\n title={TabFact : A Large-scale Dataset for Table-based Fact Verification},\n author={Wenhu Chen, Hongmin Wang, Jianshu Chen, Yunkai Zhang, Hong Wang, Shiyang Li, Xiyou Zhou and William Yang Wang},\n booktitle = {International Conference on Learning Representations (ICLR)},\n address = {Addis Ababa, Ethiopia},\n month = {April},\n year = {2020}\n}\n", "homepage": "https://tabfact.github.io/", "license": "", "features": {"id": {"dtype": "int32", "id": null, "_type": "Value"}, "table_id": {"dtype": "string", "id": null, "_type": "Value"}, "table_text": {"dtype": "string", "id": null, "_type": "Value"}, "table_caption": {"dtype": "string", "id": null, "_type": "Value"}, "statement": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 2, "names": ["refuted", "entailed"], "names_file": null, "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "builder_name": "tab_fact", "config_name": "tab_fact", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 99852664, "num_examples": 92283, "dataset_name": "tab_fact"}, "validation": {"name": "validation", "num_bytes": 13846872, "num_examples": 12792, "dataset_name": "tab_fact"}, "test": {"name": "test", "num_bytes": 13493391, "num_examples": 12779, "dataset_name": "tab_fact"}}, "download_checksums": {"https://github.com/wenhuchen/Table-Fact-Checking/archive/948b5560e2f7f8c9139bd91c7f093346a2bb56a8.zip": {"num_bytes": 196508436, "checksum": "4f0bffb6e53b59760173dac82979a0e5272c2d97514659ac3f4b44c7a008df4a"}}, "download_size": 196508436, "post_processing_size": null, "dataset_size": 127192927, "size_in_bytes": 323701363}, "blind_test": {"description": "The problem of verifying whether a textual hypothesis holds the truth based on the given evidence, also known as fact verification, plays an important role in the study of natural language understanding and semantic representation. However, existing studies are restricted to dealing with unstructured textual evidence (e.g., sentences and passages, a pool of passages), while verification using structured forms of evidence, such as tables, graphs, and databases, remains unexplored. TABFACT is large scale dataset with 16k Wikipedia tables as evidence for 118k human annotated statements designed for fact verification with semi-structured evidence. The statements are labeled as either ENTAILED or REFUTED. TABFACT is challenging since it involves both soft linguistic reasoning and hard symbolic reasoning.\n", "citation": "@inproceedings{2019TabFactA,\n title={TabFact : A Large-scale Dataset for Table-based Fact Verification},\n author={Wenhu Chen, Hongmin Wang, Jianshu Chen, Yunkai Zhang, Hong Wang, Shiyang Li, Xiyou Zhou and William Yang Wang},\n booktitle = {International Conference on Learning Representations (ICLR)},\n address = {Addis Ababa, Ethiopia},\n month = {April},\n year = {2020}\n}\n", "homepage": "https://tabfact.github.io/", "license": "", "features": {"id": {"dtype": "int32", "id": null, "_type": "Value"}, "table_id": {"dtype": "string", "id": null, "_type": "Value"}, "table_text": {"dtype": "string", "id": null, "_type": "Value"}, "table_caption": {"dtype": "string", "id": null, "_type": "Value"}, "statement": {"dtype": "string", "id": null, "_type": "Value"}, "test_id": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "tab_fact", "config_name": "blind_test", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"test": {"name": "test", "num_bytes": 10954442, "num_examples": 9750, "dataset_name": "tab_fact"}}, "download_checksums": {"https://github.com/wenhuchen/Table-Fact-Checking/archive/948b5560e2f7f8c9139bd91c7f093346a2bb56a8.zip": {"num_bytes": 196508436, "checksum": "4f0bffb6e53b59760173dac82979a0e5272c2d97514659ac3f4b44c7a008df4a"}}, "download_size": 196508436, "post_processing_size": null, "dataset_size": 10954442, "size_in_bytes": 207462878}}
|
dummy/blind_test/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:63195847e23011be684cc8b0dca40ab115dd361f5761b0ef1ff51c9e217a8cb0
|
3 |
+
size 8567
|
dummy/tab_fact/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:310f78ea8e1ed97009e17f5c3accbd657c5ebe0d887d075eb350644ffe23892c
|
3 |
+
size 9796
|
tab_fact.py
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""TabFact: A Large-scale Dataset for Table-based Fact Verification"""
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import json
|
20 |
+
import os
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
|
25 |
+
_CITATION = """\
|
26 |
+
@inproceedings{2019TabFactA,
|
27 |
+
title={TabFact : A Large-scale Dataset for Table-based Fact Verification},
|
28 |
+
author={Wenhu Chen, Hongmin Wang, Jianshu Chen, Yunkai Zhang, Hong Wang, Shiyang Li, Xiyou Zhou and William Yang Wang},
|
29 |
+
booktitle = {International Conference on Learning Representations (ICLR)},
|
30 |
+
address = {Addis Ababa, Ethiopia},
|
31 |
+
month = {April},
|
32 |
+
year = {2020}
|
33 |
+
}
|
34 |
+
"""
|
35 |
+
|
36 |
+
_DESCRIPTION = """\
|
37 |
+
The problem of verifying whether a textual hypothesis holds the truth based on the given evidence, \
|
38 |
+
also known as fact verification, plays an important role in the study of natural language \
|
39 |
+
understanding and semantic representation. However, existing studies are restricted to \
|
40 |
+
dealing with unstructured textual evidence (e.g., sentences and passages, a pool of passages), \
|
41 |
+
while verification using structured forms of evidence, such as tables, graphs, and databases, remains unexplored. \
|
42 |
+
TABFACT is large scale dataset with 16k Wikipedia tables as evidence for 118k human annotated statements \
|
43 |
+
designed for fact verification with semi-structured evidence. \
|
44 |
+
The statements are labeled as either ENTAILED or REFUTED. \
|
45 |
+
TABFACT is challenging since it involves both soft linguistic reasoning and hard symbolic reasoning.
|
46 |
+
"""
|
47 |
+
|
48 |
+
_HOMEPAGE = "https://tabfact.github.io/"
|
49 |
+
|
50 |
+
_GIT_ARCHIVE_URL = (
|
51 |
+
"https://github.com/wenhuchen/Table-Fact-Checking/archive/948b5560e2f7f8c9139bd91c7f093346a2bb56a8.zip"
|
52 |
+
)
|
53 |
+
|
54 |
+
|
55 |
+
class TabFact(datasets.GeneratorBasedBuilder):
|
56 |
+
"""TabFact: A Large-scale Dataset for Table-based Fact Verification"""
|
57 |
+
|
58 |
+
VERSION = datasets.Version("1.0.0")
|
59 |
+
BUILDER_CONFIGS = [
|
60 |
+
datasets.BuilderConfig(
|
61 |
+
name="tab_fact",
|
62 |
+
version=datasets.Version("1.0.0"),
|
63 |
+
),
|
64 |
+
datasets.BuilderConfig(
|
65 |
+
name="blind_test",
|
66 |
+
version=datasets.Version("1.0.0"),
|
67 |
+
description="Blind test dataset",
|
68 |
+
),
|
69 |
+
]
|
70 |
+
|
71 |
+
def _info(self):
|
72 |
+
features = {
|
73 |
+
"id": datasets.Value("int32"),
|
74 |
+
"table_id": datasets.Value("string"),
|
75 |
+
"table_text": datasets.Value("string"),
|
76 |
+
"table_caption": datasets.Value("string"),
|
77 |
+
"statement": datasets.Value("string"),
|
78 |
+
}
|
79 |
+
if self.config.name == "tab_fact":
|
80 |
+
features["label"] = datasets.ClassLabel(names=["refuted", "entailed"])
|
81 |
+
else:
|
82 |
+
features["test_id"] = datasets.Value("string")
|
83 |
+
|
84 |
+
return datasets.DatasetInfo(
|
85 |
+
description=_DESCRIPTION,
|
86 |
+
features=datasets.Features(features),
|
87 |
+
supervised_keys=None,
|
88 |
+
homepage=_HOMEPAGE,
|
89 |
+
citation=_CITATION,
|
90 |
+
)
|
91 |
+
|
92 |
+
def _split_generators(self, dl_manager):
|
93 |
+
extracted_path = dl_manager.download_and_extract(_GIT_ARCHIVE_URL)
|
94 |
+
|
95 |
+
repo_path = os.path.join(extracted_path, "Table-Fact-Checking-948b5560e2f7f8c9139bd91c7f093346a2bb56a8")
|
96 |
+
all_csv_path = os.path.join(repo_path, "data", "all_csv")
|
97 |
+
|
98 |
+
if self.config.name == "blind_test":
|
99 |
+
test_file_path = os.path.join(repo_path, "challenge", "blind_test.json")
|
100 |
+
return [
|
101 |
+
datasets.SplitGenerator(
|
102 |
+
name=datasets.Split.TEST,
|
103 |
+
gen_kwargs={"statements_file": test_file_path, "all_csv_path": all_csv_path},
|
104 |
+
),
|
105 |
+
]
|
106 |
+
|
107 |
+
train_statements_file = os.path.join(repo_path, "tokenized_data", "train_examples.json")
|
108 |
+
val_statements_file = os.path.join(repo_path, "tokenized_data", "val_examples.json")
|
109 |
+
test_statements_file = os.path.join(repo_path, "tokenized_data", "test_examples.json")
|
110 |
+
|
111 |
+
return [
|
112 |
+
datasets.SplitGenerator(
|
113 |
+
name=datasets.Split.TRAIN,
|
114 |
+
gen_kwargs={"statements_file": train_statements_file, "all_csv_path": all_csv_path},
|
115 |
+
),
|
116 |
+
datasets.SplitGenerator(
|
117 |
+
name=datasets.Split.VALIDATION,
|
118 |
+
gen_kwargs={"statements_file": val_statements_file, "all_csv_path": all_csv_path},
|
119 |
+
),
|
120 |
+
datasets.SplitGenerator(
|
121 |
+
name=datasets.Split.TEST,
|
122 |
+
gen_kwargs={"statements_file": test_statements_file, "all_csv_path": all_csv_path},
|
123 |
+
),
|
124 |
+
]
|
125 |
+
|
126 |
+
def _generate_examples(self, statements_file, all_csv_path):
|
127 |
+
with open(statements_file, encoding="utf-8") as f:
|
128 |
+
examples = json.load(f)
|
129 |
+
|
130 |
+
if self.config.name == "blind_test":
|
131 |
+
test_examples = self._generate_blind_test_examples(examples, all_csv_path)
|
132 |
+
for idx, example in test_examples:
|
133 |
+
yield idx, example
|
134 |
+
else:
|
135 |
+
for i, (table_id, example) in enumerate(examples.items()):
|
136 |
+
table_file_path = os.path.join(all_csv_path, table_id)
|
137 |
+
with open(table_file_path, encoding="utf-8") as f:
|
138 |
+
tabel_text = f.read()
|
139 |
+
|
140 |
+
statements, labels, caption = example
|
141 |
+
|
142 |
+
for statement, label in zip(statements, labels):
|
143 |
+
yield i, {
|
144 |
+
"id": i,
|
145 |
+
"table_id": table_id,
|
146 |
+
"table_text": tabel_text,
|
147 |
+
"table_caption": caption,
|
148 |
+
"statement": statement,
|
149 |
+
"label": label,
|
150 |
+
}
|
151 |
+
|
152 |
+
def _generate_blind_test_examples(self, examples, all_csv_path):
|
153 |
+
for i, (test_id, example) in enumerate(examples.items()):
|
154 |
+
statement, table_id, caption = example
|
155 |
+
table_file_path = os.path.join(all_csv_path, table_id)
|
156 |
+
with open(table_file_path, encoding="utf-8") as f:
|
157 |
+
tabel_text = f.read()
|
158 |
+
|
159 |
+
yield i, {
|
160 |
+
"id": i,
|
161 |
+
"test_id": test_id,
|
162 |
+
"table_id": table_id,
|
163 |
+
"table_text": tabel_text,
|
164 |
+
"table_caption": caption,
|
165 |
+
"statement": statement,
|
166 |
+
}
|