11-23-2022, 02:31 AM
(This post was last modified: 11-23-2022, 02:34 AM by PhilOfPerth.)
(11-22-2022, 05:01 PM)SMcNeill Wrote: A useful little tool for anyone who likes to play Scrabble.That's the file I've used in the wordslists folder for my word-games (alchemy et al) but I weeded out the definitions and obscene words, and separated them into 26 separate files for easier searching. I didn't think most people would be too concerned about the meanings when just playing a casual game
Code: (Select All)file$ = "Collins Scrabble Words (2019) with definitions.txt"
'279498 words
Type Dict_Type
word As String
definition As String
End Type
ReDim As String Word(1000000), Definition(1000000)
Open file$ For Binary As #1
Do Until EOF(1)
Line Input #1, text$
count = count + 1
p = InStr(text$, Chr$(9))
Word(count) = _Trim$(Left$(text$, p - 1))
Definition(count) = _Trim$(Mid$(text$, p + 1))
Loop
ReDim _Preserve Word(count) As String
ReDim _Preserve Definition(count) As String
Do
Color 4
Input "Give me a word to look up for you =>"; word$
If word$ = "" Then System
i = BinaryStringSearch(UCase$(word$), Word())
Color 15
If i > -1 Then
Print word$; " found! It's definition is: "; Definition(i)
Else
Print word$; " doesn't exist! You big dummy! Cheater! Who's gonna play Scrabble with you?!!"
End If
Loop
Function BinaryStringSearch (search$, Array() As String)
'These routines work with actual indexes, so we can search from Array(-10 to 10), if we want to.
'When the search string is found, it'll return a value = to the index proper.
'When it's not found, it'll return a value LESS THAN the LBOUND limit of the array,
'And the point where the string WOULD'VE appeared, if it existed, is after the shared variable LastIndex
BinaryStringSearch = BinaryStringSearchSome(search$, Array(), LBound(Array), UBound(Array))
End Function
Function BinaryStringSearchSome (search$, Array() As String, StartIndex As Long, EndIndex As Long)
'These routines work with actual indexes, so we can search from Array(-10 to 10), if we want to.
'When the search string is found, it'll return a value = to the index proper.
'When it's not found, it'll return a value LESS THAN the LBOUND limit of the array,
'And the point where the string WOULD'VE appeared, if it existed, is after the shared variable LastIndex
min = StartIndex
max = EndIndex
Do
gap = (max + min) \ 2
compare = _StrCmp(search$, Array(gap))
If compare > 0 Then
min = gap + 1
ElseIf compare < 0 Then
max = gap - 1
Else
BinaryStringSearchSome = gap
Exit Function
End If
If max - min < 1 Then
If search$ = Array(min) Then
BinaryStringSearchSome = min
Else
BinaryStringSearchSome = LBound(Array) - 1
If search$ < Array(min) Then
LastIndex = min - 1
Else
LastIndex = min
End If
End If
found = -1
End If
Loop Until found
End Function
Download and extract the word list/dictionary from below to use with this program.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Please visit my Website at: http://oldendayskids.blogspot.com/
Please visit my Website at: http://oldendayskids.blogspot.com/