Latest in Devjuice

Image credit:

DevJuice: Spellchecking short strings

Erica Sadun, @ericasadun
March 4, 2013
Share
Tweet
Share

Sponsored Links

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.
Comment
Comments
Share
Tweet
Share

Popular on Engadget

Put Bernie Sanders almost anywhere with this Google Street View app

Put Bernie Sanders almost anywhere with this Google Street View app

View
Cadillac's upcoming Celestiq flagship EV has a tint-shifting smart roof | Engadget

Cadillac's upcoming Celestiq flagship EV has a tint-shifting smart roof | Engadget

View
Microsoft increases Xbox Live Gold prices for new members

Microsoft increases Xbox Live Gold prices for new members

View
The Morning After: The Galaxy S21 reviews are in

The Morning After: The Galaxy S21 reviews are in

View
President Biden appoints 'world-class' cybersecurity team in wake of hacks

President Biden appoints 'world-class' cybersecurity team in wake of hacks

View

From around the web

Page 1Page 1ear iconeye iconFill 23text filevr