File size: 394 Bytes
190f036
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
import re

def identify_bad_words(text):
    bad_words = []
    with open('./src/bad_words.txt', 'r') as filehandle:
        bad_words = [current_place.rstrip()
                        for current_place in filehandle.readlines()]
    pattern = re.compile('[A-Z]*[a-z]+')
    cleaned_text = pattern.findall(text)
    long_word_set = set(bad_words)
    return (set(cleaned_text) & long_word_set)