+
+def try_pick_word(words, blacklist, verbose):
+ word1 = words[random.randint(0,len(words)-1)]
+ word2 = words[random.randint(0,len(words)-1)]
+ word = word1+word2
+ if verbose:
+ print "word is %s" % word
+ r = re.compile('[^a-z]');
+ if r.search(word):
+ print "skipping word pair '%s' because it contains non-alphabetic characters" % word
+ return None
+
+ for naughty in blacklist:
+ if naughty in word:
+ if verbose:
+ print "skipping word pair '%s' because it contains blacklisted word '%s'" % (word, naughty)
+ return None
+ return word
+
+def pick_word(words, blacklist, verbose):
+ while True:
+ word = try_pick_word(words, blacklist, verbose)
+ if word:
+ return word
+
+def read_wordlist(filename):
+ return [string.lower(x.strip()) for x in open(wordlist).readlines()]
+