def mass_replace(string, word_dict):
    """
    Take a text and replace words that match the key in a dictionary
    with the associated value, return the changed text
    """
    for key in word_dict:
        try:
            string = string.replace(word_dict[key], key)
        except TypeError:
            for variant in word_dict[key]:
                string = string.replace(variant, key)
    return string
