Assorted Afflatuses
Robots Are Idiots
With my vast quantities of free time and the release of Apple's Leopard operating system just around the corner, I thought I would revive my long abandoned effort to build a better piece of computerized recipe organization software.
At some point, as I was debugging a rather troublesome sheet, it struck me that the real coup de grâce of a recipe management program would be the ability to dump a bunch of text into a box and have the software parse it into a recipe. What began as a simple idea has now become a rather bothersome thorn in my side. Despite what some people may think, computers are extraordinarily stupid machines.
My first attempt to teach a computer to decipher a recipe involved a set of fairly simplistic rules, based mostly upon a crude analysis of the first characters on each line. As anyone who knows anything about programming would probably guess, such an approach is more or less useless. My simplistic approach did a fairly good job of parsing ingredients like, "1 cup flour," but it failed miserably when it came to the title, number of servings and just about every other point of data contained in a recipe.
So, I started to analyze recipes from a grammatical point of view, in the hope that I could somehow use grammatical differences and trends in recipes to parse them more effectively. I think I have now analyzed the grammatical differences in about five dozen recipes, and I have found a handful of interesting trends.
When I actually set about programming the parser to test my theories, however, I realized that I had no way to analyze grammar programatically. Sure, Apple added the "hasSuffix:" method to their lovely strings, but hasSuffix: cannot tell me how many words a string contains or whether the string is written in the past or present tense.
Fortunately, Apple has included a wonderful programming paradigm called the "category" in Objective-C. With it, even the most naive programmer can add methods to any existing class without creating a subclass of the class he or she would like to extend. It is absolutely brilliant. And, with any luck I should have some kind of parser working in the next week.
I did not enjoy watching The Wizard of Oz. And that horrible "Over the Rainbow" song tends to give me headaches. But I cannot possibly imagine life without a brain, like that poor scarecrow fellow. Trying to bestow the gift of logical deduction to an idiotic machine is exhaustingly painful.
Leave a comment