Add Word Generator

This commit is contained in:
TGLIDE 2018-10-03 12:21:46 -03:00
parent 2c1cfb62f5
commit 2a1b863920
4 changed files with 45389 additions and 0 deletions

10
Word-generator/README.md Normal file
View File

@ -0,0 +1,10 @@
# Word Generator
## Description
A python script that generates english words that contain 2 or more letters from input
## Usage
Just run gen.py and type in some letters
## Requirements
Python 3

45333
Word-generator/dictionary.txt Normal file

File diff suppressed because it is too large Load Diff

33
Word-generator/gen.py Normal file
View File

@ -0,0 +1,33 @@
def getDict(file):
words = set()
with open(file) as d:
for w in d.read().split("\n"):
words.add(w.lower())
return words
def isEng(word):
englishWords = getDict("dictionary.txt")
if word in englishWords:
return True
return False
def permutations(xl, length = -1, res=[], output=[]):
if xl == [] or len(res) == length:
output.append(res)
return
for i in range(len(xl)):
permutations(xl[:i] + xl[i + 1:], length, res + [xl[i]], output)
return output
while True:
found = set()
letters = [i for i in input("Choose letters: ")]
for sz in range(2, len(letters)+1):
print("\nSize:", sz, "letters")
for comb in permutations(letters, sz ,[], []):
if isEng("".join(comb)) and not "".join(comb) in found:
print("Found word:", "".join(comb))
found.add("".join(comb))
print()

13
Word-generator/isEng.py Normal file
View File

@ -0,0 +1,13 @@
def getDict(file):
words = set()
with open(file) as d:
for w in d.read().split("\n"):
words.add(w.lower())
return words
def isEng(word):
englishWords = getDict("dictionary.txt")
if word in englishWords:
return True
return False
print(isEng("boot"))