leondz commited on
Commit
9918791
1 Parent(s): 7601cb1

danfever metadata and reader

Browse files
Files changed (2) hide show
  1. danfever.py +119 -0
  2. dataset_infos.json +1 -0
danfever.py ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 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
+
16
+ # Lint as: python3
17
+ """DanFEVER: A FEVER dataset for Danish"""
18
+
19
+ import csv
20
+ import os
21
+
22
+ import datasets
23
+
24
+
25
+ logger = datasets.logging.get_logger(__name__)
26
+
27
+
28
+ _CITATION = """\
29
+ @inproceedings{norregaard-derczynski-2021-danfever,
30
+ title = "{D}an{FEVER}: claim verification dataset for {D}anish",
31
+ author = "N{\o}rregaard, Jeppe and
32
+ Derczynski, Leon",
33
+ booktitle = "Proceedings of the 23rd Nordic Conference on Computational Linguistics (NoDaLiDa)",
34
+ month = may # " 31--2 " # jun,
35
+ year = "2021",
36
+ address = "Reykjavik, Iceland (Online)",
37
+ publisher = {Link{\"o}ping University Electronic Press, Sweden},
38
+ url = "https://aclanthology.org/2021.nodalida-main.47",
39
+ pages = "422--428",
40
+ abstract = "We present a dataset, DanFEVER, intended for multilingual misinformation research. The dataset is in Danish and has the same format as the well-known English FEVER dataset. It can be used for testing methods in multilingual settings, as well as for creating models in production for the Danish language.",
41
+ }
42
+ """
43
+
44
+ _DESCRIPTION = """\
45
+
46
+ """
47
+
48
+ _URL = "https://media.githubusercontent.com/media/StrombergNLP/danfever/main/tsv/da_fever.tsv"
49
+
50
+
51
+ class DanFeverConfig(datasets.BuilderConfig):
52
+ """BuilderConfig for DanFever"""
53
+
54
+ def __init__(self, **kwargs):
55
+ """BuilderConfig DanFever.
56
+
57
+ Args:
58
+ **kwargs: keyword arguments forwarded to super.
59
+ """
60
+ super(DanFeverConfig, self).__init__(**kwargs)
61
+
62
+
63
+ class DanFever(datasets.GeneratorBasedBuilder):
64
+ """DanFever dataset."""
65
+
66
+ BUILDER_CONFIGS = [
67
+ DanFeverConfig(name="DanFever", version=datasets.Version("1.0.0"), description="FEVER dataset for Danish"),
68
+ ]
69
+
70
+ def _info(self):
71
+ return datasets.DatasetInfo(
72
+ description=_DESCRIPTION,
73
+ features=datasets.Features(
74
+ {
75
+ "id": datasets.Value("string"),
76
+ "claim": datasets.Value("string"),
77
+ "label": datasets.features.ClassLabel(
78
+ names=[
79
+ "Refuted",
80
+ "Supported",
81
+ "NotEnoughInfo",
82
+ ]
83
+ ),
84
+ "evidence_extract": datasets.Value("string"),
85
+ "verifiable": datasets.features.ClassLabel(
86
+ names=[
87
+ "NotVerifiable",
88
+ "Verifiable",
89
+ ]
90
+ ),
91
+ "evidence": datasets.Value("string"),
92
+ "original_id": datasets.Value("string"),
93
+
94
+ }
95
+ ),
96
+ supervised_keys=None,
97
+ homepage="https://stromberg.ai/publication/danfever/",
98
+ citation=_CITATION,
99
+ )
100
+
101
+ def _split_generators(self, dl_manager):
102
+ """Returns SplitGenerators."""
103
+ downloaded_file = dl_manager.download_and_extract(_URL)
104
+
105
+ return [
106
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_file}),
107
+ ]
108
+
109
+ def _generate_examples(self, filepath):
110
+ logger.info("⏳ Generating examples from = %s", filepath)
111
+ with open(filepath, encoding="utf-8") as f:
112
+ data_reader = csv.DictReader(f, delimiter="\t", quotechar='"')
113
+ guid = 0
114
+ for instance in data_reader:
115
+ instance.pop('nr.')
116
+ instance["original_id"] = instance.pop('id')
117
+ instance["id"] = str(guid)
118
+ yield guid, instance
119
+ guid += 1
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"DanFever": {"description": "\n", "citation": "@inproceedings{norregaard-derczynski-2021-danfever,\n title = \"{D}an{FEVER}: claim verification dataset for {D}anish\",\n author = \"N{\\o}rregaard, Jeppe and\n Derczynski, Leon\",\n booktitle = \"Proceedings of the 23rd Nordic Conference on Computational Linguistics (NoDaLiDa)\",\n month = may # \" 31--2 \" # jun,\n year = \"2021\",\n address = \"Reykjavik, Iceland (Online)\",\n publisher = {Link{\"o}ping University Electronic Press, Sweden},\n url = \"https://aclanthology.org/2021.nodalida-main.47\",\n pages = \"422--428\",\n abstract = \"We present a dataset, DanFEVER, intended for multilingual misinformation research. The dataset is in Danish and has the same format as the well-known English FEVER dataset. It can be used for testing methods in multilingual settings, as well as for creating models in production for the Danish language.\",\n}\n", "homepage": "https://stromberg.ai/publication/danfever/", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "claim": {"dtype": "string", "id": null, "_type": "Value"}, "label": {"num_classes": 3, "names": ["Refuted", "Supported", "NotEnoughInfo"], "id": null, "_type": "ClassLabel"}, "evidence_extract": {"dtype": "string", "id": null, "_type": "Value"}, "verifiable": {"num_classes": 2, "names": ["NotVerifiable", "Verifiable"], "id": null, "_type": "ClassLabel"}, "evidence": {"dtype": "string", "id": null, "_type": "Value"}, "original_id": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "dan_fever", "config_name": "DanFever", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2940646, "num_examples": 6407, "dataset_name": "dan_fever"}}, "download_checksums": {"https://media.githubusercontent.com/media/StrombergNLP/danfever/main/tsv/da_fever.tsv": {"num_bytes": 2952080, "checksum": "4ca3e4ee85ff8e017c49cf05235c54a00655db54c5c0a728cb4015e71b4e3efa"}}, "download_size": 2952080, "post_processing_size": null, "dataset_size": 2940646, "size_in_bytes": 5892726}}