Search code examples
date-rangeapi-ai

Date-period understands “before 2000” as [“2000-01-01/2000-12-31”]


I am building an api.ai agent, but I'm struggling to get unbounded date-period parameters understood correctly.

For example:

  • before 2000 is interpreted as ["2000-01-01/2000-12-31"]
  • after 1999 is interpreted as ["1999-01-01/1999-12-31"]
  • after January 2007 is interpreted as ["2007-01-01/2007-01-31"]

This makes me think only the date (2000/January 2007) is used for calculating the date-range, ignoring the adverb (before/after).

Is there a way to understand before 2000 as ["0000-01-01/2000-01-01"] (or at least ["1970-01-01/2000-12-31"] if Epoch-based)?


Solution

  • The before and after isn't matched, you are right.

    You can add a custom entity, like temporal preposition, to deal with this.

    before: prior to, previous to, earlier than, preparatory to, in preparation for, preliminary to, in anticipation of, in expectation of; in advance of, ahead of, leading up to

    after: following, subsequent to, succeeding, at the close/end of, in the wake of, later than

    You may create a composite entity (see in the docs). There you can compose the new preposition entity with the sys.date entity. So you will bound them together logically.