(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(vocab_file):
    """Loads a vocabulary file into a dictionary."""
    vocab = collections.OrderedDict()
    index = 0
    with open(vocab_file, "r", encoding="utf-8") as reader:
        while True:
            token = reader.readline()
            if not token:
                break
            token = token.strip()
            vocab[token] = index
            index += 1
    return vocab
def load_vocab ( vocab_file ) : vocab = collections . OrderedDict ( ) index = 0 with open ( vocab_file , "r" , encoding = "utf-8" ) as reader : while True : token = reader . readline ( ) if not token : break token = token . strip ( ) vocab [ token ] = index index += 1 return vocab