Update icelandic-ner-MIM-GOLD-NER.py
Browse files
icelandic-ner-MIM-GOLD-NER.py
CHANGED
@@ -145,6 +145,30 @@ class MIMGoldNER(datasets.GeneratorBasedBuilder):
|
|
145 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
146 |
]
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
def _generate_examples(self, filepath):
|
149 |
logger.info("⏳ Generating examples from = %s", filepath)
|
150 |
with open(filepath, encoding="utf-8") as f:
|
@@ -170,8 +194,10 @@ class MIMGoldNER(datasets.GeneratorBasedBuilder):
|
|
170 |
splits = line.split("\t")
|
171 |
tokens.append(splits[0])
|
172 |
try:
|
173 |
-
|
174 |
-
|
|
|
|
|
175 |
except:
|
176 |
print(splits)
|
177 |
raise
|
|
|
145 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
146 |
]
|
147 |
|
148 |
+
def _mim2conll(self, ner_tags):
|
149 |
+
|
150 |
+
MIM2CONLL = {
|
151 |
+
"O": "O",
|
152 |
+
"B-Date": "O",
|
153 |
+
"B-Location": "B-LOC",
|
154 |
+
"B-Miscellaneous": "B-MISC",
|
155 |
+
"B-Money": "O",
|
156 |
+
"B-Organization": "B-ORG",
|
157 |
+
"B-Percent": "O",
|
158 |
+
"B-Person": "B-PER",
|
159 |
+
"B-Time": "O",
|
160 |
+
"I-Date": "O",
|
161 |
+
"I-Location": "I-LOC",
|
162 |
+
"I-Miscellaneous": "I-MISC",
|
163 |
+
"I-Money": "O",
|
164 |
+
"I-Organization": "I-ORG",
|
165 |
+
"I-Percent": "O",
|
166 |
+
"I-Person": "I-PER",
|
167 |
+
"I-Time": "O"
|
168 |
+
}
|
169 |
+
|
170 |
+
return " ".join([MIM2CONLL[tag] for tag in ner_tags.split()])
|
171 |
+
|
172 |
def _generate_examples(self, filepath):
|
173 |
logger.info("⏳ Generating examples from = %s", filepath)
|
174 |
with open(filepath, encoding="utf-8") as f:
|
|
|
194 |
splits = line.split("\t")
|
195 |
tokens.append(splits[0])
|
196 |
try:
|
197 |
+
sentence_ner_tags = splits[1].rstrip()
|
198 |
+
ner_tags.append(sentence_ner_tags)
|
199 |
+
sentence_conll_ner_tags = self._mim2conll(sentence_ner_tags)
|
200 |
+
conll_ner_tags.append(sentence_conll_ner_tags)
|
201 |
except:
|
202 |
print(splits)
|
203 |
raise
|