Aashraya Sachdeva
commited on
Commit
·
30fb2a7
1
Parent(s):
8788221
add micro to macro mapping
Browse files- multiconer2.py +83 -0
multiconer2.py
CHANGED
|
@@ -75,6 +75,76 @@ class Multiconer2(datasets.GeneratorBasedBuilder):
|
|
| 75 |
|
| 76 |
DEFAULT_CONFIG_NAME = "en"
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
def _info(self):
|
| 79 |
return datasets.DatasetInfo(
|
| 80 |
description=_DESCRIPTION,
|
|
@@ -120,6 +190,18 @@ class Multiconer2(datasets.GeneratorBasedBuilder):
|
|
| 120 |
'B-WrittenWork', 'I-WrittenWork']
|
| 121 |
)
|
| 122 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
}
|
| 124 |
),
|
| 125 |
supervised_keys=None,
|
|
@@ -168,4 +250,5 @@ class Multiconer2(datasets.GeneratorBasedBuilder):
|
|
| 168 |
"id": str(guid),
|
| 169 |
"tokens": tokens,
|
| 170 |
"ner_tags": ner_tags,
|
|
|
|
| 171 |
}
|
|
|
|
| 75 |
|
| 76 |
DEFAULT_CONFIG_NAME = "en"
|
| 77 |
|
| 78 |
+
micro_to_macro_ner_mapping = {
|
| 79 |
+
'O': "O",
|
| 80 |
+
"B-AerospaceManufacturer": "B-Group",
|
| 81 |
+
'I-AerospaceManufacturer': 'I-Group',
|
| 82 |
+
'B-AnatomicalStructure': "B-Medical",
|
| 83 |
+
'I-AnatomicalStructure': "I-Medical",
|
| 84 |
+
'B-ArtWork': "B-CreativeWork",
|
| 85 |
+
'I-ArtWork': "I-CreativeWork",
|
| 86 |
+
'B-Artist': "B-Person",
|
| 87 |
+
'I-Artist': "I-Person",
|
| 88 |
+
'B-Athlete': "B-Person",
|
| 89 |
+
'I-Athlete': "I-Person",
|
| 90 |
+
'B-CarManufacturer': "B-Group",
|
| 91 |
+
'I-CarManufacturer': "I-Group",
|
| 92 |
+
'B-Cleric': "B-Person",
|
| 93 |
+
'I-Cleric': "I-Person",
|
| 94 |
+
'B-Clothing': "B-Product",
|
| 95 |
+
'I-Clothing': "I-Product",
|
| 96 |
+
'B-Disease': "B-Medical",
|
| 97 |
+
'I-Disease': "I-Medical",
|
| 98 |
+
'B-Drink': "B-Product",
|
| 99 |
+
'I-Drink': "I-Product",
|
| 100 |
+
'B-Facility': "B-Location",
|
| 101 |
+
'I-Facility': "I-Location",
|
| 102 |
+
'B-Food': "B-Product",
|
| 103 |
+
'I-Food': "I-Product",
|
| 104 |
+
'B-HumanSettlement': "B-Location",
|
| 105 |
+
'I-HumanSettlement': "I-Location",
|
| 106 |
+
'B-MedicalProcedure': "B-Medical",
|
| 107 |
+
'I-MedicalProcedure': "I-Medical",
|
| 108 |
+
'B-Medication/Vaccine': "B-Medical",
|
| 109 |
+
'I-Medication/Vaccine': "I-Medical",
|
| 110 |
+
'B-MusicalGRP': "B-Group",
|
| 111 |
+
'I-MusicalGRP': "I-Group",
|
| 112 |
+
'B-MusicalWork': "B-CreativeWork",
|
| 113 |
+
'I-MusicalWork': "I-CreativeWork",
|
| 114 |
+
'B-ORG': "B-Group",
|
| 115 |
+
'I-ORG': "I-Group",
|
| 116 |
+
'B-OtherLOC': "B-Location",
|
| 117 |
+
'I-OtherLOC': "I-Location",
|
| 118 |
+
'B-OtherPER': "B-Person",
|
| 119 |
+
'I-OtherPER': "I-Person",
|
| 120 |
+
'B-OtherPROD': "B-Product",
|
| 121 |
+
'I-OtherPROD': "I-Product",
|
| 122 |
+
'B-Politician': "B-Person",
|
| 123 |
+
'I-Politician': "I-Person",
|
| 124 |
+
'B-PrivateCorp': "B-Group",
|
| 125 |
+
'I-PrivateCorp': "I-Group",
|
| 126 |
+
'B-PublicCorp': "B-Group",
|
| 127 |
+
'I-PublicCorp': "B-Group",
|
| 128 |
+
'B-Scientist': "B-Person",
|
| 129 |
+
'I-Scientist': "I-Person",
|
| 130 |
+
'B-Software': "B-CreativeWork",
|
| 131 |
+
'I-Software': "I-CreativeWork",
|
| 132 |
+
'B-SportsGRP': "B-Group",
|
| 133 |
+
'I-SportsGRP': "I-Group",
|
| 134 |
+
'B-SportsManager': "B-Person",
|
| 135 |
+
'I-SportsManager': "I-Person",
|
| 136 |
+
'B-Station': 'B-Location',
|
| 137 |
+
'I-Station': 'I-Location',
|
| 138 |
+
'B-Symptom': "B-Medical",
|
| 139 |
+
'I-Symptom': "I-Medical",
|
| 140 |
+
'B-Vehicle': "B-Product",
|
| 141 |
+
'I-Vehicle': "I-Product",
|
| 142 |
+
'B-VisualWork': "B-CreativeWork",
|
| 143 |
+
'I-VisualWork': "I-CreativeWork",
|
| 144 |
+
'B-WrittenWork': "B-CreativeWork",
|
| 145 |
+
'I-WrittenWork': "I-CreativeWork",
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
def _info(self):
|
| 149 |
return datasets.DatasetInfo(
|
| 150 |
description=_DESCRIPTION,
|
|
|
|
| 190 |
'B-WrittenWork', 'I-WrittenWork']
|
| 191 |
)
|
| 192 |
),
|
| 193 |
+
"ner_macro_tags": datasets.Sequence(
|
| 194 |
+
datasets.features.ClassLabel(
|
| 195 |
+
names=['O',
|
| 196 |
+
"B-Location", "I-Location"
|
| 197 |
+
"B-CreativeWork", "I-CreativeWork",
|
| 198 |
+
"B-Group", "I-Group",
|
| 199 |
+
"B-Person", "I-Person",
|
| 200 |
+
"B-Product", "I-Product",
|
| 201 |
+
"B-Medical", "I-Medical",
|
| 202 |
+
]
|
| 203 |
+
)
|
| 204 |
+
),
|
| 205 |
}
|
| 206 |
),
|
| 207 |
supervised_keys=None,
|
|
|
|
| 250 |
"id": str(guid),
|
| 251 |
"tokens": tokens,
|
| 252 |
"ner_tags": ner_tags,
|
| 253 |
+
"ner_macro_tags": [self.micro_to_macro_ner_mapping[ner] for ner in ner_tags]
|
| 254 |
}
|