command text parsing and hints displaying on user input.

Andy icetortoise at
Mon Oct 16 09:19:17 CEST 2006

Hi guys,

I'm writing a program with a feature of accepting user input as command
text and parsing it to correct function calls...example:

"5 minutes later"/"5 min later"/"5 minute later"/"after 5 minutes"...
are being parsed as the same rule so the system will call a later
function with minutes=5 as parameter.

Of course there are many other possiblilities, "seconds"/"days", and
even "every(each) hour"/"every Monday"/"every two days" on...

The datetime computation can be done with the wonderful "dateutil"
package, but I'm not sure with the command text parsing part. I could
do a lot of regular expression, but it'll be great if there is already
something similar available...or even a hint that can make it easier
than hand-writing a lot of regular expression code...

Another requirment is to display useful hints when user input the
command text. Example:

user input:"5" -> hints: "5 minutes later/5 hours later/5 days
later/every 5 minutes"
user input:"fi" -> hints: "next Friday"/"first thing tommorrow"
user input:"ne" -> hints: "next day"/"next hour"/"next week"/"next

Sounds too intelligent to do? Any advices on this?

Thanks guys.


More information about the Python-list mailing list