def applyProfanityFilter():
    pf = ProfanityFilter()
    pf.censor_char = '@'

    with open('media/recording1/transcript.csv', mode='w+') as csv_file:
        csv_writer = csv.writer(csv_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
        csv_reader = csv.DictReader(csv_file)            
        for row in csv_reader:
            if pf.is_clean(row['sentence']):
                continue
            else:
                csv_writer.writerow(['***', '****', '****' , '*****', '*****'])
        csv_file.close
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)
Beispiel #3
0
import sys
from datetime import datetime

import discord
from profanity_filter import ProfanityFilter
from discord.ext import commands

import libs.shared as shared
from config.config import *
from libs.pygtail import Pygtail
from libs.server import servers
from libs.leaderboard import leaderboards

# Profanity filter settings
pf = ProfanityFilter()
pf.censor_char = '&'

# Chat repeat variable
repeat = False

# Info chat vars
server_embeds = {}
start_info = False  # Without this the info function can post an update before all messages are sent

# Leaderboard vars
leaderboards_embeds = None
start_leaderboards = False


# TODO: Add anti-spam
async def chat(self, channel):