<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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