(self, vocab_file)
return vocab
Loads a vocabulary file into a dictionary.
Loads a vocabulary file into a dictionary.
Loads a vocabulary file into a dictionary .
def load_vocab(self, vocab_file):
    """Loads a vocabulary file into a dictionary."""
    vocab = collections.OrderedDict()
    index = 0
    with tf.io.gfile.GFile(vocab_file, "r") as reader:
      while True:
        token = native_to_unicode(reader.readline())
        if not token:
          break
        token = token.strip()
        vocab[token] = index
        index += 1
    return vocab
def load_vocab ( self , vocab_file ) : vocab = collections . OrderedDict ( ) index = 0 with tf . io . gfile . GFile ( vocab_file , "r" ) as reader : while True : token = native_to_unicode ( reader . readline ( ) ) if not token : break token = token . strip ( ) vocab [ token ] = index index += 1 return vocab