Spaces:
Sleeping
Sleeping
Update app.py
Browse files10 unmodified lines111213141516171819202122232452 unmodified lines7778798081828310 unmodified linesself.database_url = database_urlself.conversation_history = []# Profanity filter - list of bad words to filterself.bad_words = {'damn', 'hell', 'crap', 'suck', 'idiot', 'fool', 'jerk', 'loser', 'dumb', 'trash','butt', 'freak', 'nut', 'moron', 'dummy', 'bozo', 'twit', 'dope', 'dumbass','poophead', 'jerkoff', 'bugger', 'wanker', 'tosser', 'bastard', 'scum', 'slime','creep', 'brat', 'dweeb', 'goon', 'booby', 'puke', 'vomit', 'dung', 'sap','clutz', 'knob', 'prick', 'ass', 'shit', 'fuck', 'cock', 'tits', 'pussy','cunt', 'slut', 'bitch', 'whore', 'skank'}# Simple conversation patterns52 unmodified lines# Normalize message: convert to lowercasemessage_lower = message.lower()# First, normalize common obfuscation characters# Replace common character substitutions (numbers/symbols) with lettersobfuscation_map = {'0': 'o', '1': 'i', '3': 'e', '4': 'a', '5': 's',10 unmodified lines11121314151617181920212223242526272829303132333452 unmodified lines8788899091929394959697989910010110210310 unmodified linesself.database_url = database_urlself.conversation_history = []# Profanity filter - list of bad words to filter (English and Tagalog)self.bad_words = {# English bad words'damn', 'hell', 'crap', 'suck', 'idiot', 'fool', 'jerk', 'loser', 'dumb', 'trash','butt', 'freak', 'nut', 'moron', 'dummy', 'bozo', 'twit', 'dope', 'dumbass','poophead', 'jerkoff', 'bugger', 'wanker', 'tosser', 'bastard', 'scum', 'slime','creep', 'brat', 'dweeb', 'goon', 'booby', 'puke', 'vomit', 'dung', 'sap','clutz', 'knob', 'prick', 'ass', 'shit', 'fuck', 'cock', 'tits', 'pussy','cunt', 'slut', 'bitch', 'whore', 'skank', 'stupid',# Tagalog bad words'gago', 'putangina', 'hayop', 'lintik', 'walang', 'hiya', 'bobo', 'leche','punyeta', 'sira', 'ulo', 'bwisit', 'pakshet', 'tarantado', 'ulol', 'buwisit','hudas', 'kupal', 'shet', 'tae', 'tanga', 'tangina'}# Tagalog phrases (multi-word profanity)self.bad_phrases = {'walang hiya', 'sira ulo'}# Simple conversation patterns52 unmodified lines# Normalize message: convert to lowercasemessage_lower = message.lower()# First, check for bad phrases (multi-word profanity like "walang hiya", "sira ulo")for phrase in self.bad_phrases:# Remove punctuation and check if phrase exists in messagephrase_clean = re.sub(r'[^\w\s]', '', phrase)message_clean_phrase = re.sub(r'[^\w\s]', '', message_lower)# Check if phrase appears in message (with flexible spacing)phrase_pattern = r'\b' + r'\s+'.join(re.escape(word) for word in phrase_clean.split()) + r'\b'if re.search(phrase_pattern, message_clean_phrase, re.IGNORECASE):return True# Normalize common obfuscation characters# Replace common character substitutions (numbers/symbols) with lettersobfuscation_map = {'0': 'o', '1': 'i', '3': 'e', '4': 'a', '5': 's',
app.py+23-3