Degree of Profanity in a Sentence
One way to approach it is to split the sentence into tokens and count the number of tokens that are profanities.

import re

def tokenize(text): 
    return re.findall(r'\w+', text.lower())

profane_tokens = {"nerfherder"}

sentence = "Why you stuck-up, half-witted, scruffy-looking nerfherder!"

tokens = tokenize(sentence)

# Rate: number of occurrences normalized by total number
degree_of_profanity = sum(1 for t in tokens if t in profane) / len(tokens)


This code will not handle multiple tokens and many profanities are multiple tokens.