|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os |
|
import pandas as pd |
|
|
|
import datasets |
|
from huggingface_hub import snapshot_download |
|
|
|
|
|
|
|
|
|
_CITATION = """ |
|
@article{neveol2014quaero, |
|
title={The QUAERO French medical corpus: A ressource for medical entity recognition and normalization}, |
|
author={N{\'e}v{\'e}ol, Aur{\'e}lie and Grouin, Cyril and Leixa, Jeremy and Rosset, Sophie and Zweigenbaum, Pierre}, |
|
journal={Proc of BioTextMining Work}, |
|
pages={24--30}, |
|
year={2014} |
|
} |
|
""" |
|
|
|
|
|
_DESCRIPTION = """\ |
|
The QUAEROFrenchMed is a manually annotated corpus developed as a resource for named entity named recognition and normalization. |
|
""" |
|
_URLS = { |
|
"EMEA": "https://huggingface.co/datasets/meczifho/QuaeroFrenchMed/tree/main/data", |
|
"MEDLINE": "https://huggingface.co/datasets/meczifho/QuaeroFrenchMed/tree/main/data" |
|
} |
|
|
|
_HOMEPAGE = "https://quaerofrenchmed.limsi.fr/" |
|
|
|
|
|
class QuaeroFrenchMed(datasets.GeneratorBasedBuilder): |
|
""" |
|
The QUAERO French Medical Corpus has been initially developed as a resource for named entity recognition and normalization [1]. It was then improved with the purpose of creating a gold standard set of normalized entities for French biomedical text, that was used in the CLEF eHealth evaluation lab [2][3]. |
|
A selection of MEDLINE titles and EMEA documents were manually annotated. The annotation process was guided by concepts in the Unified Medical Language System (UMLS): |
|
1. Ten types of clinical entities, as defined by the following UMLS Semantic Groups (Bodenreider and McCray 2003) were annotated: Anatomy (ANAT), Chemical and Drugs (CHEM), Devices (DEVI), Disorders (DISO), Geographic Areas (GEOG), Living Beings (LIVB), Objects (OBJC), Phenomena (PHEN), Physiology (PHYS), Procedures (PROC). |
|
2. The annotations were made in a comprehensive fashion, so that nested entities were marked, and entities could be mapped to more than one UMLS concept. In particular: (a) If a mention can refer to more than one Semantic Group, all the relevant Semantic Groups should be annotated. For instance, the mention “récidive” (recurrence) in the phrase “prévention des récidives” (recurrence prevention) should be annotated with the category “DISORDER” (CUI C2825055) and the category “PHENOMENON” (CUI C0034897); (b) If a mention can refer to more than one UMLS concept within the same Semantic Group, all the relevant concepts should be annotated. For instance, the mention “maniaques” (obsessive) in the phrase “patients maniaques” (obsessive patients) should be annotated with CUIs C0564408 and C0338831 (category “DISORDER”); (c) Entities which span overlaps with that of another entity should still be annotated. For instance, in the phrase “infarctus du myocarde” (myocardial infarction), the mention “myocarde” (myocardium) should be annotated with category “ANATOMY” (CUI C0027061) and the mention “infarctus du myocarde” should be annotated with category “DISORDER” (CUI C0027051) |
|
""" |
|
|
|
VERSION = datasets.Version("1.1.0") |
|
|
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="EMEA", version=VERSION, description="information on marketed drugs from the European Medicines Agency (EMEA)"), |
|
datasets.BuilderConfig(name="MEDLINE", version=VERSION, description="The titles of MEDLINE-indexed articles"), |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = "MEDLINE" |
|
|
|
def _info(self): |
|
if self.config.name == "EMEA": |
|
features = datasets.Features( |
|
{ |
|
"docid": datasets.Value("string"), |
|
"words": datasets.Sequence(datasets.Value("string")), |
|
"ner_tags": datasets.Sequence(datasets.Value("int32")), |
|
|
|
} |
|
) |
|
else: |
|
features = datasets.Features( |
|
{ |
|
"docid": datasets.Value("string"), |
|
"words": datasets.Sequence(datasets.Value("string")), |
|
"ner_tags": datasets.Sequence(datasets.Value("int32")), |
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
supervised_keys=("words", "ner_tags"), |
|
homepage=_HOMEPAGE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
train_pq = dl_manager.download_and_extract('https://huggingface.co/datasets/meczifho/QuaeroFrenchMed/resolve/main/data/train.parquet') |
|
test_pq = dl_manager.download_and_extract('https://huggingface.co/datasets/meczifho/QuaeroFrenchMed/resolve/main/data/test.parquet') |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"filepath": train_pq, |
|
"split": "train", |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"filepath": test_pq, |
|
"split": "test" |
|
}, |
|
), |
|
] |
|
|
|
|
|
def _generate_examples(self, filepath, split): |
|
|
|
|
|
|
|
df = pd.read_parquet(filepath) |
|
if self.config.name == "EMEA": |
|
df = df[df['docid'].str.split("_").str[0].str.len() < 4] |
|
else: |
|
df = df[df['docid'].str.split("_").str[0].str.len() >= 4] |
|
for key, row in df.iterrows(): |
|
yield key, { |
|
"docid": row["docid"], |
|
"words": row["words"], |
|
"ner_tags": row["ner_tags"], |
|
} |