import string
import re


def normalize_answer(s, remove_articles=True, keep_punc=None):
  """Lower text and remove punctuation, articles and extra whitespace."""

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

  s = s.replace('_', ' ').lower()
  exclude = set(string.punctuation + "".join([u"‘", u"’", u"´", u"`"]))
  for punc in (keep_punc or []):
    exclude.remove(punc)
  s = ''.join(ch if ch not in exclude else ' ' for ch in s)
  if remove_articles:
    s = re.sub(r'\b(a|an|the)\b', ' ', s)
  return white_space_fix(s).strip()