8000 fix load vocabs · flypythoncom/ner-bert@352fed9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 352fed9

Browse files
committed
fix load vocabs
1 parent 7856f2d commit 352fed9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

modules/data/bert_data.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from tqdm import tqdm
77
from modules.utils import read_json, save_json
88
import logging
9+
import os
910

1011

1112
class InputFeatures(object):
@@ -448,12 +449,12 @@ def create(cls,
448449
meta2idx = None
449450
cls2idx = None
450451

451-
if idx2label is None and idx2label_path is not None:
452+
if idx2label is None and os.path.exists(str(idx2label_path)):
452453
idx2label = read_json(idx2label_path)
453-
if is_meta and idx2meta is None and idx2meta_path is not None:
454+
if is_meta and idx2meta is None and os.path.exists(str(idx2meta_path)):
454455
idx2meta = read_json(idx2meta_path)
455456
meta2idx = {label: idx for idx, label in enumerate(idx2meta)}
456-
if is_cls and idx2cls is None and idx2cls_path is not None:
457+
if is_cls and idx2cls is None and os.path.exists(str(idx2cls_path)):
457458
idx2cls = read_json(idx2cls_path)
458459
cls2idx = {label: idx for idx, label in enumerate(idx2cls)}
459460
387D label2idx = {label: idx for idx, label in enumerate(idx2label)}

0 commit comments

Comments
 (0)
0