File size: 5,602 Bytes
aaeeb0f 5dbdd64 aaeeb0f 5dbdd64 09bf1c7 5dbdd64 3eb2985 |
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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
import datasets
from datasets import Sequence, ClassLabel, Value
_TRAIN = "MACCROBAT2020-V2.json"
class MACCROBAT_biomedical_ner(datasets.GeneratorBasedBuilder):
def _info(self):
return datasets.DatasetInfo(
description="",
features=datasets.Features(
{
"full_text": Value(dtype="string"),
"ner_info": [
{
"text": Value(dtype="string"),
"label": Value(dtype="string"),
"start": Value(dtype="int64"),
"end": Value(dtype="int64"),
}
],
"tokens": Sequence(Value(dtype="string")),
"ner_labels": Sequence(
ClassLabel(
names=[
"O",
"B-ACTIVITY",
"I-ACTIVITY",
"I-ADMINISTRATION",
"B-ADMINISTRATION",
"B-AGE",
"I-AGE",
"I-AREA",
"B-AREA",
"B-BIOLOGICAL_ATTRIBUTE",
"I-BIOLOGICAL_ATTRIBUTE",
"I-BIOLOGICAL_STRUCTURE",
"B-BIOLOGICAL_STRUCTURE",
"B-CLINICAL_EVENT",
"I-CLINICAL_EVENT",
"B-COLOR",
"I-COLOR",
"I-COREFERENCE",
"B-COREFERENCE",
"B-DATE",
"I-DATE",
"I-DETAILED_DESCRIPTION",
"B-DETAILED_DESCRIPTION",
"I-DIAGNOSTIC_PROCEDURE",
"B-DIAGNOSTIC_PROCEDURE",
"I-DISEASE_DISORDER",
"B-DISEASE_DISORDER",
"B-DISTANCE",
"I-DISTANCE",
"B-DOSAGE",
"I-DOSAGE",
"I-DURATION",
"B-DURATION",
"I-FAMILY_HISTORY",
"B-FAMILY_HISTORY",
"B-FREQUENCY",
"I-FREQUENCY",
"I-HEIGHT",
"B-HEIGHT",
"B-HISTORY",
"I-HISTORY",
"I-LAB_VALUE",
"B-LAB_VALUE",
"I-MASS",
"B-MASS",
"I-MEDICATION",
"B-MEDICATION",
"I-NONBIOLOGICAL_LOCATION",
"B-NONBIOLOGICAL_LOCATION",
"I-OCCUPATION",
"B-OCCUPATION",
"B-OTHER_ENTITY",
"I-OTHER_ENTITY",
"B-OTHER_EVENT",
"I-OTHER_EVENT",
"I-OUTCOME",
"B-OUTCOME",
"I-PERSONAL_BACKGROUND",
"B-PERSONAL_BACKGROUND",
"B-QUALITATIVE_CONCEPT",
"I-QUALITATIVE_CONCEPT",
"I-QUANTITATIVE_CONCEPT",
"B-QUANTITATIVE_CONCEPT",
"B-SEVERITY",
"I-SEVERITY",
"B-SEX",
"I-SEX",
"B-SHAPE",
"I-SHAPE",
"B-SIGN_SYMPTOM",
"I-SIGN_SYMPTOM",
"B-SUBJECT",
"I-SUBJECT",
"B-TEXTURE",
"I-TEXTURE",
"B-THERAPEUTIC_PROCEDURE",
"I-THERAPEUTIC_PROCEDURE",
"I-TIME",
"B-TIME",
"B-VOLUME",
"I-VOLUME",
"I-WEIGHT",
"B-WEIGHT",
]
)
),
}
),
supervised_keys=None,
homepage="",
citation="",
)
def _split_generators(self, a):
"""Returns SplitGenerators."""
return [
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": _TRAIN}),
]
def _generate_examples(self, filepath):
with open(filepath, encoding="utf-8") as f:
datas = json.load(f)
datas = datas["data"]
guid = 0
for data in datas:
yield guid, data
guid += 1
|