Skip to content

Commit

Permalink
Merge pull request #17 from winkelman/ner_fix_label2id_path
Browse files Browse the repository at this point in the history
fix path for label2id.pkl
  • Loading branch information
wonjininfo committed Mar 11, 2019
2 parents f8bdd2b + 59e35ac commit cc25c83
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions run_ner.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def convert_single_example(ex_index, example, label_list, max_seq_length, tokeni
label_map = {}
for (i, label) in enumerate(label_list,1):
label_map[label] = i
with open(FLAGS.output_dir+'label2id.pkl','wb') as w:
with open(os.path.join(FLAGS.output_dir, 'label2id.pkl'),'wb') as w:
pickle.dump(label_map,w)
textlist = example.text.split(' ')
labellist = example.label.split(' ')
Expand Down Expand Up @@ -580,7 +580,7 @@ def main(_):
writer.write("%s = %s\n" % (key, str(result[key])))
if FLAGS.do_predict:
token_path = os.path.join(FLAGS.output_dir, "token_test.txt")
with open(FLAGS.output_dir+'label2id.pkl','rb') as rf:
with open(os.path.join(FLAGS.output_dir, 'label2id.pkl'),'rb') as rf:
label2id = pickle.load(rf)
id2label = {value:key for key,value in label2id.items()}
if os.path.exists(token_path):
Expand Down

0 comments on commit cc25c83

Please sign in to comment.