(vocab_dir)
return word_to_id, id_to_word
:param vocab_dir:
    :return:
def word_2_id(vocab_dir):
    """

    :param vocab_dir:
    :return:
    """
    with open(vocab_dir) as f:
        words = [_.strip() for _ in f.readlines()]

    word_to_id = dict(zip(words, range(len(words))))
    id_to_word = dict((v, k) for k, v in word_to_id.items())

    return word_to_id, id_to_word
def word_2_id ( vocab_dir ) : with open ( vocab_dir ) as f : words = [ _ . strip ( ) for _ in f . readlines ( ) ] word_to_id = dict ( zip ( words , range ( len ( words ) ) ) ) id_to_word = dict ( ( v , k ) for k , v in word_to_id . items ( ) ) return word_to_id , id_to_word