add fancy data crunching function and help menu

This commit is contained in:
randomuser 2022-02-08 19:58:27 +00:00
parent 2d58cb1cac
commit e23268edfa
3 changed files with 41 additions and 15 deletions

Binary file not shown.

27
prob.py
View File

@ -1,8 +1,3 @@
import pickle
fd = open("wordlist", "r")
words = [i.rstrip() for i in fd.readlines()]
print(words)
def generateOutput(inputword, correct): def generateOutput(inputword, correct):
res = [0, 0, 0, 0, 0] res = [0, 0, 0, 0, 0]
for i in range(len(inputword)): for i in range(len(inputword)):
@ -22,15 +17,29 @@ def probs(dataset):
res[i] = 1 res[i] = 1
return res return res
def dist(dataset):
buf = []
for i in dataset:
tot = 0
nums = 0
for j in dataset[i]:
tot += dataset[i][j]
nums += 1
buf.append([i, tot / nums])
buf.sort(key = lambda x: x[1])
return buf
def runtime(dataset):
return len(dataset) * len(dataset)
def main(words):
data = {} data = {}
for i in words: for i in words:
data[i] = None
cache = [] cache = []
for j in words: for j in words:
cache.append(generateOutput(i, j)) cache.append(generateOutput(i, j))
print("cached {} {}".format(i, j))
data[i] = probs(cache) data[i] = probs(cache)
fdtwo = open("dataoutput", "wb") return dist(data)
pickle.dump(data, fdtwo)

View File

@ -1,5 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
import prob
words = [i.rstrip() for i in open("wordlist", "r").readlines()] words = [i.rstrip() for i in open("wordlist", "r").readlines()]
nocontain = [] nocontain = []
@ -58,6 +60,21 @@ while True:
words = buf words = buf
elif line.split(' ')[0] == "listbuffers": elif line.split(' ')[0] == "listbuffers":
print(nocontain, contains, defcontains) print(nocontain, contains, defcontains)
elif line.split(' ')[0] == "probmodel":
tmp = prob.main(words)
tmp.reverse()
print(tmp)
elif line.split(' ')[0] == "probruntime":
print(prob.runtime(words))
elif line.split(' ')[0] == "words": elif line.split(' ')[0] == "words":
print(words) print(words)
elif line.split(' ')[0] == "help":
print("welcome to wordlefish, a 'engine' for wordle")
print("add - add pattern")
print("reduce - apply pattern filter")
print("listbuffers - list filters in buffers")
print("probmodel - output ordered arr based on expensive dist model")
print("probruntime - return iterations of probmodel")
print("words - list words in consideration")
print("help - this")