You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
484 B
16 lines
484 B
import re
|
|
import itertools
|
|
from spellchecker import SpellChecker
|
|
SPELL= SpellChecker()
|
|
def canidates(letters, min=2, max=5):
|
|
pos = []
|
|
for length in range(min, max+1):
|
|
for comb in itertools.combinations(letters, length):
|
|
for perm in itertools.permutations(comb):
|
|
word = ''.join(perm)
|
|
pos.append(word)
|
|
return SPELL.known(pos)
|
|
|
|
def filter_pos(pos, regex):
|
|
pat = re.compile(regex)
|
|
return list(filter(pat.match,pos))
|