def load_vocabulary(path):
    """Loads the vocabulary from the given path and constructs a dictionary for
    mapping of vocabulary to numerical ID's as well as a list for the reverse
    mapping.

    Args:
    path: The path from which the vocabulary has to be loaded.

    Returns:
    A dictionary of forward and reverse mappings.
    """

    if not isinstance(path, str):
        raise TypeError('path should be a string')

    vocab = []
    rev = []
    with open(path) as fd:
        for line in fd:
            line = line.rstrip('\r\n')
            rev.append(line)
        vocab = dict([(x, y) for (y, x) in enumerate(rev)])

    return {'vocab': vocab, 'rev': rev}