From 9bd595ab66786eaabfb078dfcda4164c586b245e Mon Sep 17 00:00:00 2001 From: stevenewald <sewald@commschool.org> Date: Sat, 1 Jan 2022 21:21:05 -0500 Subject: [PATCH] Ready for building --- pyproject.toml | 5 +- setup.cfg | 0 setup.py | 33 ++++++ .../__pycache__/image_utils.cpython-310.pyc | Bin 1910 -> 0 bytes .../__pycache__/radix_utils.cpython-310.pyc | Bin 774 -> 0 bytes .../__pycache__/tree_utils.cpython-310.pyc | Bin 1667 -> 0 bytes .../wordcheck_utils.cpython-310.pyc | Bin 944 -> 0 bytes src/{py-radix => pyradix}/__init__.py | 48 ++++---- .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 3101 bytes .../__pycache__/image_utils.cpython-310.pyc | Bin 0 -> 1909 bytes .../__pycache__/radix_utils.cpython-310.pyc | Bin 0 -> 797 bytes .../__pycache__/tree_utils.cpython-310.pyc | Bin 0 -> 1984 bytes .../wordcheck_utils.cpython-310.pyc | Bin 0 -> 1011 bytes src/{py-radix => pyradix}/image_utils.py | 1 - .../old/wordgame - Copy.py | 0 src/{py-radix => pyradix}/old/wordgame.py | 0 .../old/wordgame_anagram.py | 0 .../old/wordgame_trie.py | 0 src/{py-radix => pyradix}/radix_utils.py | 2 +- src/{py-radix => pyradix}/tree_utils.py | 13 ++- src/{py-radix => pyradix}/wordcheck_utils.py | 6 +- .../wordgame_radix_footage.py | 0 src/pyradix_stevenewald.egg-info/PKG-INFO | 18 +++ src/pyradix_stevenewald.egg-info/SOURCES.txt | 12 ++ .../dependency_links.txt | 1 + .../top_level.txt | 1 + .../__pycache__/test_use_case.cpython-310.pyc | Bin 0 -> 1321 bytes .../test_word_check.cpython-310.pyc | Bin 0 -> 2624 bytes tests/test_use_case.py | 29 +++++ tests/test_word_check.py | 106 ++++++++++-------- 30 files changed, 196 insertions(+), 79 deletions(-) delete mode 100644 setup.cfg create mode 100644 setup.py delete mode 100644 src/py-radix/__pycache__/image_utils.cpython-310.pyc delete mode 100644 src/py-radix/__pycache__/radix_utils.cpython-310.pyc delete mode 100644 src/py-radix/__pycache__/tree_utils.cpython-310.pyc delete mode 100644 src/py-radix/__pycache__/wordcheck_utils.cpython-310.pyc rename src/{py-radix => pyradix}/__init__.py (68%) create mode 100644 src/pyradix/__pycache__/__init__.cpython-310.pyc create mode 100644 src/pyradix/__pycache__/image_utils.cpython-310.pyc create mode 100644 src/pyradix/__pycache__/radix_utils.cpython-310.pyc create mode 100644 src/pyradix/__pycache__/tree_utils.cpython-310.pyc create mode 100644 src/pyradix/__pycache__/wordcheck_utils.cpython-310.pyc rename src/{py-radix => pyradix}/image_utils.py (99%) rename src/{py-radix => pyradix}/old/wordgame - Copy.py (100%) rename src/{py-radix => pyradix}/old/wordgame.py (100%) rename src/{py-radix => pyradix}/old/wordgame_anagram.py (100%) rename src/{py-radix => pyradix}/old/wordgame_trie.py (100%) rename src/{py-radix => pyradix}/radix_utils.py (95%) rename src/{py-radix => pyradix}/tree_utils.py (83%) rename src/{py-radix => pyradix}/wordcheck_utils.py (91%) rename src/{py-radix => pyradix}/wordgame_radix_footage.py (100%) create mode 100644 src/pyradix_stevenewald.egg-info/PKG-INFO create mode 100644 src/pyradix_stevenewald.egg-info/SOURCES.txt create mode 100644 src/pyradix_stevenewald.egg-info/dependency_links.txt create mode 100644 src/pyradix_stevenewald.egg-info/top_level.txt create mode 100644 tests/__pycache__/test_use_case.cpython-310.pyc create mode 100644 tests/__pycache__/test_word_check.cpython-310.pyc create mode 100644 tests/test_use_case.py diff --git a/pyproject.toml b/pyproject.toml index b5a3c46..586aeb8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,9 @@ [build-system] requires = [ "setuptools>=42", - "wheel" + "wheel", + "numpy", + "tqdm", + "opencv-python", ] build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index e69de29..0000000 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..2e715cf --- /dev/null +++ b/setup.py @@ -0,0 +1,33 @@ +import setuptools + +#with open("README.md", "r", encoding="utf-8") as fh: +# long_description = fh.read() + +from unittest import TestLoader +def my_test_suite(): + test_loader = TestLoader() + test_suite = test_loader.discover('tests', pattern='test_*.py') + return test_suite +if(__name__=='__main__'): + setuptools.setup( + name="pyradix-stevenewald", + version="0.0.1", + author="Steven Ewald", + author_email="steve@steve.ee", + description="Python implementation of Radix Tree: memory and speed optimized language detection", + long_description="", + long_description_content_type="text/markdown", + url="https://github.com/stevenewald/pyradix", + project_urls={ + "Bug Tracker": "https://github.com/stevenewald/pyradix/issues", + }, + classifiers=[ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + ], + package_dir={"": "src"}, + packages=setuptools.find_packages(where="src"), + python_requires=">=3.6", + test_suite='setup.my_test_suite', + ) \ No newline at end of file diff --git a/src/py-radix/__pycache__/image_utils.cpython-310.pyc b/src/py-radix/__pycache__/image_utils.cpython-310.pyc deleted file mode 100644 index a79aba4e46e28dfd4bb000b28a9b1be8ab017db5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1910 zcmZ8hOK%)S5bmDto|%0)PFRTJ2yj9WEK&ejNT4W+5P2v;!HIAX$!O7P*=}#v>?=LJ zPGa?(3^&9t;9wtp=ZA2fD<}U2F7Q>a?bx2teBE8uT~l3EUric~D#Nq<*WcZ}gt32U zaq@|<_!?jS1wb>+hb-e^jIu~aTKvi~p`}(BrH*xiQR!4yFvgm%vsU#0C)rw0&~W&i z$5_F48()5dGuCH?aBP=r?$~Cu7ZuX;U9ras<&};uu_DGOob+mkYq7+BBbo9n>`A=3 z!+u&VQm1xfpZHjdOH9iq)9NC_3VV-M8<9^>Y17kMy1||*DzKFJL`S}&g^nPRJ}u%G zS3K?vFZc;Bs!naDMa@@>x=xD*PF8%~*L*{#douXG;HqA3*66=}fh0>zr<d6dFU}om zAcF?_i$|J8*r|I7OXvI|ye4}USWGzcVz=St9>+{leAo8H!RN@6r3fDoSVWW^1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python-310.pyc b/src/py-radix/__pycache__/radix_utils.cpython-310.pyc deleted file mode 100644 index cc470f835a16defc68f66633ef3544726a8eac26..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 774 zcmYjP&2G~`5T5<9F;No%s#+@b)>97Y6{$j~q7@RCAklJ(jI1=fRCW{F-Ccu&HmAUQ zz>%lm6*%veQ{Dh^ff=`mjx^uw{CIZ!%~t(>4^Uox|1tf=0e+HmS1<<0sCFMgfnsx* zFvXSl1QV{LiqHzh&R`gCumZ+2M&?!oT8VmsYFh-wR?I^Ir||Z0#U1m!fHn5J;%0<r zZbwRB1uq0;l-z?t?1Janf1jg=dYgqW@+;-RMV_yji;H_1Tt}XnBaC40Gw^`ZMdKG6 zn(W*V4wI1B=Ax{Wwn5Bw8RFc2sEi8IEo&X*tg4rxU)3&O<R5kBjMjm>CP?~ZD6kA8 zlisvkzSgQ~wVFhfx%dWV3;X|mesYw)vD(<wI{jX!r`le*s!r*S%jrUAWmR70F12Qs z*2|HZs=Q4*%o>-^?P0w%2{s}E?GA!uJ+{px>VQ2$l`LVBcQrFA`X@0SNIS;Q@qmmA zPkbM&qyuD}t&v}}vOvCeLGj11=BtQ&j~ViP^qKDg?&QD=4h;G8Lh&cC64z1*WK)hi z8V$XU%^wt`L@e^s(6SBPKa35H6=cV1tV{J$wLz54!q9^Yk#3!tc4XZ^pP~=m<)z9{ zb(?i;JjAFSAkhErvmL}9{=3=6&`^dRt>K0-b00$;A6@cJXIhBq+9yvJm1^et8NC5Z KV<wRBt-)Wd`>f{x diff --git a/src/py-radix/__pycache__/tree_utils.cpython-310.pyc b/src/py-radix/__pycache__/tree_utils.cpython-310.pyc deleted file mode 100644 index 1118d1126d0000447904cae64606e9f9415fa32c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1667 zcmah~%Wm676rGnSMxpF9sgtHCjC2!(i+a&bi@+#SBuLSXHfa|PR1gYhY|y4jX=aqf z1+`N8ANH~z(0)hPv+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I&>(S-X-bTD2U(f0f()bX& zd+3h-7!(Lh`4*8#>ytd`eW>c9A|khz@{b2D!Hu^=7ZcL`{=4=~{8Z8HY_T*+Z=|=< HG)w*g#$ZA= diff --git a/src/py-radix/__pycache__/wordcheck_utils.cpython-310.pyc b/src/py-radix/__pycache__/wordcheck_utils.cpython-310.pyc deleted file mode 100644 index 09149e23b95657db84017b50220b0cda9534b737..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 944 zcmaJ=y>1gh5Z=E#UrZbfLL?M4Q3{L%5=b-%p-4e4-6S;DNhjmogo`hC*6v;$OPk7c zd5J`#;Ynzzx24J}P-SM%N*p9uYi4i1o!R;OTy;8a0?YjTHTo_H`HhFw#o(|DVs=1D zB56T}H0*51C6oLc844+61bZauKIz5RU`YmJj@xqKcLcHrVm3fo;;4hy99szRVS{T5 zXpj0w<F9Hw$@0T&R%w};`b&>{QC3oUfryXvNaklhh;D(ypZ?za^s`agq{gaKm3~rY zVykJ2rbnX_m6cU_l-tzkaXOv93clg82~*p=Ft4X`-?<kS(=}N62Gwh@jiEEQ3*#mr zp_V?RE$O)ci5%CvmRwRtkC`KmU2(vmCzD9Ovpk^DGjc2zQ1vDOge>Spz}>A+gURL= zUs>935qL|K&;Paz=wlmQ#!bw|AJIGPULLdm<S~Q%XO8_lhY356%ec9B3{MW~hUzXt zbOE)s;5*hAlJApc<ySU=UMy<~udmd#NgT)dOXNT_(8vLeeLv{;);!a-?;hr*%s|vx z7KY~&pajyvcwVT|3p<}G&us16ccwnh4KhIEAbTy1)YCXa-zt=~Ko=duX(-^WHy-s{ z&re51;8de<!oeL4%{C}O@z<q0^d)`Dp0F-`LAU8T+X6HJRInyo?Aul=l?86;hv4ZS mgw&S^{@((tg852FB$mdwKKXD`$+}P<u^|Sbgd`ATo!<aazS?~N diff --git a/src/py-radix/__init__.py b/src/pyradix/__init__.py similarity index 68% rename from src/py-radix/__init__.py rename to src/pyradix/__init__.py index 930634d..33f565a 100644 --- a/src/py-radix/__init__.py +++ b/src/pyradix/__init__.py @@ -1,12 +1,9 @@ -import image_utils as iu -import tree_utils as tu -import radix_utils as ru -import wordcheck_utils as wordcheck #not used currently but useful -import time +from pyradix.image_utils import * +from pyradix.tree_utils import * +from pyradix.radix_utils import * +from pyradix.wordcheck_utils import * #from english_words import english_words_lower_alpha_set #from threading import Thread -import numpy as np -import cv2 def initArray(wordlist): u = 0 @@ -40,36 +37,37 @@ def validWords(it, tn, accumlet, accum, i, z, moves, accumpos, arr): if(lett[0:1]==lettF): tempmoves = moves.copy() tempmoves.append(let) - pos = let + posns = [let] if(len(lett)>1): - pos = returnComb(lett, possibleLetters(let[0], let[1], tempmoves), 1, tempmoves, arr) - if(pos[0]>-1 and pos[1]>-1): - if(nodes.isword): - accum.append(accumlet+lett) - if(len(accumlet+lett)>2): - accumpos.append((tempmoves, accumlet+lett)) - validWords(it-1, nodes, accumlet+lett, accum, pos[0], pos[1], tempmoves, accumpos, arr) + posns = [] + returnComb(lett, possibleLetters(let[0], let[1], tempmoves), 1, tempmoves, arr, posns) + for pos in posns: + if(pos[0]>-1 and pos[1]>-1): + if(nodes.isword): + accum.append(accumlet+lett) + if(len(accumlet+lett)>2): + accumpos.append((tempmoves, accumlet+lett)) + validWords(it-1, nodes, accumlet+lett, accum, pos[0], pos[1], tempmoves, accumpos, arr) return (accum, accumpos) -def returnComb(word, PL, it, moves, arr): +def returnComb(word, PL, it, moves, arr, posns): if(it>(len(word))): - return (-1, -1) + return lett_to_find = word[it:it+1] for let in PL: newL = arr[let[0]][let[1]] if(newL==lett_to_find): moves.append(let) if(it==(len(word)-1)): - return let + posns.append(let) else: - return returnComb(word, possibleLetters(let[0], let[1], moves), it+1, moves, arr) - return (-1, -1) + returnComb(word, possibleLetters(let[0], let[1], moves), it+1, moves, arr, posns) def sortByLen(e): return len(e[1]) -def finalWords(showImages, wordlist): #alphabet array +def wordPathfinding(showImages, topnode, wordlist): #alphabet array arr = initArray(wordlist) if(showImages): - bg = iu.create_imgs(wordlist) + bg = create_imgs(wordlist) words = [] frames = [] wordl = [] @@ -80,7 +78,7 @@ def finalWords(showImages, wordlist): #alphabet array for uvi in uv: if(showImages): uvi[0].append((i2,z2)) - var = iu.create_arrows(bg, uvi[0], uvi[1]) + var = create_arrows(bg, uvi[0], uvi[1]) if(wordl.count(var[1])<1): frames.append((var[0], var[1])) wordl.append(var[1]) @@ -103,7 +101,7 @@ def finalWords(showImages, wordlist): #alphabet array k+=1 otl = np.unique(otl).tolist() otl.sort(key=len) - if(len(otl)>15): # reduce length of list - otl = otl[len(otl)-15:len(otl)] + #if(len(otl)>15): # reduce length of list + #otl = otl[len(otl)-15:len(otl)] return otl \ No newline at end of file diff --git a/src/pyradix/__pycache__/__init__.cpython-310.pyc b/src/pyradix/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b12f9b4ae58016867450e71cc391c4e1d63ef457 GIT binary patch literal 3101 zcmZuz&5t8T74NG4aNBNwjCZs<vl|k$Aiz<y5`(glq7Vo{2$abxQjm~Zjx3L>$J1-O z+paEq;;33$WVnDpoH%=Oh{PX}6Mq5Mx^kK$M>r6Eui8$s8@g3huU>t;SMTFjmA6_A z2cO6OG5UMkasEl2uYVk!pQ024RKgK#=KQ*9*}mob)<w&O`#UH0geQEoz6eAOZ6HEX zM_UsO(L@`HNVL$_MO$>xHbnPBr+;({2~M9G_Uf1sx&M5$0m{25#T6>SN+z5M6Z{yO z{Qq|1m0UreE&I9i(P`;^N%u-mJDO=G+<VUN`KhD1c2Rq8fh*iMoRTeHUY=+Ujl3t4 z6uI@NA_~g+a+FPyzHh?oT#8v*D8p999Z6|eYS<@#b7T`U|MT|v&B3ZjWHBgIvQ7pf zDW)o43~1G4G*5<Eo=s9UDCBss*vOGcKOPK+X_l(t@X=yp>O{UH<!BRPyP}KAW8Y;F z{u9<<{J)+nTVRe|RELjDMGmv3dJICtSW{=wLCdEeTDI@QcvCNON|%gr$u(ay7{<-- zYYzu^_XnrF?Q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$HIk-FNdXNpEEzutG z)kg_XY6>Q`ck4%G2!n@$--S+Po#?7}g8X_wyoU0Gi;D;AbzL_mKyx^yKHy~&SQ5eY zXTT3fUg?(bPo14lv-VjUz-5+;I>4!2AWCgl({1YAFcC~0IRe)B;9zaVuhwE7aqT>~ z{4o#;;ZiJta82Cu{_>dcNBBS%NA7g+G*op_`x7Bmuxs2nK#`^nfFL2l_Rl&Hz6c55 z5Uv4q?vzI=+O<SoACcr6j``6JT2P2C|Drfn``gM!56T{-_Ml&9&E)5*Q}tAL%jM^~ z13m4iUHKUhD1d(5<!9<>*VCOFw!3o!O?3wvHuoBK;QhvvTY42pijP}?%2an*b#XD{ zPLs_og{$!hUi!!Oy%0CYG8w64n9e7Kqz8j>(@fbcw$UHA_7iXk<=436$N4H##-l*8 zfn#bC4;qQL4P{L1j@M^Evw3lqU&poUQL5fcHl~plX;!FFHcpINC~0`MFu^KIm#f4C zDyN52|4!VXRlk~#Cb;`*cpedkNy3snu3b!wPYGC<;8Nn%RK&JBi#?ev3c%%A%s)9Z zY#sB}I(Ap<)VS-BjNM$#44dMGLaSn){^*5-G#%RZgOR$T#7(n_jr?;+4w0Nx=%?4# zF|JVR_dxa7U7#O-Mi(nxs@0s(&I^&!5z2j(25*D*JoyuB_@v*A@9dv=k5W48aHY~& z5%&&EC6fd1%Zc_yxSx3MFp+c~UnS#dHDDcTpA;6YDj!<#q6D|Xzjka3`1WNMzBSLq aYL>iB@M50~A&zZ-FRX_?%H1%E`2PUjG@VEQ literal 0 HcmV?d00001 diff --git a/src/pyradix/__pycache__/image_utils.cpython-310.pyc b/src/pyradix/__pycache__/image_utils.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6214eaa25e445b6dc6c4e8abd0c575e952d84e80 GIT binary patch literal 1909 zcmZ8hOOG5i5VqTPch76{U?499oA3~W5P}sFD2gHwBuY@&L~JCI)}Yle_D*J*nVz^k zn}^(|g&X1*AhCPQzv1jFr~LyQxWHGQ-6WfC^=G@PTw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ZCP*?Pa72ba3CP;2Sg5p>e(6JevDc*xWFwwk52Sp!E4*O{0ko8@T z{&@AU!^)!$`&_e%3dneWICV_wt>{fDGAoxgq}+F71<+Gdve-ghQDOBttNFw8=u?Ro z(I(>3X1SLvA9g(5$83F>XX-h&2RJHG>{+oGu>@4Mo{A-~ACfIqASgSSjZDlzFN?Vi zd{Jaui^&9u3w&H;&P?ZV{<IJnU(IvtMV>24WlS`YupPfHU*%1H3FNb%QUqC0v&9s& srn|7b07S&dg&0OOd+8^!tdUCjm1(IL6LXa)Q_=pMf$2$pHka-8|4avyKL7v# literal 0 HcmV?d00001 diff --git a/src/pyradix/__pycache__/radix_utils.cpython-310.pyc b/src/pyradix/__pycache__/radix_utils.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d9411bcf55945ca396ddfef3a14f7a741ea03978 GIT binary patch literal 797 zcmYk4&2G~`5P)ZYY)q6yP*p9JI3V?uLvux{P*ns%;?e`{DKfIs>{8i{?R0ky4%(ao z?*T{NhVx!I<rNST%(y}ANHe?h<DK<4TMq_3Kso*Ma|#0B7diKZqjQRCpP^Bp*c?hW z;S3a4;tNcKk}ASgDs~Q|c!O1NHe<AG1y2Qu`U=&yXcSv94+Xr2_v00J%<}@)Oz~@O zj&RTIkrG(J3qctr51<hH;CXiEbM#QRS@<TuQyyI8`I@=7c#y$O<e53f2%dco9`JV2 z*_#dB?81;8B_XlRWmPL}gP7|o#JT-c8x^EmE_9Hyda(?Hdg1ai|Ex1-v<}=gLDDB9 zfn^w(^rqGFomNe&)g+?K<qt4@JpcF0*>T!fZER|t{-{&zbM5LyN<FTorOv9ly2@Q@ z%`9Ck%~a)W+S#me`P_~%mf$(W&+eg-tjBhlL>;mnRLK%1c~>)|qW==(hO`5Ifg1!a zJmEfENe2j=tr0J-vOrw>ILarm=BtQ&j~ViP^pzg~j^xk_4h->mq4;xHi5sZ|!jxwn zMMDo{^A`n)h%&DX&Dv1^QEcd1L3U7MU8%RK4WepFLvJobx^-sSvAQ(_iaz>~S1Lo* zZPw9vj8Qv8L;w4f?V;`AznfhQjiRu#MK`8t+>#5uyS;gcWgVmLgL~a*My6|-yeMnc Q%=HO93rkn;L&E#Rf8tBECIA2c literal 0 HcmV?d00001 diff --git a/src/pyradix/__pycache__/tree_utils.cpython-310.pyc b/src/pyradix/__pycache__/tree_utils.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6c755e6380c67f831da4e5627570d3c7660b3283 GIT binary patch literal 1984 zcmah}O=}xR7@n_Pjb+I;Ax`2p1PVQ5FCmmdN(sf#lF}Y@aZf^JQFqp6ZFyIo86|dD zos|9$`<Oq_WB)_1bM480p%?dgN0lRoKxdhEzTbV`=ly8<{VqfMQ~xz)9mf8q#d?!i z?4!G%Aq+Eo!iMZeW`vRNn2`%H<VKm~9UBUhnhr*3wAsL@OxJ8;Oia)8F{WnAY-8*g ze!#MwYv^Nxg5-J=SnQ*_#}FlhcGAp^z)NYQQ5f+*Xh?&q8&ehv7gvquq~UvX_W+{h zEz4OeA$cnxg<%KmJs)H;D1R|6gLbpuNRJC?<=!;bWGX0EP7W<8vnh!L;ytq(!$14Q zx1*UWts6OCzAi_2dE%Sth@KvePs_Y+>Z8h!oGnJv3p+N|`N-R{%xAuuxM$Ogp!2+{ zE1&1Yt)m~LJmp>fwof>otxgM$lT{<5=z2743lq;SVcHd+^A>bkI?F^*MMFO@WjUo; zCM<l)LW)IInrOgMY+&1NLXb_4EbVf|-)=+%^mLFV1hgiL^3cum)5gpuH1Fm4*=#&n zo>+>WsAx?&>9p|=1e<!aQZvnaiKX=&+Xy=`9Bum=6VE(1{D>_itYbg0U$^I?6-Jy0 zyM3lT&1K7v<pMI7XPOwu)ZkTM*Th+-;y;3P-iGbMmSYdElyBe}Q$}Bs^G#Lw(1GV@ zHz;!7nhAtH^l8)OzRAgfJ#0A=J+AQyeh-Y<N7yLHq*bFi@fof85)+RgT)>_aWp_Nh zWe|qP0@(ix#u$)tU<tat2LW_)Qr7l9Z4fbVBgL|PNFtJZ%W%+RV{*btw<FCxexIuw z`#IJHQM+mcih?Zy`vVgI0~COha|vK<0dS!BX)6Ji+b>#iDLh~j<VTRdi#=pKx#fy; zygk4Q8sr|!6|LgC#J=>&^36likJIB6#xC!r@!qHOs+HdVdz~d~RQ>WQ>xAxMRU4#~ zDbMX^uq&kF>9nj(jDlqXf1pxD7Kfcl={=G-@;g+h0bhN@Y^0yO>quvhlh>bcCA&8Y zv&ZoL6G1ZGyF)a&>^7di!NTx4Xha<E&Q+_9K_x{qC>2C0DBo?RU>t=B6p9yYF3*&a zF{VF6#q|wZ#$#2=l8Ae0N(xhdGUq|ov(u%?cSFQdC4Gt>gO|WRK&Nz%CwEejVuWHQ z#t6MZi~#;ZP?@>pSBw(z65vsIkbIZ&3b0#(DhGkvz`ImE8?YY~^3H_BO(&HPNik_$ znW<s_utE`;G{x9g4KC3#bc&|-W$o=Q{`ip_f<7vJPRaTlhmOikH^SFs071NC0D-^F zJ~{>W2<>BHzX$LLW$+7Q5b$EbX?~W(3c82ONHlU>*ese^?PI-gnT*L7<m>U|lk{eI z@d7<!Qy^CJEy70onO@dLDhjbw#I#&yHn}Al5O1!Tt?3{ZApLS#b-$z9;C3K1+v2*b LwN`pZ>t5$yA4PTX literal 0 HcmV?d00001 diff --git a/src/pyradix/__pycache__/wordcheck_utils.cpython-310.pyc b/src/pyradix/__pycache__/wordcheck_utils.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2dca2c8aa89c4d505fd771043dad788955e0478c GIT binary patch literal 1011 zcmaJ<PiqrF6rX>)*`}$)Dz*w<iU%W7Q1DVj3Sy7Bq^A&A;?A^gv)K(ZvrPlrQ@r&{ zv`0UV*TI{oeg#jyH@h~epab*f&2Qe{dB0+7t4&}Xw7-vk2tt11WqmQY9KtrQK}aHL zMy7PgXsz?97zUs-$-k0eD1{8*Y)LvGz3>)1NI&6tGz;|r_D9&}8HkEXI$=7LY(OmB zDk6EsmIC}m-;v{63PwHZ9wuK@GKtfZcwT53oAPsyJCPSsIe~}^^jM}B--wRD;n%0+ zU{o5V&B$1Fu0~Rsi7jR$G(8<pRh$?3X=+DCC!^WIyZW~}OKH>0?9Uc%>t0qY-h?0` zD(C~M@#7Nsv%A#-4b%JXj-YZ$F9qzN;`-2%Yg*AWR*{O`aKHlSJkakf_h|5xoQWl^ z*bV`NEa^nR+nrC1$@&$eH1@j$Vu}3u-<BTTw!w8+=dAq^U19g?nE$7aIn+O|*uQI- zu*)zH>-UP`t%AOxyDOhvKyNM3LwzOrfHa-o*a-fj>BUE1>uZNp99bZd2|-^Y4Kxnm z_^7wxm@ZxSB+X?ETV2F{fGz@7AR~<9naZ88i<xrFmae@rbzy3d1RCeoYiS&(Mn<|; zrmO|VXq@6uK&&?o<y*(k$C;;9EjG{v-Eq`r4}<_d2->AD=qvh!J!W0{lJ3zC+XXZN zRIoZ-<hC2K?OUx>?0M$eD_wUXntSxe$hXy4ZLVGPCYX8p`M7JfVM!VbbkX~1A<ImC Pz@IaScSr}S=>)$43&-#D literal 0 HcmV?d00001 diff --git a/src/py-radix/image_utils.py b/src/pyradix/image_utils.py similarity index 99% rename from src/py-radix/image_utils.py rename to src/pyradix/image_utils.py index a09313b..c599e48 100644 --- a/src/py-radix/image_utils.py +++ b/src/pyradix/image_utils.py @@ -1,7 +1,6 @@ import numpy as np import cv2 - def create_arrows_sub(src2, moves2, word): frames = [] currentImg = np.zeros((560, 560, 3), np.uint8) diff --git a/src/py-radix/old/wordgame - Copy.py b/src/pyradix/old/wordgame - Copy.py similarity index 100% rename from src/py-radix/old/wordgame - Copy.py rename to src/pyradix/old/wordgame - Copy.py diff --git a/src/py-radix/old/wordgame.py b/src/pyradix/old/wordgame.py similarity index 100% rename from src/py-radix/old/wordgame.py rename to src/pyradix/old/wordgame.py diff --git a/src/py-radix/old/wordgame_anagram.py b/src/pyradix/old/wordgame_anagram.py similarity index 100% rename from src/py-radix/old/wordgame_anagram.py rename to src/pyradix/old/wordgame_anagram.py diff --git a/src/py-radix/old/wordgame_trie.py b/src/pyradix/old/wordgame_trie.py similarity index 100% rename from src/py-radix/old/wordgame_trie.py rename to src/pyradix/old/wordgame_trie.py diff --git a/src/py-radix/radix_utils.py b/src/pyradix/radix_utils.py similarity index 95% rename from src/py-radix/radix_utils.py rename to src/pyradix/radix_utils.py index 3976718..b105693 100644 --- a/src/py-radix/radix_utils.py +++ b/src/pyradix/radix_utils.py @@ -1,4 +1,4 @@ -import tree_utils as tu +import pyradix.tree_utils as tu def optimize_tree(tree): anyReduxed = False diff --git a/src/py-radix/tree_utils.py b/src/pyradix/tree_utils.py similarity index 83% rename from src/py-radix/tree_utils.py rename to src/pyradix/tree_utils.py index 578aa42..f67f425 100644 --- a/src/py-radix/tree_utils.py +++ b/src/pyradix/tree_utils.py @@ -1,18 +1,26 @@ +import copy class node: def __init__(self, type, isword, subnodes): self.type = type self.subnodes = subnodes self.isword = isword -def words_to_tree(file_location): + def copy(self): + copied = copy.deepcopy(self) + return copied + +def words_to_tree(dict): topnode = node(str,False,[]) - dict = get_dict(file_location) for word in dict: if(word==""): continue topnode.subnodes = create_new_node(word, 1, topnode.subnodes) return topnode +def add_word(topnode, word): #DOES NOT WORK WITH RADIX TREE + if(len(word)>0): + topnode.subnodes = create_new_node(word, 1, topnode.subnodes) + def create_new_node(word, letters, subnodes): sub2 = find_index(subnodes,word, letters) if(len(word)==letters): @@ -41,6 +49,7 @@ def get_dict(file_location): file = open(file_location, "r") #or use english3.txt for smaller dictionary content = file.read() dict = content.split("\n") + file.close() return dict def count_nodes(topnode): diff --git a/src/py-radix/wordcheck_utils.py b/src/pyradix/wordcheck_utils.py similarity index 91% rename from src/py-radix/wordcheck_utils.py rename to src/pyradix/wordcheck_utils.py index 0120131..79dacf2 100644 --- a/src/py-radix/wordcheck_utils.py +++ b/src/pyradix/wordcheck_utils.py @@ -1,6 +1,8 @@ -import tree_utils as tu -import radix_utils as ru +import pyradix.tree_utils as tu +import pyradix.radix_utils as ru def check_if_word(node, word, radix): + if(word==""): + return True return check_if_word_sub(word, node, 1, radix) def check_if_word_sub(word, node, letters, radix): #actually not used in new version, but useful regardless diff --git a/src/py-radix/wordgame_radix_footage.py b/src/pyradix/wordgame_radix_footage.py similarity index 100% rename from src/py-radix/wordgame_radix_footage.py rename to src/pyradix/wordgame_radix_footage.py diff --git a/src/pyradix_stevenewald.egg-info/PKG-INFO b/src/pyradix_stevenewald.egg-info/PKG-INFO new file mode 100644 index 0000000..127ced7 --- /dev/null +++ b/src/pyradix_stevenewald.egg-info/PKG-INFO @@ -0,0 +1,18 @@ +Metadata-Version: 2.1 +Name: pyradix-stevenewald +Version: 0.0.1 +Summary: Python implementation of Radix Tree: memory and speed optimized language detection +Home-page: https://github.com/stevenewald/pyradix +Author: Steven Ewald +Author-email: steve@steve.ee +License: UNKNOWN +Project-URL: Bug Tracker, https://github.com/stevenewald/pyradix/issues +Platform: UNKNOWN +Classifier: Programming Language :: Python :: 3 +Classifier: License :: OSI Approved :: MIT License +Classifier: Operating System :: OS Independent +Requires-Python: >=3.6 +Description-Content-Type: text/markdown + +UNKNOWN + diff --git a/src/pyradix_stevenewald.egg-info/SOURCES.txt b/src/pyradix_stevenewald.egg-info/SOURCES.txt new file mode 100644 index 0000000..da3135a --- /dev/null +++ b/src/pyradix_stevenewald.egg-info/SOURCES.txt @@ -0,0 +1,12 @@ +pyproject.toml +setup.py +src/pyradix/__init__.py +src/pyradix/image_utils.py +src/pyradix/radix_utils.py +src/pyradix/tree_utils.py +src/pyradix/wordcheck_utils.py +src/pyradix/wordgame_radix_footage.py +src/pyradix_stevenewald.egg-info/PKG-INFO +src/pyradix_stevenewald.egg-info/SOURCES.txt +src/pyradix_stevenewald.egg-info/dependency_links.txt +src/pyradix_stevenewald.egg-info/top_level.txt \ No newline at end of file diff --git a/src/pyradix_stevenewald.egg-info/dependency_links.txt b/src/pyradix_stevenewald.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/pyradix_stevenewald.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/src/pyradix_stevenewald.egg-info/top_level.txt b/src/pyradix_stevenewald.egg-info/top_level.txt new file mode 100644 index 0000000..e389529 --- /dev/null +++ b/src/pyradix_stevenewald.egg-info/top_level.txt @@ -0,0 +1 @@ +pyradix diff --git a/tests/__pycache__/test_use_case.cpython-310.pyc b/tests/__pycache__/test_use_case.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d266171e824ba9f1efc88f1c0ea025d80af69e56 GIT binary patch literal 1321 zcmY)u%WfMtkldH3wPYJXfY?P3x#XZ8EI7v?EdtnSE`?DbDT)#*h|Q8(t@b68RO}e5 zlhadC^cSq&`Z>Mw+LL~uhaB3@teiq6HM29rc@L>(IE)Fb^Z1YC=YWtuk=b1!BQF5V z1t3WzEeYR#DW@IpaSy&;=~q7YDS1VtFM|(628zssTc3w2l40TLCyLzl)`WtO*By+a z4frG%BkBTsDXSE@-Q@xE0>C^3qzJ}?SX6o+2=}G`nv4RsXO*$v8FiKzl~U0Aw6H7& za0X!h0%XY@m2^#4)OymB{x9^`Co8Y@?jYSYr39!zhDd>C*rKKnRMh(aoqG3FSH}0y zh5+_06kW4ZVxC@sE$$z%$Y>RSHIu#8Z-ceJ3fs{3+whi3c0{(+Pu?*BIk}7PPx@<b zCwi0-8UIFCy|#Bweq<{K{`T6aWvF#2I_Z8V9iUY9AW9#+4ck8Ec{!H^TC{g@^YZN3 z7+R#w*jV*Wjn9=SY_k|&HCkp#r9|D-S#HPYd1~{fPIRu!Sk+mXo0%vRov9OhZ8ta$ zm{n*So0K;XzG)Jf*V$tnz+<bGG8^naKTO`HQcbg2J}=6uZWdo}4nV%afsFQe5B0&0 zvus`@^CHtcHkmGq%*<=UW0lP{{A5<};OeP1j-EQgqoT|TQ^G|7Yu-0arR)s7^pb^K z$Z0*=cfG}X4JloNXJv(iVl<}A4-B%(q&i<<eJ)xqWMUN`Vgrn@jllHzuz}+$zfm3Q z!nACR;s>boZDMEByvBN+U#i*-69Wykue1V3nzKYofr@;X&Qw~6eA=-t-s-*4OErpJ zU{pEfA*Oc9gT>oKyYN0`G=_d#7j{W;1~b_n^*<e5y8ub&ze~#BiGBpNef;w5*`yoo zq#NzzezX%*+!^fz+h#f}mPUybUdzeiy&Iw&B`7$Jz@zyBP)r9j-r1jj40`+Yh#rEB z!QSs+K!d+;j?n{TfbZ|*f8H+ObuuApykNq`LR5`hmPikTxLhXX_Cy~;z^<4bbc8Y= zPzYe~KZub5?Ih^4O7dEW5p!%==N6;F#mFnA2WW>wckB&FF{#c-e}=LE?RKJI2Q`Lr a?D;miukZ$&LqLpRp#%DWvPV$pKmP*pT4=@q literal 0 HcmV?d00001 diff --git a/tests/__pycache__/test_word_check.cpython-310.pyc b/tests/__pycache__/test_word_check.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..151c38f6e050f390be712709ca1a1ef74f53df34 GIT binary patch literal 2624 zcmZ`*O>Y}T7@pY=d+gYWlYY>amWGxVj6|*SajB}dQu=WKMMw=)tb$fs&)D8%z3a@3 z+s1M(wBmq-_zMoVUJwWV0l$FjT#=A^?ghBO`_9^NoVaW4JKwYK`##S+<E&aO6L@}i z|A>Aq5%MQC4nH0=?!c?o!EnN9LV~=c0kv%>aG-P&x9bKjB@YO9x%Yx_PmnF|xf}SR z!2NAUUJ+ze+$R+Fcxc~x;T7yj*6Y-GdWUzL*gE_$XxxEU{RT!5{9fP)cjR%pPXoUV zU;UW|1yRH={z!lNFkpg>O5ES4l)${QfLgEseHC7q>8rx%qNv(F9CgRFCG_tR;YE*l z<T*r>vg<_MehT~H?;G@<@zM(t)OeXMK)K8-yb9$CU*t<rp5QgU4CP5)d`RjmrmBU~ zk21;EI-<EfxVLtr@s$!%HIx=lMB}bd+dAttp2CcF)D>ZxrR`WZ?#4|WXK5s3p&BA> zC$Z{;NhI6intrD1UQpAz-|9u8mkJrTQ>B7hFH5`0_Ey|!w*+rKj)Gb<&XR6Nwghyf zD#=VOdfeoq)$YVw+etUgd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^-55U<E1ftqRt;@Sm= z^HD1hOStv|npHGc(0qVqDjK$iiYZ+%2#mS}h7r_74D#^r{6CB_hm~2mQnK?gzHSt! zVOVE|_0w2mKH!g4+!eWeVGM?CK<`=vmoa`s*0ImSb@LoC>}H;*TX^Fulu|~R^=5^# J&nndW?|;o*gD?O9 literal 0 HcmV?d00001 diff --git a/tests/test_use_case.py b/tests/test_use_case.py new file mode 100644 index 0000000..92a9a2d --- /dev/null +++ b/tests/test_use_case.py @@ -0,0 +1,29 @@ +import unittest +import time +import pyradix +from tqdm import tqdm +class testUseCase(unittest.TestCase): + def test_usecase1(self): + dict1 = pyradix.get_dict("C:/Users/steve/Desktop/wordgame_nongit/Dictionaries/english_large.txt") + with tqdm(total=2) as pbar: + pbar.set_description("Loading test trees") + pbar.update(1) + radix = pyradix.words_to_tree(dict1) + pyradix.optimize_tree(radix) + pbar.update(2) + pbar.close() + wordlist = "abcdefghijklmnop" + words = pyradix.wordPathfinding(False, radix, wordlist) + words = words[len(words)-15:len(words)] + self.assertGreater(len(words), 10) + nonradix = pyradix.words_to_tree(dict1) + wordlistx = ["testing", "gjkajkgr", "sgrlkgsjns", "egjrgjrdgk", "w2rs", "1", "", "klgksl", "test", "something", "apdpdfn"] + for word in wordlistx: + pyradix.add_word(nonradix, word) + for word in wordlistx: + val = pyradix.check_if_word(nonradix, word, False) + self.assertTrue(val) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_word_check.py b/tests/test_word_check.py index baae1a6..07e71c7 100644 --- a/tests/test_word_check.py +++ b/tests/test_word_check.py @@ -1,47 +1,59 @@ -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)) \ No newline at end of file +import unittest +import time +import pyradix +from tqdm import tqdm +class testWordCheck(unittest.TestCase): + dict1 = pyradix.get_dict("C:/Users/steve/Desktop/wordgame_nongit/Dictionaries/english_large.txt") + wordlistF = ["ttufpaepnerignss", "ponmlkjihgfedcba", "ciolmhrfefednslo", "abcdefghijklmnop"] + with tqdm(total=2) as pbar: + pbar.set_description("Loading test trees") + nonradix = pyradix.words_to_tree(dict1) + pbar.update(1) + radix = pyradix.words_to_tree(dict1) + pyradix.optimize_tree(radix) + pbar.update(2) + pbar.close() + def test_testvalidity(self): + self.assertGreater(len(self.dict1), 10000) + def test_nonradix_word_equality(self): + with tqdm(total=(len(self.dict1))) as pbar: + pbar.set_description("Testing non-radix validity") + for word in self.dict1: + if(word==""): + continue + val = pyradix.check_if_word(self.nonradix, word, False) + self.assertTrue(val) + pbar.update(1) + pbar.close() + def test_radix_word_equality(self): + with tqdm(total=(len(self.dict1))) as pbar: + pbar.set_description("Testing radix validity") + for word in self.dict1: + if(word==""): + continue + val = pyradix.check_if_word(self.radix, word, True) + self.assertTrue(val) + pbar.update(1) + pbar.close() + def test_result_equality(self): + with tqdm(total=len(self.wordlistF)) as pbar: + pbar.set_description("Testing non-radix and radix equality") + for wordlist in self.wordlistF: + pw1 = pyradix.wordPathfinding(False, self.nonradix, wordlist) + pw2 = pyradix.wordPathfinding(False, self.radix, wordlist) + self.assertEqual(pw1, pw2) + pbar.update(1) + pbar.close() + def test_trie_size(self): + with tqdm(total=2) as pbar: + pbar.set_description("Validating non-radix and radix size") + size = pyradix.count_nodes(self.nonradix) + pbar.update(1) + size2 = pyradix.count_nodes(self.radix) + pbar.update(1) + self.assertEqual(size, 1027814) + self.assertEqual(size2, 478056) + pbar.close() + +if __name__ == '__main__': + unittest.main() \ No newline at end of file