File size: 3,094 Bytes
cef968a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
import os
import pathlib
from typing import overload
import datasets
import json
from datasets.info import DatasetInfo
_VERSION = "0.0.1"
_URL= "data/"
_URLS = {
"train": _URL + "train.jsonl",
"validation": _URL + "validation.jsonl",
"test": _URL + "test.jsonl"
}
_DESCRIPTION = """\
CsFEVER is a Czech localisation of the English FEVER datgaset.
"""
_CITATION = """\
@article{DBLP:journals/corr/abs-2201-11115,
author = {Jan Drchal and
Herbert Ullrich and
Martin R{\'{y}}par and
Hana Vincourov{\'{a}} and
V{\'{a}}clav Moravec},
title = {CsFEVER and CTKFacts: Czech Datasets for Fact Verification},
journal = {CoRR},
volume = {abs/2201.11115},
year = {2022},
url = {https://arxiv.org/abs/2201.11115},
eprinttype = {arXiv},
eprint = {2201.11115},
timestamp = {Tue, 01 Feb 2022 14:59:01 +0100},
biburl = {https://dblp.org/rec/journals/corr/abs-2201-11115.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
"""
datasets.utils.version.Version
class CsFever(datasets.GeneratorBasedBuilder):
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"id": datasets.Value("int32"),
"label": datasets.ClassLabel(names=["REFUTES", "NOT ENOUGH INFO", "SUPPORTS"]),
# datasets.features.Sequence({"text": datasets.Value("string"),"answer_start": datasets.Value("int32"),})
"evidence": datasets.Value("string"),
"claim": datasets.Value("string"),
}
),
# No default supervised_keys (as we have to pass both question
# and context as input).
supervised_keys=None,
version=_VERSION,
homepage="https://fcheck.fel.cvut.cz/dataset/",
citation=_CITATION,
)
def _split_generators(self, dl_manager: datasets.DownloadManager):
downloaded_files = dl_manager.download_and_extract(_URLS)
return [
datasets.SplitGenerator(datasets.Split.TRAIN, {
"filepath": downloaded_files["train"]
}),
datasets.SplitGenerator(datasets.Split.VALIDATION, {
"filepath": downloaded_files["validation"]
}),
datasets.SplitGenerator(datasets.Split.TEST, {
"filepath": downloaded_files["test"]
}),
]
def _generate_examples(self, filepath):
"""This function returns the examples in the raw (text) form."""
key = 0
with open(filepath, encoding="utf-8") as f:
for line in f:
datapoint = json.loads(line)
yield key, {
"id": datapoint["id"],
"evidence": " ".join(datapoint["evidence"]),
"claim": datapoint["claim"],
"label": datapoint["label"]
}
key += 1
|