Beispiel #1
0
def profanity_check(cleaned_comment):
    custom_profanity_list = config.get('ckan.comments.profanity_list', [])

    if custom_profanity_list:
        pf = ProfanityFilter(
            custom_censor_list=custom_profanity_list.splitlines())
    else:
        # Fall back to original behaviour of built-in Profanity bad words list
        # combined with bad_words_file and good_words_file
        more_words = load_bad_words()
        whitelist_words = load_good_words()

        pf = ProfanityFilter(extra_censor_list=more_words)
        for word in whitelist_words:
            pf.remove_word(word)

    return pf.is_profane(cleaned_comment)
Beispiel #2
0
import yorm
from yorm.types import List, Object
from profanityfilter import ProfanityFilter
import log

profanity_filter = ProfanityFilter()
profanity_filter.remove_word("damn")


@yorm.attr(items=List.of_type(Object))
@yorm.sync("data/cache/{self.name}.yml", auto_resolve=True)
class Cache:

    SIZE = 100

    def __init__(self, filtered=True):
        self.items = []
        self.disabled = False
        self.filtered = filtered

    @property
    def name(self):
        return 'filtered' if self.filtered else 'unfiltered'

    def add(self, **kwargs):
        if self._skip_cache(kwargs):
            return

        log.info("Caching: %s", kwargs)

        self.items.insert(0, kwargs)
Beispiel #3
0
import yorm
from yorm.types import List, Object
from profanityfilter import ProfanityFilter
import log

profanity_filter = ProfanityFilter()
profanity_filter.remove_word("damn")


@yorm.attr(items=List.of_type(Object))
@yorm.sync("data/cache/{self.name}.yml", auto_resolve=True)
class Cache:

    SIZE = 100

    def __init__(self, filtered=True):
        self.items = []
        self.disabled = False
        self.filtered = filtered

    @property
    def name(self):
        return 'filtered' if self.filtered else 'unfiltered'

    def add(self, **kwargs):
        if self._skip_cache(kwargs):
            return

        log.info("Caching: %s", kwargs)

        self.items.insert(0, kwargs)