Datasets:
KennethEnevoldsen
commited on
Delete loading script
Browse files- danfever.py +0 -119
danfever.py
DELETED
@@ -1,119 +0,0 @@
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|