def remove_profanity(name: str) -> str:
    profanity.add_censor_words(['supremacia ariana'])
    name = profanity.censor(name, ' ').strip()
    name = re.sub(
        ' +', ' ',
        name)  # We just replaced profanity with a space so compress spaces.
    return name
Ejemplo n.º 2
0
async def filter_message(message):
    mydb = databaseConnection()
    mycursor = mydb.cursor()
    profanity.add_censor_words(censored_words)

    containsProfanity = False
    if profanity.contains_profanity(message.content.lower()):
        containsProfanity = True

    if containsProfanity:
        mycursor.execute("SELECT * FROM strikes WHERE user='******'".format(
            message.author.name))
        result = mycursor.fetchall()
        count = 1

        if result:
            print('User: {} is in strikes table'.format(message.author.name))
            for row in result:
                count = row[1] + 1
                sql = "UPDATE strikes SET count = {} WHERE user = '******'".format(
                    count, row[0])
                mycursor.execute(sql)
        else:
            print("User:  {} not in strikes table".format(message.author.name))
            sql = "INSERT INTO strikes (user, count) VALUES (%s, %s)"
            val = (message.author.name, count)
            mycursor.execute(sql, val)

        mydb.commit()
        mydb.close()

        await message.delete()
        await message.channel.send(
            "{}, your message has been deleted as it contains inappropriate text. And you have received a strike. Total Strikes: {}"
            .format(message.author.mention, count))
Ejemplo n.º 3
0
    def song_name(self):
        profanity.load_censor_words()

        profanity.add_censor_words(self.custom_profanity)
        title = str(Song.find_song(self.songName).title)
        title = profanity.censor(str(title))

        return " ".join(self.process_word(word) for word in title.split())
Ejemplo n.º 4
0
def remove_profanity(name: str) -> str:
    profanity.load_censor_words(whitelist_words=PROFANITY_WHITELIST)
    profanity.add_censor_words(
        ['supremacia ariana', 'fisting', 'retarded', 'erection'])
    name = profanity.censor(name, ' ').strip()
    name = re.sub(
        ' +', ' ',
        name)  # We just replaced profanity with a space so compress spaces.
    return name
Ejemplo n.º 5
0
def censorText():
    text = request.json.get('text', '')
    whitelist = request.json.get('white_list', [])
    censorlist = request.json.get('censor_list', [])
    profanity.load_censor_words(whitelist_words=whitelist)
    profanity.add_censor_words(censorlist)
    words = text.split(' ')
    censored_text = ''
    for word in words:
        censored_text += (
            " " + (profanity.censor(word, censor_char=random.choice(emojis))))
    return {"censored_text": censored_text}
Ejemplo n.º 6
0
    def process_lyrics(self):
        # making the assumption that the lyric input is one long string
        # and that nothing in the lyrics contains an asterisk
        # (actually because many censors use asterisks that might still work
        # if the music was already censored to an extent)
        profanity.load_censor_words()

        profanity.add_censor_words(self.custom_profanity)
        lyrics = Song.find_song(self.songName).lyrics
        print(lyrics)
        lyrics = profanity.censor(str(lyrics))

        return " ".join(self.process_word(word) for word in lyrics.split())
def validate_profane_content(content):
    """ Validates text for any profanity

    :param content: text content to be validated
    :type content: str
    :raises: ValidationError upon detecting profane word(s) in content
    :return: None
    :rtype: None
    """
    with open('utils/more_profanity.txt', 'r') as f:
        additional_words = [line.strip() for line in f]

    profanity.add_censor_words(additional_words)
    if profanity.contains_profanity(content):
        raise ValidationError("Content contains profane language")
Ejemplo n.º 8
0
 async def update_profanity(self, mode, *words):
     async with aiofiles.open(self.profanity_file, "r", encoding="utf-8") as afp:
         stored = [w.strip() for w in await afp.readlines()]
     if mode == 'add':
         new_list = [w for w in words if w not in stored]
         if len(new_list):
             async with aiofiles.open(self.profanity_file, "a+", encoding="utf-8") as afp:
                 await afp.write("".join([f"{w}\n" for w in new_list]))
             profanity.add_censor_words(new_list)
         return len(new_list)
     elif mode == "remove":
         new_list = [w for w in stored if w not in words]
         async with aiofiles.open(self.profanity_file, "w", encoding="utf-8") as afp:
             await afp.write("".join([f"{w}\n" for w in new_list]))
         await self.load_profanity(new_list)
         return len(new_list)
Ejemplo n.º 9
0
def __init_sanitize():
    global _CURRENT_DIR
    log.debug('[VERBOSE] Initializing additional Spanish Profanities')
    censored_spanish_words = open(_PROFANITY_FILE_PATH, 'r')

    lines = censored_spanish_words.readlines()
    censored_spanish_words.close()
    lines = list(map(lambda x: x.strip().lower(), lines))

    combinations = set()
    for word in lines:
        num_of_non_allowed_chars = profanity._count_non_allowed_characters(
            word)
        if num_of_non_allowed_chars > profanity.MAX_NUMBER_COMBINATIONS:
            profanity.MAX_NUMBER_COMBINATIONS = num_of_non_allowed_chars

        combinations.update(set(profanity._generate_patterns_from_word(word)))

    profanity.add_censor_words(combinations)
    log.debug('[VERBOSE] Finished adding additional Spanish Profanities')
