Understanding Dates and Times in Natural Language
One of the more challenging aspects of understanding natural language is dealing with date and time expressions. There are many different ways a user could refer to a specific date and time. They might say "Next Tuesday at 4pm", they might give a specific date in any of several different forms, they might refer to other time ranges "First Tuesday in January 2012 at 4pm" etc.
Whilst my natural language engine can't understand every possible date time expression (e.g. the second Wednesday after the first Friday in May 2010) it does handle a huge variety.
Clearly the .NET provided DateTime class is wholly inadequate to express the kinds of date/time expressions your users might enter. To deal with that I've created my own classes that represent items like a specific Time of day, a DateTimeRange, a DateTimeRangeCollection, ...
TemporalSets are the most general result of parsing a datetime expression since they can represent any date time expression. Broadly they split into two categories: finite and infinite expressions. "Tuesday at 5pm" is an infinite time expression. "Tuesday at 5pm January 2012" is a finite time expression. Sometimes you will want to accept an infinite expression and interpret it as a future or past finite occurrence. For that I have a MergePreferPast and MergePreferFuture method that operate on a TemporalSetCollection. The demonstration code on BitBucketshows this in action.
TemporalSets also have unique capabilities around both providing query expressions (for database searches) and generative expressions (for adding dates to a calendar).
If you find any expressions that ought to work, please feel free to email or Tweet them to me.
Here's a sample session, you can try it out on nlp.abodit.com:
define june 23rd 2010 Absolute:[DATETIMERANGE 6/23/2010 at 12:00 AM to 6/23/2010 at 11:59 PM] define January 19th Future:[Thursday 1/19/2012], [Saturday 1/19/2013], [Sunday 1/19/2014], [Monday 1/19/2015], [Tuesday 1/19/2016], [Thursday 1/19/2017], [Friday 1/19/2018], [Saturday 1/19/2019], [Sunday 1/19/2020], [Tuesday 1/19/2021] Past: [Wednesday 1/19/2011] ...