Spell Checker Search

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Spell Checker Search

Post by johnmiller1950 » Thu Nov 20, 2008 3:17 pm

Greetings,

I am developing a spell checker for a client. The dictionary word list that I have put together is over 100,000 words (1 word per line).

My script sets wholematches to true and then uses wordoffset(XX,YY) to see if the typed word is in my list of words.

If I check each word on the fly as I type, the search is plenty fast (3 ticks), however, when I use the same code to check each word in the whole field all at once, then I am looking at 3 ticks per word which gets pretty lengthy on a long text field.

I am not skilled at doing searches or setting up a word list to speed a search up. Is there a better way to do this?

Thanks!
John Miller

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Post by Garrett » Thu Nov 20, 2008 4:11 pm

I did a program once that searched a large dictionary file for rhyming words... I ran into a problem where it was slow because I was going line for line in a repeat loop.

Someone told me to do the following, and it was a huge... Huge speed increase!

Code: Select all

repeat for each line tLine in tData
  --do your stuff here
end repeat
tData being your full dictionary data. tLine would contain the data for a single line.

This sure beat my way of doing something like

Code: Select all

put the number of lines of tData into tLoopCounter
repeat tLoopCounter times
  --do stuff here
end repeat
Don't ask me why the "for each line" loop works faster.. I don't know, but it does.

~Garrett

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Thu Nov 20, 2008 5:16 pm

Hi John,

to increase speed you could split your word list into smaller lists that could e.g. start with the letter of the alphabet. All words of your 100000 words starting with A go into an A-list, and so on. That would speed things up and is relatively easy to implement.
If you want a faster way you could go for on or more (see above) arrays. There was a rev newsletter that uses that approach
that could speed up things considerably but is a little more involved. Though it might be a very good opportunity to look into arrays.
cheers
Bernd

Post Reply