def vocab_from_file(path):
    """ Read all words of vocabulary from a file.

    Parameters
    ----------
    path : string
        Path of vocabulary file.

    Returns
    -------
    index2word : dict_like, shape (vocabsize)
        Dictionary that contains indices as keys, and words as values.

    word2index : dict_like, shape (vocabsize)
        Dictionary that contains words as keys, and indices as values.
    """

    fin = open(path, 'r')

    WORD_INDEX = 0
    index2word = dict()
    word2index = dict()

    while True:

        line = fin.readline()

        if not line:
            break

        word_freq = line.split()
        word = word_freq[WORD_INDEX]
        word2index[word] = len(word2index) + 1
        index2word[len(index2word) + 1] = word

    fin.close()

    return (index2word, word2index)