import re
import string


def normalize_answer(s):
    """Lower text and remove punctuation, articles and extra whitespace.
    This function is an extended version of the SQuAD evaluation script.

    Arguments:
        s: ``str`` String to normalize.
    """

    def remove_articles(text):
        regex = re.compile(r"\b(a|an|the)\b", re.UNICODE)
        return re.sub(regex, " ", text)

    def white_space_fix(text):
        return " ".join(text.split())

    def remove_punc(text):
        # Replace dash with a space
        text = text.replace("-", " ")
        # Replace other punctuation with empty string
        for punc in string.punctuation:
            text = text.replace(punc, "")
        return text

    def lower(text):
        return text.lower()

    return white_space_fix(remove_articles(remove_punc(lower(s))))