def get_index_dictionary(filepath, delimiter='\n'):
    """Generates a dictionary of words to their respective indices.

    Args:
        filepath (str): File path.
        delimiter (str, optional): Delimiter separating words. Defaults to '\n'.

    Returns:
        Dictionary mapping words to their indices.
    """

    with open(filepath, 'r') as f:
        lines = f.readlines()

    return {k.strip(delimiter): v for v, k in enumerate(lines)}