| import os |
|
|
| import datasets |
| import pandas as pd |
|
|
| _CITATION = None |
|
|
| _DESCRIPTION = """\ |
| MEDIQA @ NAACL-BioNLP 2021 -- Task 2: Multi-answer summarization |
| https://sites.google.com/view/mediqa2021 |
| Biomedical Summarization Data |
| The MEDIQA-AnS Dataset could be used for training. |
| """ |
| _HOMEPAGE = "https://github.com/abachaa/MEDIQA2021/tree/main/Task2" |
| _LICENSE = None |
| _DATA_URL = "https://huggingface.co/datasets/nbtpj/BioNLP2021/resolve/main/{split_name}.csv" |
| |
| _SPLIT = ['train_mul', 'train_sig', 'validate', 'test'] |
|
|
|
|
| class BioNLP2021(datasets.BuilderConfig): |
| """BuilderConfig for GLUE.""" |
|
|
| def __init__(self, data_url, **kwargs): |
| """BuilderConfig for BioNLP2021MAS |
| Args: |
| data_url: `string`, url to the dataset (word or raw level) |
| **kwargs: keyword arguments forwarded to super. |
| """ |
| super(BioNLP2021, self).__init__( |
| version=datasets.Version( |
| "1.0.0", |
| ), |
| **kwargs, |
| ) |
| self.data_url = data_url |
|
|
|
|
| class Loader(datasets.GeneratorBasedBuilder): |
| VERSION = datasets.Version("0.1.0") |
| BUILDER_CONFIGS = [BioNLP2021(name='BioNLP2021', data_url=_DATA_URL)] |
|
|
| def _info(self): |
| return datasets.DatasetInfo( |
| |
| description=_DESCRIPTION, |
| features=datasets.Features( |
| { |
| "text": datasets.Value("string"), |
| "question": datasets.Value("string"), |
| "key": datasets.Value("string"), |
| "summ_abs": datasets.Value("string"), |
| "summ_ext": datasets.Value("string"), |
| |
| |
|
|
| } |
| ), |
| |
| |
| |
| supervised_keys=None, |
| homepage=_HOMEPAGE, |
| license=_LICENSE, |
| citation=_CITATION, |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| """Returns SplitGenerators.""" |
| rs = [] |
| for split in _SPLIT: |
| file= dl_manager.download_and_extract(_DATA_URL.format(split_name=split)) |
| rs.append( |
| datasets.SplitGenerator( |
| name=split, |
| gen_kwargs={"data_file": file, "split": split }, |
| )) |
| |
|
|
| return rs |
|
|
|
|
| def _generate_examples(self, data_file, split): |
| """Yields examples.""" |
| with open(data_file, encoding="utf-8") as f: |
| f = pd.read_csv(f).to_dict('records') |
| for idx, row in enumerate(f): |
| yield idx, row |