Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
(02-29-2024, 03:21 PM)bplus Wrote: Here is my RA method tested with zebra and some of your words, no rootbeer here either but does find zebra OK
Possible Plil's list was reassembled from his letter lists???
Mine came straight from Collins 2019 Scrabble which came from you Steve, I think?
No, the list was a direct download from the 'net, without sorting (but I did filter my own lists for shorter words and to remove some "F'" and "C" words, to make it suitable for general consumption.
Posts: 652
Threads: 96
Joined: Apr 2022
Reputation:
22
02-29-2024, 11:23 PM
(This post was last modified: 02-29-2024, 11:24 PM by PhilOfPerth.)
(02-29-2024, 02:53 PM)bplus Wrote: cat = to vomit??? that's what a cat is?
I gotta check my Collin's now ;-))
That's a weird definition. I searches several dictiomaries and couldn't match it, but a search on VOMIT came up with a slang phrase, "to shoot the cat".
That's as close as I can get!
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
(02-29-2024, 06:33 PM)bplus Wrote: So something else is going on that using count to control stop fixes.
BTW .39 +/- secs to load dictionary well within acceptable range! I think the issue you're seeing is from the last line being blank. I don't think it terminates with a chr$(10), so you're never actually advancing to the end of the file.
Add a check for If temp1$ = "" Then Exit Do in there, and you're golden.
Your endless loop is basically start point = 1234567890, end point = 0... then at the end of that loop, start point = end point + 1... so it just starts reading the whole file over and over and over and over and over and over again.
Exit it with a check for that blank line, and you skip that reset to 0.
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
02-29-2024, 11:33 PM
(This post was last modified: 02-29-2024, 11:36 PM by SMcNeill.)
(02-29-2024, 11:23 PM)PhilOfPerth Wrote: (02-29-2024, 02:53 PM)bplus Wrote: cat = to vomit??? that's what a cat is?
I gotta check my Collin's now ;-))
That's a weird definition. I searches several dictiomaries and couldn't match it, but a search on VOMIT came up with a slang phrase, "to shoot the cat".
That's as close as I can get!
https://en.wiktionary.org/wiki/cat#Verb
(02-29-2024, 11:03 PM)PhilOfPerth Wrote: (02-29-2024, 03:21 PM)bplus Wrote: Here is my RA method tested with zebra and some of your words, no rootbeer here either but does find zebra OK
Possible Plil's list was reassembled from his letter lists???
Mine came straight from Collins 2019 Scrabble which came from you Steve, I think?
No, the list was a direct download from the 'net, without sorting (but I did filter my own lists for shorter words and to remove some "F'" and "C" words, to make it suitable for general consumption.
The problem wasn't with the list. It was with SINGLE losing precision counting character position with the list. A single variable type can only got up to 16.3 million or so, before it swaps over to scientific notation. The file is over 17 million bytes in size, and thus the issue I was having.
You still might want to grab the version I posted as an attachment a few versions up. It cleans out those 2 header lines and removes a blank line at the end, and makes it so you only have to look for CHR$(10) line endings instead of chr$(13) + chr$(10), which reduces overall size by 275k bytes. (one byte for each line in the file.)
Posts: 3,964
Threads: 176
Joined: Apr 2022
Reputation:
219
02-29-2024, 11:52 PM
(This post was last modified: 03-01-2024, 12:03 AM by bplus.)
(02-29-2024, 11:27 PM)SMcNeill Wrote: (02-29-2024, 06:33 PM)bplus Wrote: So something else is going on that using count to control stop fixes.
BTW .39 +/- secs to load dictionary well within acceptable range! I think the issue you're seeing is from the last line being blank. I don't think it terminates with a chr$(10), so you're never actually advancing to the end of the file.
Add a check for If temp1$ = "" Then Exit Do in there, and you're golden.
Your endless loop is basically start point = 1234567890, end point = 0... then at the end of that loop, start point = end point + 1... so it just starts reading the whole file over and over and over and over and over and over again.
Exit it with a check for that blank line, and you skip that reset to 0.
+1 That sounds so likely and nicely reasoned I don't even want to test and find out it's wrong. ;-))
I've been working on getting v3.12 loaded and copying my 13,994 files and 1051 folders to a backup drive and before that, storing away or dumping 2 months of files and pictures, whew!
Confirmed, I tested by ending loop with this:
Code: (Select All) Loop Until sp >= Len(temp$) Or ep = 0
b = b + ...
Posts: 733
Threads: 30
Joined: Apr 2022
Reputation:
43
At a certain point, dealing with a dictionary of that size sounds better suited for a SQLite database.
Tread on those who tread on you
Posts: 128
Threads: 12
Joined: Apr 2022
Reputation:
14
This file is so small, just keep it in a small corner of your memory
Makes life much easier also.
Takes 39ms on my older i5 system:
Code: (Select All) Dim Shared words As String
words = _ReadFile$("Collins.txt")
Dim Junk(10) As String
Data cheese,dog,cat,elephant,rootbeer,house,food,drink,zebra,mouse
For i = 1 To 10
Read Junk(i)
Next
t# = Timer(.001)
For i = 1 To 10
Print Junk(i),
def$ = FindWord(Junk(i))
If def$ = "" Then
Print "Word not found"
Else
Print def$
End If
Next
t1# = Timer(.001)
Print Using "###.######## seconds to find #### words and definitions"; t1# - t#, i - 1
' 0.039 seconds
Function FindWord$ (wrd$)
fpos& = InStr(words, UCase$(wrd$) + Chr$(9))
If fpos& > 0 Then
fpos& = fpos& + Len(wrd$) + 1
eol& = InStr(fpos&, words, Chr$(13))
FindWord$ = Mid$(words, fpos&, eol& - fpos&)
End If
End Function
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Posts: 3,964
Threads: 176
Joined: Apr 2022
Reputation:
219
03-01-2024, 01:39 PM
(This post was last modified: 03-01-2024, 02:04 PM by bplus.)
Oh that looks pretty nice and efficient, way to use that tab char!
OK I was testing that function and it found another definition for CAT:
Code: (Select All) Dim Shared words As String
words = _ReadFile$("Collins.txt")
Do
Input "Enter word to lookup "; lookup$
result$ = FindWord$(lookup$)
If result$ = "" Then Print lookup$; " Not Found." Else Print result$
Print
Loop Until lookup$ = ""
Function FindWord$ (wrd$) ' thanks mdijkens
fpos& = InStr(words, UCase$(wrd$) + Chr$(9))
If fpos& > 0 Then
fpos& = fpos& + Len(wrd$) + 1
eol& = InStr(fpos&, words, Chr$(13))
FindWord$ = Mid$(words, fpos&, eol& - fpos&)
End If
End Function
So it found cat somewhere else in Collins.txt???
I verified the Collins def of CAT as 'to vomit' so how are we finding this new definition?
Also mouse looked different.
b = b + ...
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
03-01-2024, 01:56 PM
(This post was last modified: 03-01-2024, 01:57 PM by SMcNeill.)
You're getting the 2nd half of "alley cat" definition.
Which is why a look up list is better than a INSTR search.
You might try to search for CHR$(10) + word$ + CHR$(9), for the line ending from the previous line, plus the word, with the tab separator after.
Posts: 3,964
Threads: 176
Joined: Apr 2022
Reputation:
219
03-01-2024, 02:05 PM
(This post was last modified: 03-01-2024, 02:08 PM by bplus.)
that might work except for AA but who cares about that
;-))
I am starting to think the RA method wasn't too terrible 0 preprocessing after setup RA, but yes some duplication and 2 files for words...
The definitions doesn't even have to be RA.
b = b + ...
|