Datasets:

Languages:
English
Multilinguality:
monolingual
Size Categories:
100K<n<1M
Language Creators:
found
Annotations Creators:
crowdsourced
Source Datasets:
extended|wikipedia
ArXiv:
License:
albertvillanova HF staff commited on
Commit
14110dd
1 Parent(s): 3a2c033

Add dataset loading script

Browse files
Files changed (1) hide show
  1. feverous.py +126 -0
feverous.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """FEVEROUS dataset."""
2
+
3
+ import json
4
+ import textwrap
5
+
6
+ import datasets
7
+
8
+
9
+ class FeverousConfig(datasets.BuilderConfig):
10
+ """BuilderConfig for FEVER."""
11
+
12
+ def __init__(self, homepage: str = None, citation: str = None, base_url: str = None, urls: dict = None, **kwargs):
13
+ """BuilderConfig for FEVEROUS.
14
+
15
+ Args:
16
+ homepage (`str`): Homepage.
17
+ citation (`str`): Citation reference.
18
+ base_url (`str`): Data base URL that precedes all data URLs.
19
+ urls (`dict`): Data URLs (each URL will pe preceded by `base_url`).
20
+ **kwargs: keyword arguments forwarded to super.
21
+ """
22
+ super().__init__(**kwargs)
23
+ self.homepage = homepage
24
+ self.citation = citation
25
+ self.base_url = base_url
26
+ self.urls = {key: f"{base_url}/{url}" for key, url in urls.items()}
27
+
28
+
29
+ class FeverOUS(datasets.GeneratorBasedBuilder):
30
+ """FEVEROUS dataset."""
31
+
32
+ BUILDER_CONFIGS = [
33
+ FeverousConfig(
34
+ version=datasets.Version("1.0.0"),
35
+ description=textwrap.dedent(
36
+ "FEVEROUS:\n"
37
+ "FEVEROUS (Fact Extraction and VERification Over Unstructured and Structured information) is a fact "
38
+ "verification dataset which consists of 87,026 verified claims. Each claim is annotated with evidence "
39
+ "in the form of sentences and/or cells from tables in Wikipedia, as well as a label indicating whether "
40
+ "this evidence supports, refutes, or does not provide enough information to reach a verdict. The "
41
+ "dataset also contains annotation metadata such as annotator actions (query keywords, clicks on page, "
42
+ "time signatures), and the type of challenge each claim poses."
43
+ ),
44
+ homepage="https://fever.ai/dataset/feverous.html",
45
+ citation=textwrap.dedent(
46
+ """\
47
+ @inproceedings{Aly21Feverous,
48
+ author = {Aly, Rami and Guo, Zhijiang and Schlichtkrull, Michael Sejr and Thorne, James and Vlachos, Andreas and Christodoulopoulos, Christos and Cocarascu, Oana and Mittal, Arpit},
49
+ title = {{FEVEROUS}: Fact Extraction and {VERification} Over Unstructured and Structured information},
50
+ eprint={2106.05707},
51
+ archivePrefix={arXiv},
52
+ primaryClass={cs.CL},
53
+ year = {2021}
54
+ }"""
55
+ ),
56
+ base_url="https://fever.ai/download/feverous",
57
+ urls={
58
+ datasets.Split.TRAIN: "feverous_train_challenges.jsonl",
59
+ datasets.Split.VALIDATION: "feverous_dev_challenges.jsonl",
60
+ datasets.Split.TEST: "feverous_test_unlabeled.jsonl",
61
+ },
62
+ ),
63
+ ]
64
+
65
+ def _info(self):
66
+ features = {
67
+ "id": datasets.Value("int32"),
68
+ "label": datasets.ClassLabel(names=["SUPPORTS", "REFUTES", "NOT ENOUGH INFO"]),
69
+ "claim": datasets.Value("string"),
70
+ "evidence": [
71
+ {
72
+ "content": [datasets.Value("string")],
73
+ "context": [[datasets.Value("string")]],
74
+ }
75
+ ],
76
+ "annotator_operations": [
77
+ {
78
+ "operation": datasets.Value("string"),
79
+ "value": datasets.Value("string"),
80
+ "time": datasets.Value("float"),
81
+ }
82
+ ],
83
+ "expected_challenge": datasets.Value("string"),
84
+ "challenge": datasets.Value("string"),
85
+ }
86
+ return datasets.DatasetInfo(
87
+ description=self.config.description,
88
+ features=datasets.Features(features),
89
+ homepage=self.config.homepage,
90
+ citation=self.config.citation,
91
+ )
92
+
93
+ def _split_generators(self, dl_manager):
94
+ dl_paths = dl_manager.download_and_extract(self.config.urls)
95
+ return [
96
+ datasets.SplitGenerator(
97
+ name=split,
98
+ gen_kwargs={
99
+ "filepath": dl_paths[split],
100
+ },
101
+ )
102
+ for split in dl_paths.keys()
103
+ ]
104
+
105
+ def _generate_examples(self, filepath):
106
+ with open(filepath, encoding="utf-8") as f:
107
+ for id_, row in enumerate(f):
108
+ data = json.loads(row)
109
+ # First item in "train" has all values equal to empty strings
110
+ if [value for value in data.values() if value]:
111
+ evidence = data.get("evidence", [])
112
+ if evidence:
113
+ for evidence_set in evidence:
114
+ # Transform "context" from dict to list (analogue to "content")
115
+ evidence_set["context"] = [
116
+ evidence_set["context"][element_id] for element_id in evidence_set["content"]
117
+ ]
118
+ yield id_, {
119
+ "id": data.get("id"),
120
+ "label": data.get("label", -1),
121
+ "claim": data.get("claim", ""),
122
+ "evidence": evidence,
123
+ "annotator_operations": data.get("annotator_operations", []),
124
+ "expected_challenge": data.get("expected_challenge", ""),
125
+ "challenge": data.get("challenge", ""),
126
+ }