Datasets:
Commit
·
e781983
1
Parent(s):
c0a497e
Update multiconer_v2.py
Browse files- multiconer_v2.py +34 -32
multiconer_v2.py
CHANGED
@@ -288,38 +288,40 @@ class MultiCoNER2(datasets.GeneratorBasedBuilder):
|
|
288 |
|
289 |
|
290 |
with open(filepath) as f:
|
291 |
-
guid =
|
292 |
s_id = None
|
293 |
tokens = []
|
294 |
ner_tags = []
|
295 |
-
|
296 |
-
for
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
|
|
|
|
|
288 |
|
289 |
|
290 |
with open(filepath) as f:
|
291 |
+
guid = 0
|
292 |
s_id = None
|
293 |
tokens = []
|
294 |
ner_tags = []
|
295 |
+
|
296 |
+
for line in f:
|
297 |
+
yield guid, {'id': '0', 'data':line}
|
298 |
+
guid+=1
|
299 |
+
|
300 |
+
# if line.strip().startswith("# id"):
|
301 |
+
# s_id = line.split('\t')[0].split(' ')[-1].strip()
|
302 |
+
# guid += 1
|
303 |
+
# tokens = []
|
304 |
+
# ner_tags = []
|
305 |
+
# elif '_ _' in line:
|
306 |
+
# # Separator is " _ _ "
|
307 |
+
# splits = line.split("_ _")
|
308 |
+
# tokens.append(splits[0].strip())
|
309 |
+
# ner_tags.append(splits[1].strip())
|
310 |
+
# elif len(line.strip()) == 0:
|
311 |
+
# if s_id and len(tokens) >= 1 and len(tokens) == len(ner_tags):
|
312 |
+
# yield guid, {
|
313 |
+
# "id": s_id,
|
314 |
+
# "tokens": tokens,
|
315 |
+
# "ner_tags": ner_tags,
|
316 |
+
# }
|
317 |
+
# s_id = None
|
318 |
+
# tokens = []
|
319 |
+
# ner_tags = []
|
320 |
+
# else:
|
321 |
+
# continue
|
322 |
+
# if s_id and len(tokens) >= 1 and len(tokens) == len(ner_tags):
|
323 |
+
# yield guid, {
|
324 |
+
# "id": s_id,
|
325 |
+
# "tokens": tokens,
|
326 |
+
# "ner_tags": ner_tags,
|
327 |
+
# }
|