xwords/xwords4/dawg/remove-dirty.py
Eric House 8752432de3 add ability to filter out "dirty" words
If a Makefile defines a dirty word list then a new python script is
invoked to filter for and remove those words as the dict is being
built. So far I have for English only, which makes sense because only
English wordlists are built-in on Android and Google's rating system
cares only about what's built in.
2017-05-04 22:45:27 -07:00

18 lines
479 B
Python
Executable file

#!/usr/bin/python
# Invoked with path to bad words list as single parameter, and with a
# stream of words via stdin, loads the bad words into a map and for
# every word in stdin echos it to stdout IFF it's not in the map.
import sys
dirtyMap = {}
dirtyList = sys.argv[1]
for f in open(dirtyList):
dirtyMap[f] = True
for word in sys.stdin:
if word in dirtyMap:
sys.stderr.write( sys.argv[0] + ": dropping: " + word )
else:
sys.stdout.write( word )