(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()
    with open(vocab_file, "r", encoding="utf-8") as reader:
        tokens = reader.readlines()
    for index, token in enumerate(tokens):
        token = token.rstrip('\n')
        vocab[token] = index
    return vocab
def load_vocab ( vocab_file ) : vocab = collections . OrderedDict ( ) with open ( vocab_file , "r" , encoding = "utf-8" ) as reader : tokens = reader . readlines ( ) for index , token in enumerate ( tokens ) : token = token . rstrip ( '\n' ) vocab [ token ] = index return vocab