9 Replies Latest reply on Mar 28, 2013 12:37 PM by Rothrock

# spell suggestion algorithm

Hi,

I would like to know is there option to have spell suggestion in as2.

• ###### 1. Re: spell suggestion algorithm

There is no built-in option.  It would be a fairly complicated thing to implement.

• ###### 2. Re: spell suggestion algorithm

Thanks for the response. I know there is no built-in option in as2. But is there any logic which can be used to achieve the same.

• ###### 3. Re: spell suggestion algorithm

As far as I know there is nothing written specifically for AS2 as an algorithm.  If you search Google using "spell checking algorithm" you will find some results that you might be able to resolve into AS2.

• ###### 4. Re: spell suggestion algorithm

i have check that one but nothing is helping. Is there any better way to compare value from array rather than using for loop.

It may not be a correct way, is there any way around to achieve the same. reason is array has 100000 words and looping is taking too long to complete..

function search(srchKeyWrd:String)

{

filter_arr = [];

for(var i=0; i<searchable_arr.length; i++)

{

var fst_str:String = searchable_arr[i].substr(0,srchKeyWrd.length);

var snd_str:String = srchKeyWrd.substr(0,srchKeyWrd.length);

if(fst_str.toLowerCase() == snd_str.toLowerCase())

{

filter_arr.push(searchable_arr[i]);

}

}

searchable_arr = [];

searchable_arr = filter_arr;

articlelisting(searchable_arr);

}

• ###### 5. Re: spell suggestion algorithm

One thing you might consider is to devise a way of extracting only the relevant portion of the array to loop thru.  For example, if the word begins with "a", then extract all of the words that begin with "a" and loop thru that alone rather than the entire 100,000 words.

• ###### 6. Re: spell suggestion algorithm

zYa, just now i figure it out and made the changes. from 30 to 2/3 secs i am getting the response. Sorry to bother you more.. Is there any way to fasten the process from 3 to less than a sec.

• ###### 7. Re: spell suggestion algorithm

If you consider to be your spellcheck a serious feature of your application, upgrade to AS3 and  have a look at Squiggly

• ###### 8. Re: spell suggestion algorithm

I have used this AS2 version: http://activeden.net/item/flash-spell-checker/23953?sso?WT.ac=search_item&WT.seg_1=search_ item&WT.z_author=dontangg

Here is an excellent tutorial on how to write a spell checker: http://norvig.com/spell-correct.html

It would be possible to use a bloom filter to quickly determine if a word is known word. It might let some incorrect words through, but it is an interesting idea:

http://www.jasondavies.com/bloomfilter/

http://theyougen.blogspot.com/2010/02/faster-spelling-corrector.html

• ###### 9. Re: spell suggestion algorithm

Also don't create an array use an object:

var myWords:Object={};

myWords["apple"]=true;

myWords["ax"]=true;

of course you wouldn't generally type them all out like that, you could do a loop that reads in all your words and makes them keys in your object. Then to test you would just do this:

var candidateWord:String="supercalifragilisticexpialidotious";

if(candidateWord in myWords){

// true means it is there

} else {

// false means it isn't there

}

Using an object is WAAAYYYY faster than looping through an array.