Temporal Sets

By including a TemporalSet parameter as one of the parameters in a rule method you can ask AboditNLP to recognize a wide variety of temporal expressions. The result is however still ambiguous at this stage as Monday, for example, could mean last monday, next monday or every monday.

The context to decide which of these meanings to ascribe to the temporal set comes from your rule. A query for example typically involves the past so you would take the TemporalSet and call EnumerateBackward passing it the current time. A request to put a meeting on a calendar implies a future time so you would use EnumerateForward.

var backward = ts.EnumerateBackward(TimeProvider.Current.CalendarNow);

[Note the use of TimeProvider not DateTime.Now. TimeProvider allows for proper testing as you can substitute your own TimeProvider and set the time on it manually while testing.]

TemporalSets are either IFinite or IInfinite. The former can be enumerated without specifying a direction.

A TemporalSet is similar to an Expression tree in .NET. You can combine Temporal sets using Union, or intersect them using Intersect. If you intersect a infinite temporal set with a finite one you get a finite one. Infinite temporal sets can also be half-infinite (e.g. before a given point in time) or infinite in both directions. This allows some intersections of infinite temporal sets to become finite (e.g. before X and after Y).

During parsing the engine creates a TemporalExpression tree and then flattens any portions of it that it can simplify. Thus it can convert one week after two days before three days before today into a single calendar range.

In addition to the obvious times and dates, here are some examples of temporal expressions that the engine can handle:

    ""1970s""
    ""'70s""
    ""seventies""
    ""the 1970s""
    ""the '70s""
    ""the seventies""
    ""the first Sunday in may 2013""
    ""the Tuesday before last""
    ""Tuesday before last""
    ""the third Wednesday of this month""
    ""the first Sunday of this month""
    ""the first week in May 2013""
    ""three days before 3/1/2013""
    ""three days after 3/1/2013""
    ""three days before the first week in May 2013""
    ""October of 1963""
    ""this weekend""
    ""next weekend""
    ""last weekend""
    ""this year""
    ""last year""
    ""next year""
    ""today""
    ""tomorrow""
    ""the day after tomorrow""
    ""this saturday morning""
    ""Wednesday 2nd September 2015""
    ""Wednesday, 2nd September 2015""
    ""the 2nd Wednesday in September 2015""
    ""last friday""
    ""last friday night""
    ""next september""
    ""next October""
    ""last May""
    ""this July""

It can also handle relative expressions like:

    ""5 minutes ago""
    ""5 hours from now""
    ""in 5 secs""
    ""in 90 secs""
    ""90 seconds from now""
    ""90 seconds ago""
    ""in three days""
    ""in three days time""

And if you find a temporal expression it can't handle, send me an email and I'll get it added.