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

  1. import re
  2. import itertools
  3. from spellchecker import SpellChecker
  4. SPELL= SpellChecker()
  5. def canidates(letters, min=2, max=5):
  6. pos = []
  7. for length in range(min, max+1):
  8. for comb in itertools.combinations(letters, length):
  9. for perm in itertools.permutations(comb):
  10. word = ''.join(perm)
  11. pos.append(word)
  12. return SPELL.known(pos)
  13. def filter_pos(pos, regex):
  14. pat = re.compile(regex)
  15. return list(filter(pat.match,pos))