minerbot-phoenix/words.py

18 lines
376 B
Python

import random,re
WORDS = []
def _isASCII(s):
for c in s:
if ord(c) not in range(128):
return False
return True
def loadDict(name="words"):
global WORDS
with open("/usr/share/dict/"+name) as f:
WORDS = [l.strip() for l in f if l.strip() and _isASCII(l.strip())]
def getWords(pattern=".*"):
return list(filter(lambda x: (re.match(pattern,x) is not None),WORDS))