Datasets:
Tasks:
Token Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
named-entity-recognition
Languages:
English
Size:
10K - 100K
License:
Update fabner.py with new tagging formats
Browse files
fabner.py
CHANGED
|
@@ -78,79 +78,60 @@ class FabNER(datasets.GeneratorBasedBuilder):
|
|
| 78 |
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 79 |
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 80 |
BUILDER_CONFIGS = [
|
| 81 |
-
datasets.BuilderConfig(name="fabner", version=VERSION,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
]
|
|
|
|
| 83 |
|
| 84 |
def _info(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
features = datasets.Features(
|
| 86 |
{
|
| 87 |
"id": datasets.Value("string"),
|
| 88 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
| 89 |
"ner_tags": datasets.Sequence(
|
| 90 |
datasets.features.ClassLabel(
|
| 91 |
-
names=
|
| 92 |
-
"O",
|
| 93 |
-
"B-MATE", # Material
|
| 94 |
-
"I-MATE",
|
| 95 |
-
"O-MATE",
|
| 96 |
-
"E-MATE",
|
| 97 |
-
"S-MATE",
|
| 98 |
-
"B-MANP", # Manufacturing Process
|
| 99 |
-
"I-MANP",
|
| 100 |
-
"O-MANP",
|
| 101 |
-
"E-MANP",
|
| 102 |
-
"S-MANP",
|
| 103 |
-
"B-MACEQ", # Machine/Equipment
|
| 104 |
-
"I-MACEQ",
|
| 105 |
-
"O-MACEQ",
|
| 106 |
-
"E-MACEQ",
|
| 107 |
-
"S-MACEQ",
|
| 108 |
-
"B-APPL", # Application
|
| 109 |
-
"I-APPL",
|
| 110 |
-
"O-APPL",
|
| 111 |
-
"E-APPL",
|
| 112 |
-
"S-APPL",
|
| 113 |
-
"B-FEAT", # Engineering Features
|
| 114 |
-
"I-FEAT",
|
| 115 |
-
"O-FEAT",
|
| 116 |
-
"E-FEAT",
|
| 117 |
-
"S-FEAT",
|
| 118 |
-
"B-PRO", # Mechanical Properties
|
| 119 |
-
"I-PRO",
|
| 120 |
-
"O-PRO",
|
| 121 |
-
"E-PRO",
|
| 122 |
-
"S-PRO",
|
| 123 |
-
"B-CHAR", # Process Characterization
|
| 124 |
-
"I-CHAR",
|
| 125 |
-
"O-CHAR",
|
| 126 |
-
"E-CHAR",
|
| 127 |
-
"S-CHAR",
|
| 128 |
-
"B-PARA", # Process Parameters
|
| 129 |
-
"I-PARA",
|
| 130 |
-
"O-PARA",
|
| 131 |
-
"E-PARA",
|
| 132 |
-
"S-PARA",
|
| 133 |
-
"B-ENAT", # Enabling Technology
|
| 134 |
-
"I-ENAT",
|
| 135 |
-
"O-ENAT",
|
| 136 |
-
"E-ENAT",
|
| 137 |
-
"S-ENAT",
|
| 138 |
-
"B-CONPRI", # Concept/Principles
|
| 139 |
-
"I-CONPRI",
|
| 140 |
-
"O-CONPRI",
|
| 141 |
-
"E-CONPRI",
|
| 142 |
-
"S-CONPRI",
|
| 143 |
-
"B-MANS", # Manufacturing Standards
|
| 144 |
-
"I-MANS",
|
| 145 |
-
"O-MANS",
|
| 146 |
-
"E-MANS",
|
| 147 |
-
"S-MANS",
|
| 148 |
-
"B-BIOP", # BioMedical
|
| 149 |
-
"I-BIOP",
|
| 150 |
-
"O-BIOP",
|
| 151 |
-
"E-BIOP",
|
| 152 |
-
"S-BIOP",
|
| 153 |
-
]
|
| 154 |
)
|
| 155 |
),
|
| 156 |
}
|
|
@@ -203,7 +184,18 @@ class FabNER(datasets.GeneratorBasedBuilder):
|
|
| 203 |
else:
|
| 204 |
splits = line.split(" ")
|
| 205 |
tokens.append(splits[0])
|
| 206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
# last example
|
| 208 |
if tokens:
|
| 209 |
yield guid, {
|
|
|
|
| 78 |
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 79 |
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 80 |
BUILDER_CONFIGS = [
|
| 81 |
+
datasets.BuilderConfig(name="fabner", version=VERSION,
|
| 82 |
+
description="The FabNER dataset with the original BIOES tagging format"),
|
| 83 |
+
datasets.BuilderConfig(name="fabner_bio", version=VERSION,
|
| 84 |
+
description="The FabNER dataset with BIO tagging format"),
|
| 85 |
+
datasets.BuilderConfig(name="fabner_simple", version=VERSION,
|
| 86 |
+
description="The FabNER dataset with no tagging format"),
|
| 87 |
]
|
| 88 |
+
DEFAULT_CONFIG_NAME = "fabner"
|
| 89 |
|
| 90 |
def _info(self):
|
| 91 |
+
entity_types = [
|
| 92 |
+
"MATE", # Material
|
| 93 |
+
"MANP", # Manufacturing Process
|
| 94 |
+
"MACEQ", # Machine/Equipment
|
| 95 |
+
"APPL", # Application
|
| 96 |
+
"FEAT", # Engineering Features
|
| 97 |
+
"PRO", # Mechanical Properties
|
| 98 |
+
"CHAR", # Process Characterization
|
| 99 |
+
"PARA", # Process Parameters
|
| 100 |
+
"ENAT", # Enabling Technology
|
| 101 |
+
"CONPRI", # Concept/Principles
|
| 102 |
+
"MANS", # Manufacturing Standards
|
| 103 |
+
"BIOP", # BioMedical
|
| 104 |
+
]
|
| 105 |
+
if self.config.name == "fabner":
|
| 106 |
+
class_labels = ["O"]
|
| 107 |
+
for entity_type in entity_types:
|
| 108 |
+
class_labels.extend(
|
| 109 |
+
[
|
| 110 |
+
"B-" + entity_type,
|
| 111 |
+
"I-" + entity_type,
|
| 112 |
+
"O-" + entity_type,
|
| 113 |
+
"E-" + entity_type,
|
| 114 |
+
"S-" + entity_type,
|
| 115 |
+
]
|
| 116 |
+
)
|
| 117 |
+
elif self.config.name == "fabner_bio":
|
| 118 |
+
class_labels = ["O"]
|
| 119 |
+
for entity_type in entity_types:
|
| 120 |
+
class_labels.extend(
|
| 121 |
+
[
|
| 122 |
+
"B-" + entity_type,
|
| 123 |
+
"I-" + entity_type,
|
| 124 |
+
]
|
| 125 |
+
)
|
| 126 |
+
else:
|
| 127 |
+
class_labels = ["O"] + entity_types
|
| 128 |
features = datasets.Features(
|
| 129 |
{
|
| 130 |
"id": datasets.Value("string"),
|
| 131 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
| 132 |
"ner_tags": datasets.Sequence(
|
| 133 |
datasets.features.ClassLabel(
|
| 134 |
+
names=class_labels
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
)
|
| 136 |
),
|
| 137 |
}
|
|
|
|
| 184 |
else:
|
| 185 |
splits = line.split(" ")
|
| 186 |
tokens.append(splits[0])
|
| 187 |
+
ner_tag = splits[1].rstrip()
|
| 188 |
+
if self.config.name == "fabner_simple":
|
| 189 |
+
if ner_tag == "O":
|
| 190 |
+
ner_tag = "O"
|
| 191 |
+
else:
|
| 192 |
+
ner_tag = ner_tag.split("-")[1]
|
| 193 |
+
elif self.config.name == "fabner_bio":
|
| 194 |
+
if ner_tag == "O":
|
| 195 |
+
ner_tag = "O"
|
| 196 |
+
else:
|
| 197 |
+
ner_tag = ner_tag.replace("S-", "B-").replace("E-", "I-")
|
| 198 |
+
ner_tags.append(ner_tag)
|
| 199 |
# last example
|
| 200 |
if tokens:
|
| 201 |
yield guid, {
|