from typing import Union
from pathlib import Path
from typing import Dict
import json


def load_vocab(path: Union[str, Path]) -> Dict:
    """
    Load vocabulary from a JSON file.
    Args:
        path: Path to file.
    Returns:
        Dictionary object i.e. the vocabulary.
    """
    f = open(path, "r")
    vocab = json.load(f)
    f.close()
    return vocab