import re


def toxicity_check(word_list,text):
    """

    Check words that are profane

    Parameters
    ----------

    word_list: set

        set of words in english dictionary

    text : str

       output string from function pre-processing

    Returns
    -------
    set
        list of words that are profane

    int
         count of words that are profane

    float

         proportion of words that are profane in the entire text
      
    Examples
    --------
    >>> text="this is so shitty"
    >>> toxicity_check(toxic_words,text)

    {'toxic_words': [{'shitty'}],
     'count_toxic_words': 1,
     'proportion_toxic_words': 0.25}

    """

    toxic_content= {'toxic_words': [set()],
                    'count_toxic_words': 0,
                    'proportion_toxic_words': 0.0}



    if len(text.split())!=0:
        toxic_words=set(text.split()).intersection(word_list)

        if len(toxic_words)!=0:
            #remove toxic words
            pattern = re.compile(r'\b(' + r'|'.join(toxic_words) + r')\b\s*')
            text_toxic_words = (pattern.sub('', text)).split()
            count_toxic_words = len(text.split())-len(text_toxic_words)


            return {'toxic_words': [toxic_words],
                    'count_toxic_words': count_toxic_words,
                    'proportion_toxic_words':count_toxic_words/len(text.split())}

        else:
            return toxic_content

    else:
        return toxic_content