from profanity_filter import ProfanityFilter pf = ProfanityFilter() extra_negative_words = {'en': {}} with open("five-letter-words-extra-negative.txt", "r") as extra_negative_file: words = extra_negative_file.read().splitlines() extra_negative_words['en'] = dict.fromkeys(words) pf.extra_profane_word_dictionaries = extra_negative_words with open("five-letter-words.txt", "r") as source_file, open( "five-letter-words-clean.txt", "w") as clean_file, open("five-letter-words-profane.txt", "w") as profane_file: words = source_file.read().splitlines() for word in words: if pf.is_profane(word): profane_file.write(f"{word}\n") print( f"Word \'{word}\' is profane or negative. Omitting from the cleaned file." ) else: clean_file.write(f"{word}\n")
import discord from profanity_filter import ProfanityFilter client = discord.Client() pf = ProfanityFilter() pf.extra_profane_word_dictionaries = { 'en': { 'dumbass', 'MOTHERFUCKERS', 'motherfuckers', 'benchod', 'madrachod', 'BENCHOD', 'MADRACHOD' } } # not case insensitive; should I add dhigger (the n word for Indians)... nah @client.event async def on_ready(): print('We have logged in as {0.user}'.format(client)) await client.change_presence(activity=discord.Activity( type=discord.ActivityType.listening, name="52 Stories by Omar Waseem on Spotify and iTunes", title="52 Stories", color=discord.Color.green())) # selmshots left the podcast :( #await client.change_presence(activity=discord.Spotify(type=discord.ActivityType.listening, name="Spotify", title="52 Stories")) #await client.change_presence(activity=discord.Spotify(title="52 Stories")) @client.event async def on_message(message): if message.author == client.user: return
import re from profanity_filter import ProfanityFilter from . import config from . import lib config = config.config pr_config = config['profanity_rater'] pf = ProfanityFilter(analyses=pr_config['languages'], languages=pr_config['languages']) pf.censor_char = '*' pf.extra_profane_word_dictionaries = pr_config['extra_profane_word_dictionary'] def profanity_severity_rating(content_text, turn_on=None): severity = 0 if turn_on is None: turn_on = pr_config['turn_on'] if turn_on == False: return severity cencored_text = pf.censor(content_text) profane_words = re.findall(f"\{pf.censor_char}+", cencored_text) total_words = lib.word_count(content_text) percent_profane = (len(profane_words) / total_words) * 100 if percent_profane > pr_config['safe_profanity_percent']: severity = pr_config['severity_start'] # Increase severity as the percentage goes up by the rate set in the config. # Max severity will be 10 (set in the config file)