DevJuice: Spellchecking short strings
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.
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!
Subscribe to Newsletter
Software Updatesmore updates
- Fantastical 2.1 for iOS adds new snooze, search and notification features
- ExpanDrive 4, more services and faster sync
- Apple adds iTunes Extras to Apple TV
- Spotify updates with new iPhone controls in time for summer BBQs
- iTunes U update will bring course creation and student discussion to iPad app
- Dropbox for iOS update adds new setup and file management options