import re


def output_cleaner(text):
    """
    Clean text generated by the multiple line generated by textgen.generate.
    Removes "^ ". Removes empty line. Clean other things TBD.
    :param text: text to clean
    :return: cleaned text
    """
    regex_patterns = []
    regex_patterns.append(("\n ", "\n"))  # space at beginning of line
    regex_patterns.append(("\n{2,}", "\n"))  # multiple newlines
    regex_patterns.append(("i ' m", "i'm"))  # i ' m -->i'm
    for (p, r) in regex_patterns:
        text = re.sub(re.compile(p), r, text)

    return text