DevJuice: Spellchecking short strings

Sponsored Links

DevJuice: Spellchecking short strings

A few years ago, xkcd created a crowd-sourced color survey to collected real-world hue descriptions. You'll find the hilarious results here.

I've been working on updating my UIColor utilities as part of building a color-sampling app. Stumbling across this survey, I decided to add the xkcd colors to my repository, along with code that matched colors to their nearest xkcd equivalents.

What I found is that as delightful as the sourced color descriptions are, that they were rather full of misspellings, for example "urple."

So I put together a simple NSString category to find misspellings and "creatively" described colors. I found this approach to be useful enough that I decided to share it on a DevJuice.

DevJuice Spellchecking short strings

Normally, you use text checkers to find misspellings in text view and fields, and to present those items to the user. But you're certainly not limited to that scenario. This simple string category lets you test whether a misspelled word was found, enabling me to automate my inspection.

I loaded up the xkcd names as an array and searched them to find any potential errors. Out of nearly a thousand color names, it quickly flagged about two dozen issues -- saving a huge amount of detail checking.

This doesn't of course, guarantee the correctness of my results. I know I left in a few amusing misspellings: "Blurple," for example, plus if any misspellings ended up as a legal English word, they will not have been flagged.

What's more, I had to bowdlerize some entries. Apple does not have any "offensive language" tester that I could find. (Know of one? Please ping me about it!) So I had to update those items by hand.

In any case, I hope you'll find this useful. Happy coding!

All products recommended by Engadget are selected by our editorial team, independent of our parent company. Some of our stories include affiliate links. If you buy something through one of these links, we may earn an affiliate commission.
Popular on Engadget