Datasets:

Modalities:
Text
Formats:
csv
Languages:
English
DOI:
Libraries:
Datasets
pandas
License:
duvel / duvel.py
cnachteg's picture
to csv
b2632f0
raw
history blame
4.64 kB
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# TODO: Address all TODOs and remove all explanatory comments
"""DUVEL : the Detection of Unlimited Variant Ensemble in Literature"""
import csv
import datasets
# TODO: Add BibTeX citation
# Find for instance the citation on arxiv or on the dataset repo/website
_CITATION = """\
@InProceedings{huggingface:dataset,
title = {A great new dataset},
author={huggingface, Inc.
},
year={2020}
}
"""
_DESCRIPTION = """\
This dataset was created to identity oligogenic variant combinations, i.e. relation between several genes and their mutations, \
causing genetic diseases in scientific articles written in english. At the moment, it contains only digenic variant combinations, \
i.e. relations between two genes and at least two variants. The dataset is intended for binary relation extraction where the \
entities are masked within the text.
"""
_HOMEPAGE = "https://github.com/cnachteg/DUVEL"
_LICENSE = "cc-by-nc-sa-4.0"
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
_URL = "https://raw.githubusercontent.com/cnachteg/DUVEL/main/"
_URLS = {
"train": _URL + "data/train.csv",
"dev": _URL + "data/validation.csv",
"test": _URL + "data/test.csv"
}
class DUVEL(datasets.GeneratorBasedBuilder):
"""DUVEL : the Detection of Unlimited Variant Ensemble in Literature - Version 1.1."""
VERSION = datasets.Version("1.1.0")
def _info(self):
features = datasets.Features(
{
'sentence': datasets.Value('string'),
'pmcid': datasets.Value('int32'),
'gene1': datasets.Value('string'),
'gene2': datasets.Value('string'),
'variant1': datasets.Value('string'),
'variant2': datasets.Value('string'),
'label': datasets.ClassLabel(names=[0,1])
}
)
return datasets.DatasetInfo(
# This is the description that will appear on the datasets page.
description=_DESCRIPTION,
# This defines the different columns of the dataset and their types
features=features, # Here we define them above because they are different between the two configurations
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
# supervised_keys=("sentence", "label"),
# Homepage of the dataset for documentation
homepage=_HOMEPAGE,
# License for the dataset if available
license=_LICENSE,
# Citation for the dataset
citation=_CITATION,
task_templates=[
datasets.tasks.TextClassification(
text_column='sentence', label_column='label'
)
],
)
def _split_generators(self, dl_manager):
downloaded_files = dl_manager.download_and_extract(_URLS)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"filepath": downloaded_files['train']
},
),
datasets.SplitGenerator(
name=datasets.Split.VALIDATION,
gen_kwargs={
"filepath": downloaded_files['dev'],
},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"filepath": downloaded_files['test'],
},
),
]
def _generate_examples(self, filepath):
with open(filepath, encoding="utf-8") as f:
reader = csv.DictReader(f)
for key, row in enumerate(reader):
yield key, row