wordlefish/prob.py

37 lines
755 B
Python

import pickle
fd = open("wordlist", "r")
words = [i.rstrip() for i in fd.readlines()]
print(words)
def generateOutput(inputword, correct):
res = [0, 0, 0, 0, 0]
for i in range(len(inputword)):
if inputword[i] == correct[i]:
res[i] = 2
elif inputword[i] in correct:
res[i] = 1
return tuple(res)
def probs(dataset):
res = {}
for i in dataset:
if i in res:
res[i] += 1
else:
res[i] = 1
return res
data = {}
for i in words:
data[i] = None
cache = []
for j in words:
cache.append(generateOutput(i, j))
print("cached {} {}".format(i, j))
data[i] = probs(cache)
fdtwo = open("dataoutput", "wb")
pickle.dump(data, fdtwo)