Skip to content

Commit

Permalink
Merge branch 'master' of github.com:78/ssbc
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoxia committed Jun 4, 2015
2 parents e350741 + 69df028 commit cb1da58
Show file tree
Hide file tree
Showing 10 changed files with 506 additions and 24 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
Expand Down
Empty file added lib/__init__.py
Empty file.
24 changes: 24 additions & 0 deletions lib/politics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#coding: utf8
import re
import os

re_blacklist = []

def load_words():
txt_path = os.path.join(os.path.dirname(__file__), 'politics.txt')
for line in open(txt_path, 'r'):
r = re.compile(line.rstrip('\r\n').decode('utf8'))
re_blacklist.append(r)
print 'Loaded words', len(re_blacklist)

def is_sensitive(kw):
for r in re_blacklist:
if r.search(kw):
print kw.encode('utf8'), 'is sensitive'
return True
return False

load_words()
is_sensitive(u'习主席')
is_sensitive(u'Test')

Loading

0 comments on commit cb1da58

Please sign in to comment.