Changed database to a more reliable one, added functionality for no three word puzzles.
This commit is contained in:
parent
85d28346bb
commit
ca17762c1a
5 changed files with 69927 additions and 370109 deletions
|
@ -1,6 +1,6 @@
|
||||||
# Find words based on letters given
|
# Find words based on letters given
|
||||||
|
|
||||||
from read_english_dictionary import load_words
|
from import_dictionary import load_words
|
||||||
from sys import argv
|
from sys import argv
|
||||||
|
|
||||||
def create_bank(letters):
|
def create_bank(letters):
|
||||||
|
@ -13,11 +13,15 @@ def create_bank(letters):
|
||||||
|
|
||||||
return lb
|
return lb
|
||||||
|
|
||||||
def main(letters):
|
def main(letters, no_three=False):
|
||||||
wdb = load_words()
|
wdb = load_words()
|
||||||
|
|
||||||
|
mininum = 3
|
||||||
|
if(no_three):
|
||||||
|
mininum += 1
|
||||||
|
|
||||||
for w in wdb:
|
for w in wdb:
|
||||||
if(len(letters) >= len(w) and len(w) >= 3):
|
if(len(letters) >= len(w) and len(w) >= mininum):
|
||||||
lb = create_bank(letters)
|
lb = create_bank(letters)
|
||||||
contains_letters = True
|
contains_letters = True
|
||||||
for l in w:
|
for l in w:
|
||||||
|
@ -40,4 +44,15 @@ def main(letters):
|
||||||
print(w)
|
print(w)
|
||||||
|
|
||||||
if(__name__ == '__main__'):
|
if(__name__ == '__main__'):
|
||||||
main('catlle')
|
if(len(argv) > 1):
|
||||||
|
if(len(argv) > 2):
|
||||||
|
if(argv[2] == '--no-three' or argv[2] == '-n'):
|
||||||
|
main(argv[1], True)
|
||||||
|
elif(argv[1] == '--no-three' or argv[1] == '-n'):
|
||||||
|
main(argv[2], True)
|
||||||
|
else:
|
||||||
|
print('Usage: python find_words.py [letters] [-n | --no-three]')
|
||||||
|
else:
|
||||||
|
main(argv[1])
|
||||||
|
else:
|
||||||
|
print('Usage: python find_words.py [letters] [-n | --no-three]')
|
|
@ -1,5 +1,5 @@
|
||||||
def load_words():
|
def load_words():
|
||||||
with open('words_alpha.txt') as word_file:
|
with open('wordlist.txt') as word_file:
|
||||||
valid_words = set(word_file.read().split())
|
valid_words = set(word_file.read().split())
|
||||||
|
|
||||||
return valid_words
|
return valid_words
|
|
@ -1,2 +1,3 @@
|
||||||
### I forgot how to do headings in markdown and I'm too lazy to look it up
|
### I forgot how to do headings in markdown and I'm too lazy to look it up
|
||||||
Word database and python script from: https://github.com/dwyl/english-words
|
Word database python script from: https://github.com/dwyl/english-words
|
||||||
|
Words list: http://www-personal.umich.edu/~jlawler/wordlist.html
|
||||||
|
|
69905
wordlist.txt
Normal file
69905
wordlist.txt
Normal file
File diff suppressed because it is too large
Load diff
370103
words_alpha.txt
370103
words_alpha.txt
File diff suppressed because it is too large
Load diff
Reference in a new issue