Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

20 lines (15 sloc) 0.57 kb
"""
(Incomplete) bad words list, not to filter every conceivable swear word but
to encourage constructive feedback.
"""
import os
import re
root = os.path.dirname(os.path.realpath(__file__))
WORDLIST = set(
open(os.path.join(root, 'badwords.txt'), 'r').read().splitlines())
BADWORD_RE = re.compile(r'(?:[^\w]|^)(%s)(?:[^\w]|$)' % (
'|'.join([ r for r in [ '\w*'.join(map(re.escape, w.split('*'))) for
w in WORDLIST ] ])))
def find_swearwords(str):
"""Find swearwords in a string."""
return BADWORD_RE.findall(str.lower())
Jump to Line
Something went wrong with that request. Please try again.