From 901dde0e4583a00dc7e486aca6cda7acb647dea9 Mon Sep 17 00:00:00 2001 From: thomwolf Date: Tue, 20 Aug 2019 11:05:51 +0200 Subject: [PATCH] fix #1014 --- pytorch_transformers/tokenization_bert.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pytorch_transformers/tokenization_bert.py b/pytorch_transformers/tokenization_bert.py index 177d26dec1..04f35aa466 100644 --- a/pytorch_transformers/tokenization_bert.py +++ b/pytorch_transformers/tokenization_bert.py @@ -187,6 +187,8 @@ class BertTokenizer(PreTrainedTokenizer): index = 0 if os.path.isdir(vocab_path): vocab_file = os.path.join(vocab_path, VOCAB_FILES_NAMES['vocab_file']) + else: + vocab_file = vocab_path with open(vocab_file, "w", encoding="utf-8") as writer: for token, token_index in sorted(self.vocab.items(), key=lambda kv: kv[1]): if index != token_index: