Skip to content

Commit

Permalink
Adding files
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenewald committed Jan 1, 2022
1 parent 13bc75c commit e5fd42e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 50 deletions.
51 changes: 1 addition & 50 deletions src/py-radix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,53 +106,4 @@ def finalWords(showImages, wordlist): #alphabet array
if(len(otl)>15): # reduce length of list
otl = otl[len(otl)-15:len(otl)]

return otl


topnode = tu.words_to_tree("C:/Users/steve/Desktop/wordgame_nongit/Dictionaries/english_small.txt")
wordlist = "abcdefghijklmnop"
triesize = str(tu.count_nodes(topnode))
startTime = time.time()
pw1 = finalWords(False, wordlist)
endTime = time.time()
topnode = ru.optimize_tree(topnode)
st2 = time.time()
pw2 = finalWords(True, wordlist)
et2 = time.time()
nodes2 = tu.count_nodes(topnode)
ext1 = ((endTime-startTime)*1000)
ext2 = ((et2-st2)*1000)
sizechange = abs(10000*(nodes2-int(triesize))/int(triesize))
timechange = (10000*(ext2-ext1)/ext1)
print("Trie vertices: " + triesize)
print("Trie execution time: " + str(round(ext1)/1000) + " seconds")
print("=========================")
print("Radix tree vertices: " + str(nodes2))
print("Radix tree execution time: " + str(round(ext2)/1000) + " seconds")
print("=========================")
print("Changes from implementing radix tree")
print("Reduction in size: -" + str(round(sizechange)/100) + "%")
if(timechange>0):
print("Increase in execution time: +" + str(round(abs(timechange))/100) + "%")
else:
print("Decrease in execution time: -" + str(round(abs(timechange))/100) + "%")
print("=========================")
print(pw1)
if(False): #only if testing words
numvw = 0
for word in dict:
word2 = word + "e"
check1 = word2 in dict
check2 = check_if_word(word2, True)
if(check1 and (not check2)):
print(word)
elif((not check1) and check2):
print(word)
numvw+=1
if(numvw%1000==0):
print(numvw)
print("Word check done")
if(not(pw1==pw2)):
print("ERROR: TRIE AND RADIX TREE UNEQUAL")
print(len(pw1))
print(len(pw2))
return otl
47 changes: 47 additions & 0 deletions tests/test_word_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
topnode = tu.words_to_tree("C:/Users/steve/Desktop/wordgame_nongit/Dictionaries/english_small.txt")
wordlist = "abcdefghijklmnop"
triesize = str(tu.count_nodes(topnode))
startTime = time.time()
pw1 = finalWords(False, wordlist)
endTime = time.time()
topnode = ru.optimize_tree(topnode)
st2 = time.time()
pw2 = finalWords(True, wordlist)
et2 = time.time()
nodes2 = tu.count_nodes(topnode)
ext1 = ((endTime-startTime)*1000)
ext2 = ((et2-st2)*1000)
sizechange = abs(10000*(nodes2-int(triesize))/int(triesize))
timechange = (10000*(ext2-ext1)/ext1)
print("Trie vertices: " + triesize)
print("Trie execution time: " + str(round(ext1)/1000) + " seconds")
print("=========================")
print("Radix tree vertices: " + str(nodes2))
print("Radix tree execution time: " + str(round(ext2)/1000) + " seconds")
print("=========================")
print("Changes from implementing radix tree")
print("Reduction in size: -" + str(round(sizechange)/100) + "%")
if(timechange>0):
print("Increase in execution time: +" + str(round(abs(timechange))/100) + "%")
else:
print("Decrease in execution time: -" + str(round(abs(timechange))/100) + "%")
print("=========================")
print(pw1)
if(False): #only if testing words
numvw = 0
for word in dict:
word2 = word + "e"
check1 = word2 in dict
check2 = check_if_word(word2, True)
if(check1 and (not check2)):
print(word)
elif((not check1) and check2):
print(word)
numvw+=1
if(numvw%1000==0):
print(numvw)
print("Word check done")
if(not(pw1==pw2)):
print("ERROR: TRIE AND RADIX TREE UNEQUAL")
print(len(pw1))
print(len(pw2))

0 comments on commit e5fd42e

Please sign in to comment.