Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to format a While... Wend correctly?
#31
(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.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#32
(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". Huh 
That's as close as I can get!
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.) Big Grin
Please visit my Website at: http://oldendayskids.blogspot.com/
Reply
#33
(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. Wink
Reply
#34
(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". Huh 
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.  Wink

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.)
Reply
#35
Thumbs Up 
(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. Wink

+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 + ...
Reply
#36
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

Reply
#37
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
Reply
#38
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 + ...
Reply
#39
You're getting the 2nd half of "alley cat" definition.

Which is why a look up list is better than a INSTR search.  Wink

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.
Reply
#40
that might work except for AA but who cares about that
;-))

I am starting to think the RA method wasn't too terrible Smile 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 + ...
Reply




Users browsing this thread: 2 Guest(s)