def compute_spam_word_ratio()

in build_obelics/13_final_processing.py [0:0]


def compute_spam_word_ratio(txt):
    words = FilteringFunctions.get_words_from_text(
        text=txt, lower_case=True, strip_words=True, strip_characters=SPECIAL_CHARACTERS
    )
    if not words:
        return 0
    spam_word_ratio = len([word for word in words if word in SPAM_WORDS]) / len(words)
    return spam_word_ratio