def contains_entity(entity, text):
        """
        Attempt to try entity, return false if not found. Otherwise the
        amount of time entitu is occuring.
        """

        try:
            entity = re.escape(entity)
            entity = entity.replace("\ ", "([^\w])?")
            pattern = "(\ |-|\\\|/|\.|,|^)%s(\ |\-|\\\|/|\.|,|$)" % entity
            found = len(re.findall(pattern, text, re.I | re.M))
        except Exception as e:
            found = False

        return found
Attempt to try entity, return false if not found. Otherwise the
        amount of time entitu is occuring.