Louie
Louie

Reputation: 5940

Searching Array for similar spelled words/objects

I am looking for a solution similar to Google's "Did You Mean: Word"

I have an array of vehicles entered as

2011ChevroletMalibu
2011FordF150
2009FordProbe
etc...

In my app I have three Textfields.

Year Make Model .

When the user types in 2011 Chevrolet Malabu (notice that Malibu is misspelled) and hits search... Id like to reply "Did you mean: 2011 Chevrolet Malibu". Anyone have any suggestions on how to "search for similar"? Thanks!

Upvotes: 1

Views: 313

Answers (3)

Roberson Balbino
Roberson Balbino

Reputation: 397

Louie, I think it is not very simple. You need use some phonetic search. If your app use data provided by a webservice and you have a mssqlserver>=2000 behind this webservice, you can use SOUNDEX function in your searchs. But if you want, implement your own phonetic search, it is a big challenge.

Upvotes: 1

Till
Till

Reputation: 27597

AFAIK that is not any function the iOS SDK would solve for you - however, there are many algorithms available doing just that.

Look out for:

Phonetic Soundex String Comparison

Levenshtein Distance

Oliver 1993

Upvotes: 2

Stripes
Stripes

Reputation: 4229

Look at soundx "hashes" or if you have the CPU for it the levenshtein distance. Soundx will be cheaper to compute, the levenshtein distance will give better results.

Upvotes: 0

Related Questions