cryptexcode commited on
Commit
e781983
·
1 Parent(s): c0a497e

Update multiconer_v2.py

Browse files
Files changed (1) hide show
  1. 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 = -1
292
  s_id = None
293
  tokens = []
294
  ner_tags = []
295
-
296
- for l in f:
297
- line = l.decode("utf-8")
298
- if line.strip().startswith("# id"):
299
- s_id = line.split('\t')[0].split(' ')[-1].strip()
300
- guid += 1
301
- tokens = []
302
- ner_tags = []
303
- elif '_ _' in line:
304
- # Separator is " _ _ "
305
- splits = line.split("_ _")
306
- tokens.append(splits[0].strip())
307
- ner_tags.append(splits[1].strip())
308
- elif len(line.strip()) == 0:
309
- if s_id and len(tokens) >= 1 and len(tokens) == len(ner_tags):
310
- yield guid, {
311
- "id": s_id,
312
- "tokens": tokens,
313
- "ner_tags": ner_tags,
314
- }
315
- s_id = None
316
- tokens = []
317
- ner_tags = []
318
- else:
319
- continue
320
- if s_id and len(tokens) >= 1 and len(tokens) == len(ner_tags):
321
- yield guid, {
322
- "id": s_id,
323
- "tokens": tokens,
324
- "ner_tags": ner_tags,
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
+ # }