Question

I am trying to build an iOS application. In one of the screens the user can type something in a search bar and I have to take same action for different spellings of the same word.

For eg: User can type "elephant" or "alephant" or "elefant". I have to take same action for all these three words.

Is there any library that identifies these words as similar ones ? I cannot use spellchecker as I need this in languages other than english also .. I did some research and I found that there are some phonetic algorithms like Text::soundex for achieving this on server side. Wondering if any libraries there for iOS ?

Thanks in advance !!

Was it helpful?

Solution

A better alternative to Soundex would be Double Metaphone or, even better, Metaphone 3. You don't say what language you are using, but both of these algorithms are available in C++, C#, and Java

OTHER TIPS

There's no soundex available in for example NSString, but if that's what you want, it's fairly easy to implement. Here's a—albeit horribly formatted—soundex NSString category from CocoaDev.

You could also use the Levenstein Distance algorithm to catch simple spelling errors. Also easy to implement (read the Wikipedia article for the details), but here's a NSString category for that.

Before you use these algorithms, normalize the input. There's the amazing CFStringTransform class in Core Foundation (see this great article about it on NSHipster—especially the last part about normalization) that automatically can transform different language inputs into normalized forms.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top