Extract time

It is currently possible to extract an absolute time ("August 11th 1999"), a relative time ("tomorrow"), an interval ("from 8am to noon") or a duration ("2 mins").

Dimension time

curl \
-X GET \
'https://api.botfuel.io/nlp/entity-extraction/v0'\
'?sentence=Now'\
'&dimensions=time'\
'&timezone=EST' \
-H "App-Id: $BOTFUEL_APP_ID" \
-H "App-Key: $BOTFUEL_APP_KEY"
// Response
[
  {
    "dim": "time",
    "body": "Now",
    "values": [
      {
        "type": "timestamp",
        "timestamp": "2018-05-17T05:47:21.000-05:00",
        "unit": "second",
        "milliseconds": 1526554041000
      }
    ],
    "start": 0,
    "end": 3
  }
]

When you want to extract data related to time, use the dimension time. To set a specific timezone, use the parameter timezone. Here is an example with the sentence 'Now'. We will use the 'EST' timezone (UTC -5).

Dimension time (intervals)

curl \
-X GET \
'https://api.botfuel.io/nlp/entity-extraction/v0'\
'?sentence=The+post+office+is+closed+on+the+last+Sunday'\
'+of+March+between+8am+and+noon'\
'&dimensions=time'\
'&timezone=EST' \
-H "App-Id: $BOTFUEL_APP_ID" \
-H "App-Key: $BOTFUEL_APP_KEY"
// Response
[
  {
    "dim": "time",
    "body": "last Sunday of March between 8am and noon",
    "values": [
      {
        "type": "interval",
        "from": {
          "time-stamp": "2018-03-25T08:00:00.000Z",
          "unit": "hour",
          "milliseconds": 1521964800000
        },
        "to": {
          "time-stamp": "2018-03-25T12:00:00.000Z",
          "unit": "hour",
          "milliseconds": 1521979200000
        }
      }
    ],
    "start": 22,
    "end": 63
  }
]

When two time entities are detected and they are boundaries of an interval of time, an interval entity is extracted. For instance, here is an example including a time interval:

The post office is closed on the last Sunday of March between 8am and noon

Dimension duration

curl -X GET 'https://api.botfuel.io/nlp/entity-extraction/v0'\
'?sentence=2+mins'\
'&dimensions=duration' \
-H "App-Id: $BOTFUEL_APP_ID" \
-H "App-Key: $BOTFUEL_APP_KEY"
[
  {
    "dim": "duration",
    "body": "2 mins",
    "values": [
      {
        "value": 2,
        "unit": "minute",
        "milliseconds": 120000
      }
    ],
    "start": 0,
    "end": 6
  }
]

A duration of time including units