Post by dkl on Nov 2, 2021 2:44:56 GMT -5
I think this is close to my final version of this programme. If anyone is interested and has been following this.
Updates are as follows.....................
1.) added an extra listbox, to include 3 letter words
4.) added a box to display search time
Collins Scrabble Dictionary - File Link
drive.google.com/open?id=1oGDf1wjWp5RF_X9C7HoedhIWMh5uJs8s
Collins Scrabble Dictionary (with definitions) - File Link
drive.google.com/open?id=1XIFdZukAcDRiDIOgR_rHpICrrgJbLBxV
Any problems use this link
Webpage Link (StackExchange)
Updates are as follows.....................
1.) added an extra listbox, to include 3 letter words
2.) double click on a word and box will open with the word definition
3.) word list is only loaded once - when the programme first starts. Not every time a word search is done (as before)
3.) speed has been greatly improved, but the longer the word and further into the alphabet e.g. Z, the longer it can take. (xylophone takes 9 sec to find 146 words),(abbreviated takes 13s to find 461 words), but (cable takes 3 sec to find 22 words). The word definition file is NOT attached to this so does not affect the search speed. I might add a min/max word search which may improve the speed more4.) added a box to display search time
N.B. Hit 'Clear' before inputting a new word.
Download the following files and add relevant path/filename to the relevant code at the beginning of the programme. If an alternative file is used then the variable 'wordCount' will need to be updated.
There are many word lists out there on the web, which one can customise to personal taste, but here are the links to the lists I have been using. there are a lot of words that really not needed, so if anyone finds one that is fairly comprehensive, but just has common usage words, I would be very interested to know about it.
Collins Scrabble Dictionary - File Link
drive.google.com/open?id=1oGDf1wjWp5RF_X9C7HoedhIWMh5uJs8s
Collins Scrabble Dictionary (with definitions) - File Link
drive.google.com/open?id=1XIFdZukAcDRiDIOgR_rHpICrrgJbLBxV
Any problems use this link
Webpage Link (StackExchange)
Hope this of interest to someone! But if not that's fine, I've had a lot of fun coding it.
A special thanks to tsh73 for his help and assistance
Dim dict$(280000),letr$(30),Uword$(30),Uword2$(30)
Dim store3$(2000),store4$(2000),store5$(2000),store6$(2000),store7$(2000),store8$(2000),store9$(2000),store10$(2000)
c = 1
dictionary$ = "Collins Scrabble Words (2019) with definitions.txt":DwordCount = 279494'321719
'path$ = "C:\Users\username\Desktop\" 'add word.txt file path$ here
path$ = "L:\_New Projects\Anagrams\"
'doc$ = "unixdict.txt":wordCount = 25000'unixdict.txt
doc$ = "Collins Scrabble Words (2019).txt":wordCount = 279494 'Collins Scrabble Words (2019).txt
'doc$ = "words1.txt":wordCount = 235886 'word1.txt
f$ = path$+doc$
d$ = paths$+dictionary$
'---------------------------------------------------------------------------GUI
nomainwin
WindowWidth = 1055
WindowHeight = 600
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
x=10:y = 80:w = 110:h = 400:xgap = w+20
ListboxColor$ = "lightgray"
listbox #1.3, store3$(), [EH3], x+(xgap*0), y, w, h
listbox #1.4, store4$(), [EH4], x+(xgap*1), y, w, h
listbox #1.5, store5$(), [EH5], x+(xgap*2), y, w, h
listbox #1.6, store6$(), [EH6], x+(xgap*3), y, w, h
listbox #1.7, store7$(), [EH7], x+(xgap*4), y, w, h
listbox #1.8, store8$(), [EH8], x+(xgap*5), y, w, h
listbox #1.9, store9$(), [EH9], x+(xgap*6), y, w, h
listbox #1.10, store10$(), [EH10], x+(xgap*7),y, w, h
button #1.ext, "Exit", [quit],UL,1000, y-60, 35, 25
stylebits #1.tb1, _ES_CENTER, 0, 0, 0
textbox #1.in, x, y-60, 300, 25
stylebits #1.ok, _BS_DEFPUSHBUTTON, 0, 0, 0
button #1.ok, "OK", [getWord],UL, x+305, y-60, 30, 25
button #1.cl, "Clear", [clear],UL, x+345, y-60, 50, 25
statictext #1.ina, "Input User Word (Min 3 - Max 10 Letters)",10+(xgap*0),0,340,20
statictext #1.3a, "3 Letter Words",10+(xgap*0),y-20,120,20
statictext #1.4a, "4 Letter Words",10+(xgap*1),y-20,120,20
statictext #1.5a, "5 Letter Words",10+(xgap*2),y-20,120,20
statictext #1.6a, "6 Letter Words",10+(xgap*3),y-20,120,20
statictext #1.7a, "7 Letter Words",10+(xgap*4),y-20,120,20
statictext #1.8a, "8 Letter Words",10+(xgap*5),y-20,120,20
statictext #1.9a, "9 Letter Words",10+(xgap*6),y-20,120,20
statictext #1.10a, "10 Letter Words",10+(xgap*7),y-20,120,20
y2 = 500
statictext #1.3b, "Word Count",10+(xgap*0),y2-20,120,20
statictext #1.4b, "Word Count",10+(xgap*1),y2-20,120,20
statictext #1.5b, "Word Count",10+(xgap*2),y2-20,120,20
statictext #1.6b, "Word Count",10+(xgap*3),y2-20,120,20
statictext #1.7b, "Word Count",10+(xgap*4),y2-20,120,20
statictext #1.8b, "Word Count",10+(xgap*5),y2-20,120,20
statictext #1.9b, "Word Count",10+(xgap*6),y2-20,120,20
statictext #1.10b, "Word Count",10+(xgap*7),y2-20,120,20
textbox #1.3t, x+(xgap*0), 500, 40, 25
textbox #1.4t, x+(xgap*1), 500, 40, 25
textbox #1.5t, x+(xgap*2), 500, 40, 25
textbox #1.6t, x+(xgap*3), 500, 40, 25
textbox #1.7t, x+(xgap*4), 500, 40, 25
textbox #1.8t, x+(xgap*5), 500, 40, 25
textbox #1.9t, x+(xgap*6), 500, 40, 25
textbox #1.10t, x+(xgap*7), 500, 40, 25
textbox #1.tim, 900, y-60, 40, 25
stylebits #1.inf, _ES_CENTER, 0, 0, 0
textbox #1.inf, x+450, y-60, 400, 25
TextboxColor$ = "green"
stylebits #1.sinf, _ES_CENTER, 0, 0, 0
textbox #1.sinf, x+450, y-60, 400, 25'y-50
BackgroundColor$ = "darkcyan"
[main_loop]
if op = 0 then open w$ for Window as #1:op = 1
#1, "font Georgia 10 bold"
#1.in, "!setfocus"
#1.inf "!hide"
#1.sinf "!hide"
if ld = 0 then gosub [loadDict]
#1.inf,"":#1.inf,ct;" words loaded from ";wordCount;" words available"
wait
'---------------------------------------------------------------------------
[loadData]
#1.sinf,"!show":#1.sinf,"Searching Wordlist..............."
t0=time$("seconds")
[split] 'separate letters in dictionary Word(dict$)
lnDct = len(dict$(c)) 'len of dictionary word
if lnDct > lnwd or lnDct < 3 then [nextWord]'get new word if 'next word' is greater than user word or smaller than 4
for a = 1 to lnDct
letr$(a) = mid$(dict$(c),a,1)
next a
[srch] 'compare letters in Uword$ with dict$ word
for b = 1 to lnwd'Uword loop
pos = instr(Uword$,letr$(b))
if pos = 0 then exit for
if pos <> 0 then Lct = Lct + 1:Uword$ = mid$(Uword$,1,pos-1) + mid$(Uword$,pos+1,len(Uword$))
next b
if Lct = lnDct then gosub [store]
Lct = 0:lnDct = 0
[nextWord]'this clears old info to search for next word in dict$ WORD LIST. It has nothing to do with restarting and searching a NEW User word
redim letr$(30)
Uword$ = Uword2$ 'reinstate User word
c = c + 1:if c >= wordCount then [end]'[error]
goto [split]
[end]
cls
print "there's a problem"
t1=time$("seconds")
print "Time taken ";t1-t0
#1.sinf,"":#1.sinf,"!hide"':#1.inf,"":#1.inf,"!hide"
#1.3, "reload":#1.4, "reload":#1.5, "reload":#1.6, "reload":#1.7, "reload":#1.8, "reload":#1.9, "reload":#1.10, "reload"
#1.3t, st3:#1.4t, st4:#1.5t, st5:#1.6t, st6:#1.7t, st7:#1.8t, st8:#1.9t, st9:#1.10t, st10
print:print "3 letter words - ";st3-1:p = 0
for pr = 1 to st3
print store3$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "4 letter words - ";st4-1:p = 0
for pr = 1 to st4
print store4$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "5 letter words - ";st5-1:p = 0
for pr = 1 to st5
print store5$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "6 letter words - ";st6-1:p = 0
for pr = 1 to st6
print store6$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "7 letter words - ";st7-1:p = 0
for pr = 1 to st7
print store7$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "8 letter words - ";st8-1:p = 0
for pr = 1 to st8
print store8$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "9 letter words - ";st9-1:p = 0
for pr = 1 to st9
print store9$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
print:print "10 letter words - ";st10-1:p = 0
for pr = 1 to st10
print store10$(pr),:p = p + 1:if p = 6 then print chr$(10),chr$(13):p = 0
next pr
total = st3+st4+st5+st6+st7+st8+st9+st10
print total;" words found in total"
#1.inf, "":#1.inf,total;" words found in total"
#1.tim, t1-t0;" s"
wait
[store]
if lnDct = 3 then store3$(st3) = dict$(c):st3 = st3 +1
if lnDct = 4 then store4$(st4) = dict$(c):st4 = st4 +1
if lnDct = 5 then store5$(st5) = dict$(c):st5 = st5 +1
if lnDct = 6 then store6$(st6) = dict$(c):st6 = st6 +1
if lnDct = 7 then store7$(st7) = dict$(c):st7 = st7 +1
if lnDct = 8 then store8$(st8) = dict$(c):st8 = st8 +1
if lnDct = 9 then store9$(st9) = dict$(c):st9 = st9 +1
if lnDct = 10 then store10$(st10) = dict$(c):st10 = st10 +1
return
[getWord]
#1.in,"!contents? Uword$"
Uword$ = lower$(trim$(Uword$))
Uword2$ = Uword$
lnwd = len(Uword$) 'len of User word
#1.cl,"!setfocus"
goto [loadData]
[clear]
'redim dict$(280000)
redim letr$(30):redim Uword$(30):redim Uword2$(30)
redim store3$(2000):redim store4$(2000):redim store5$(2000):redim store6$(2000)
redim store7$(2000):redim store8$(2000):redim store9$(2000):redim store10$(2000)
#1.3, "reload":#1.4, "reload":#1.5, "reload":#1.6, "reload":#1.7, "reload":#1.8, "reload":#1.9, "reload":#1.10, "reload"
#1.3t, "":#1.4t, "":#1.5t, "":#1.6t, "":#1.7t, "":#1.8t, "":#1.9t, "":#1.10t, "":#1.tim,""
st3 = 0:st4 = 0:st5 = 0:st6 = 0:st7 = 0:st8 = 0:st9 = 0:st10 = 0
c = 0:lnDct = 0:lnwd = 0:ct = 0
#1.in,"":#1.in,"!setfocus"
goto [main_loop]
[quit]
close #1
end
[EH3]
sel = 3:goto [CSD]
[EH4]
sel = 4:goto [CSD]
[EH5]
sel = 5:goto [CSD]
[EH6]
sel = 6:goto [CSD]
[EH7]
sel = 7:goto [CSD]
[EH8]
sel = 8:goto [CSD]
[EH9]
sel = 9:goto [CSD]
[EH10]
sel = 10:goto [CSD]
[CSD]
'print "I'M HERE"
if sel = 3 then #1.3,"selection? selected$"
if sel = 4 then #1.4,"selection? selected$"
if sel = 5 then #1.5,"selection? selected$"
if sel = 6 then #1.6,"selection? selected$"
if sel = 7 then #1.7,"selection? selected$"
if sel = 8 then #1.8,"selection? selected$"
if sel = 9 then #1.9,"selection? selected$"
if sel = 10 then #1.10,"selection? selected$"
Sword$ = selected$:sel = len(Sword$)
t0=time$("seconds")
open d$ for input as #dic
for rd = 1 to DwordCount' <------- here
line input #dic,dictData$:dd = dd + 1
if lower$(left$(dictData$,sel)) = Sword$ then exit for
if dictData$ = "" then exit for
next rd
close #dic
t1=time$("seconds")
print "Time taken ";t1-t0;" secs"
print
print upper$(Sword$);" - ";mid$(dictData$,sel+1,len(dictData$))
[dictInfo]
WindowWidth = 600
WindowHeight = 45
UpperLeftX=int((DisplayWidth-WindowWidth)/2)'706
UpperLeftY=int((DisplayHeight-WindowHeight)/2) '485
BackgroundColor$ = "darkred"
TextboxColor$ = "palegray"
textbox #inf1.tb, 10, 10, 550, 25
stylebits #inf1.ok1, _BS_DEFPUSHBUTTON, 0, 0, 0
button #inf1.ok1, "OK", [OK1],UR, 5, 10, 30, 25
on error goto [OK1]
open " " for Window_popup as #inf1
#inf1.tb, "!font georgia 10 bold"
#inf1.tb,upper$(Sword$);" - ";mid$(dictData$,sel+1,len(dictData$))
wait
[OK1]
close #inf1
#1.3,"select 0":#1.4,"select 0":#1.5,"select 0":#1.6,"select 0":#1.7,"select 0":#1.8,"select 0":#1.9,"select 0":#1.10,"select 0"
selected$ = "":sel = 0:dd = 0
wait
[loadDict]
open f$ for input as #rd
print "loading word file........"
#1.inf, "!show":#1.inf, "loading word file........................"
for rd = 1 to wordCount
line input #rd,data$:ct = ct +1:dict$(ct) = lower$(trim$(data$))':if len(data$) >= 4 and len(data$) <= lnwd then ct = ct +1:dict$(ct) = lower$(trim$(data$))
if data$ = "" then exit for
next rd
close #rd
ld = 1
return
[error]
notice "there is a problem with variable c"
wait