import re


def cleanse(text):
    """
    Clean up the text a little by removing punctuation, extra spaces, new lines, etc.
    This should be run after split_to_sentences(), tokenize_by_sentence() because I think it removes all the
    punctuation you will need to split the text into sentences.
    :param text:
    :return:
    """
    text = text.lower()
    text = text.replace("'", '')    # Remove apostrophes
    # text = re.sub('[^\w\s]', ' ', text)
    # Replace punct with a space so that when someone does something like <word comma word> you don't accidentally
    # transform it into one word.  We remove extra spaces in the next line.
    text = re.sub('[^\w\s]', ' ', text)
    text = re.sub('\\n', ' ', text)
    text = re.sub(' +', ' ', text)
    text = text.strip()     # Small thing but remove a trailing space.
    return text