| | import csv |
| | import json |
| | import os |
| | import datasets |
| |
|
| | _CITATION = """\ |
| | @inproceedings{devaraj-etal-2021-paragraph, |
| | title = "Paragraph-level Simplification of Medical Texts", |
| | author = "Devaraj, Ashwin and |
| | Marshall, Iain and |
| | Wallace, Byron and |
| | Li, Junyi Jessy", |
| | booktitle = "Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies", |
| | month = jun, |
| | year = "2021", |
| | address = "Online", |
| | publisher = "Association for Computational Linguistics", |
| | url = "https://aclanthology.org/2021.naacl-main.395", |
| | doi = "10.18653/v1/2021.naacl-main.395", |
| | pages = "4972--4984", |
| | } |
| | """ |
| |
|
| | _DESCRIPTION = """\ |
| | This dataset measures the ability for a model to simplify paragraphs of medical text through the omission non-salient information and simplification of medical jargon. |
| | """ |
| |
|
| | _URLs = { |
| | "train": "train.json", |
| | "validation": "validation.json", |
| | "test": "test.json", |
| | } |
| |
|
| |
|
| | class Cochrane(datasets.GeneratorBasedBuilder): |
| | VERSION = datasets.Version("1.0.0") |
| | DEFAULT_CONFIG_NAME = "cochrane-simplification" |
| |
|
| | def _info(self): |
| | features = datasets.Features( |
| | { |
| | "gem_id": datasets.Value("string"), |
| | "gem_parent_id": datasets.Value("string"), |
| | "source": datasets.Value("string"), |
| | "target": datasets.Value("string"), |
| | "doi": datasets.Value("string"), |
| | "references": [datasets.Value("string")], |
| | } |
| | ) |
| | return datasets.DatasetInfo( |
| | description=_DESCRIPTION, |
| | features=features, |
| | supervised_keys=datasets.info.SupervisedKeysData( |
| | input="source", output="target" |
| | ), |
| | homepage="https://github.com/AshOlogn/Paragraph-level-Simplification-of-Medical-Texts ", |
| | citation=_CITATION, |
| | ) |
| |
|
| | def _split_generators(self, dl_manager): |
| | """Returns SplitGenerators.""" |
| | dl_dir = dl_manager.download_and_extract(_URLs) |
| | return [ |
| | datasets.SplitGenerator( |
| | name=spl, gen_kwargs={"filepath": dl_dir[spl], "split": spl} |
| | ) |
| | for spl in ["train", "validation", "test"] |
| | ] |
| |
|
| | def _generate_examples(self, filepath, split): |
| | """Yields examples.""" |
| | with open(filepath, encoding="utf-8") as f: |
| | reader = json.load(f) |
| | for id_, example in enumerate(reader): |
| | yield id_, { |
| | "gem_id": f"cochrane-simplification-{split}-{id_}", |
| | "gem_parent_id": f"cochrane-simplification-{split}-{id_}", |
| | "source": example["source"], |
| | "target": example["target"], |
| | "doi": example["doi"], |
| | "references": [example["target"]], |
| | } |
| |
|