Ejemplo n.º 10
0
def new():
    form = LinkForm()
    if form.validate_on_submit():
        link = Link(link=form.link.data,
                    title=form.title.data,
                    name=form.name.data,
                    desc=form.desc.data,
                    image=form.image.data,
                    url='https://www.youtube.com/watch?v=dQw4w9WgXcQ')
        with open('bad-words.txt', 'r') as f:
            wordlist = [i.strip() for i in f.readlines()]
        profanity.load_censor_words()
        profanity.add_censor_words(wordlist)
        if profanity.contains_profanity(
                f'{link.link} {link.title} {link.name} {link.desc}'):
            flash(
                'NOTE: EXCESSIVE PROFANITY IS NOT PERMITTED ON THIS PLATFORM. CONTINUED EXCESSIVE PROFANITY MAY RESULT IN AN IP BAN FROM THIS PLATFORM',
                'danger')
        link.link = profanity.censor(link.link, 'X')
        link.title = profanity.censor(link.title, 'X')
        link.name = profanity.censor(link.name, 'X')
        link.desc = profanity.censor(link.desc, 'X')
        link.link = link.link.replace(' ', '-')
        link.link = re.sub(r'[^a-zA-Z0-9-]', '-', link.link)

        # ensure uniqueness of link
        existinglink = Link.query.filter_by(link=link.link).first()
        while existinglink:
            link.link = link.link + 'X'
            existinglink = Link.query.filter_by(link=link.link).first()
        db.session.add(link)
        db.session.commit()
        # getting config details
        with open('config.json') as f:
            data = json.load(f)
        flash(f"Created link {data['domain']}/l/{link.link}", 'success')
        return redirect(url_for('home'))
    return render_template('new.html', form=form, legend='New Link')
Ejemplo n.º 11
0
async def add_profanity_to_list(message: discord.Message):
    sections = message.content.split(':')
    if sections[0] == "!admin_add_profanity":
        if len(sections) == 1:
            await message.author.send(
                "No me dijiste que palabra añado a la lista de profanidades")
            return

        if is_sender_counselor(message):
            author = None
            if hasattr(message.author, 'nick'):
                author = message.author.nick
            else:
                author = message.author.name
            log.debug('[DEBUG] Can add a profanity. Is ADMIN')

            censored_words_file = open(_PROFANITY_FILE_PATH, 'r')
            lines = censored_words_file.readlines()
            censored_words_file.close()
            censored_words = set(list(map(lambda x: x.strip().lower(), lines)))
            censored_words_file.close()

            profanity_to_add = sections[1].lower()

            if profanity_to_add not in censored_words:
                profanity_file = open(_PROFANITY_FILE_PATH, 'a+')
                profanity_file.write(f'{profanity_to_add}\n')
                profanity_file.close()

                combinations = set()
                combinations.update(
                    profanity._generate_patterns_from_word(profanity_to_add))
                profanity.add_censor_words(combinations)

            await message.delete(delay=0)
            await message.channel.send(f"""{author}, commando fue completado"""
                                       )
            return True
Ejemplo n.º 12
0
async def main():
    profanity.add_censor_words(['ngbl', 'nagoobalha', 'balha'])

    await roanuedhuru.start()
    await roanuedhuru.idle()
import sys
sys.path.append("../src")
import re
import pandas as pd
from data_utils import find_substr
from better_profanity import profanity

profanity.load_censor_words(whitelist_words=['asses'])
profanity.add_censor_words(['gay'])


def symb_decode(s):
    replacements = (
        (''', "'"),
        ("'", "`"),
        ('"', "'"),
        ('>', '>'),
        ('&lt;', '<'),
        ('&amp;', '&'),
    )
    for replace in replacements:
        s = s.replace(replace[0], replace[1])
    return s


def filter_name(text):
    return re.sub('@[a-zA-Z0-9]+', '', text)


def filter_name_correct(text):
    return re.sub('@[(a-zA-Z0-9)|_]+', '', text)
Ejemplo n.º 14
0
 def test_custom_words(self):
     bad_text = "supremacia ariana"
     censored_text = "****"
     profanity.add_censor_words([bad_text])
     self.assertEqual(profanity.censor(bad_text), censored_text)
Ejemplo n.º 15
0
 def test_custom_words_doesnt_remove_initial_words(self):
     bad_text = "f**k and heck"
     censored_text = "**** and heck"
     profanity.add_censor_words(["supremacia ariana"])
     self.assertEqual(profanity.censor(bad_text), censored_text)
Ejemplo n.º 16
0
class recordThread(QThread):
    def __init__(self):
        super().__init__()

    def run(self):
        self.rec = Recorder()
        self.rec.start()


class processThread(QThread):
    procDone = pyqtSignal(int)

    def __init__(self):
        super().__init__()

    def run(self):
        global s2t
        global transcripts
        global fs
        global data
        fs, data = wavfile.read("output.wav")
        transcripts, s2t = speech2text()
        self.procDone.emit(int)


if __name__ == "__main__":
    profanity.add_censor_words(["hackathon"])
    app = QApplication(sys.argv)
    myWin = Window()
    sys.exit(app.exec_())
Ejemplo n.º 17
0
from better_profanity import profanity

profanity.load_censor_words()

censored_text = profanity.censor("f**k you")
print(censored_text)

text = "bahen chod sala"
censored_text = profanity.censor(text)
print(censored_text)

custom_badwords = ['bahen chod']
profanity.add_censor_words(custom_badwords)

text = "bahen chod sala"
censored_text = profanity.censor(text)
print(censored_text)