More spell check questions

robphelan

Diamond Member
Aug 28, 2003
4,084
17
81
thanks for the help in the previous thread. I'm using the Metaphone algorithm, and my spell check app is coming along pretty well.

I have another problem.

Let's say I misspell impractical as impratical.
The metaphone codes are:
impractical - IMPRKTKL
impratical - IMPRTKL

What I had been doing was finding the metaphone code for the misspelled word and searching for matches. If none found, I would take the first x - n characters and try to find a match.

So I would look for:
IMPRTKL* then
IMPRTK* then
IMPRT* etc... until I found some matches.

The problem is that the misspelling is in the middle of the word and it is a consonant - I would have to go all the way down to IMPR* which gives me a list of hundreds and hundreds of matches.

Other mid-word misspellings aren't a big issue because they don't change the sound of the word.

Someone mentioned in the other thread a mehtod of calculating the shortest path of changes from incorrect to correct word.

how does that work?

thanks for your help!
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
This site has everything you need to know about understanding and implementing the Levenshtein Distance algorithm. It's fairly straightforward once you understand the logic behind it.
 

robphelan

Diamond Member
Aug 28, 2003
4,084
17
81
thanks a lot for that link!

So it looks like I need to have my misspelled word (impratical) and a list of up to dozens of suggestions.

Calculate the LD and display the ones with the lowest results.

Sound about right?

My issue would be how to correctly return the suggestions using the metaphone algorithm..

I guess I could take the first few letters of my metaphone code and retrieve suggestions. Then take the last few letters of my metaphone code and retrieve suggestions for those.

From this result set, I guess I would run the LD algorithm and come up with the shortest distance - return the lowest 5 - 7 results to user?
 
Last edited: