I am working on an application that I want to allow users to enter commands in natural language, eg:
Followup in two days
Followup on November 23rd at 3pm
Remind me about my dentist appointment at 3.30pm on December 12th 2008
Clearly there can be lots of subtle variations on what exactly gets entered in these sort of scenarios which makes for a potentially tricky/interesting problem.
Listening to a podcast recently, Joel Spolsky mentioned that people with no knowledge of compilers would tend to tackle a parsing problem like this the 'hard way' (ie using regexes, searching strings etc) while they may be better using a lexer/compiler approach. I have no knowledge of compilers, so my thinking right now is to scan for keywords and then things that look like dates using regexes.
Has anyone implemented anything that does this sort of this command processing and have any tips or tools to share? My application is in Rails, but I am willing to experiment - I just don't want to have many hundreds of lines of code testing for all sorts of strange conditions making for a brittle maintenance nightmare!
I have two ideas for alternatives that may or may not work, but at least have not been tried as often:
1. Autocomplete. When the user is typing, autocomplete his message, such that there is always 100% certainty that the command will be executed properly. Also, simplify the syntax, so I write 'remind' : 'December ...' : 'Dentist'. Your syntax has to be consistent, so once learned, there is no relearning. I don't want to have to figure out what the system wants me to type in as a command.
2. Visual. Use blocks and lines to create the actions. Humans have a very good sense of geometry and relationships between physical objects. Leverage that to make your app. Models of physical things are one of the few things we can actually say is inherently intuitive for human beings.