facebook / duckling

Language, engine, and tooling for expressing, testing, and evaluating composable language rules on input strings.
Other
4.05k stars 723 forks source link

Where can I define the date format of the data? #630

Open OrtalAshkenaziGong opened 3 years ago

OrtalAshkenaziGong commented 3 years ago

Is it possible to define in the API call or in the installation the date format for example mm/dd/yyyy? Thanks in advance, Ortal

chessai commented 3 years ago

Sorry, it's not clear to me what you mean? Can you elaborate?

OrtalAshkenaziGong commented 3 years ago

Dates can be ambiguous: For example, the following date 2021-01-11 can be interpreted as:

  1. 11 of January
  2. 1 of November Is there a way that I can indicate what is the expected date format in the text?

More details those the results I get from the following API calls: ‘locale=en_US&text=1/11/2021’ - > "value":"2021-01-11T00:00:00.000-08:00" ‘locale=en_US&text=11 of January 2021’ -> "value":"2021-01-11T00:00:00.000-08:00” 'locale=en_US&text=1 of November' -> "value":"2021-11-01T00:00:00.000-07:00"

From this, I can deduce that the date format Duckling is searching in the text is "%m/%d/%Y" and the date format in output in the JSON is "%d/%m/%Y". How can I control these formats? Thanks in advance, Ortal

chessai commented 3 years ago

This is not yet supported.

OrtalAshkenaziGong commented 3 years ago

Can you please tell me from where the date formats are taken today? Are they fixed ? are they taken from the machine locale?(locale -k LC_TIME) Thanks in advance, Ortal

chessai commented 3 years ago

Can you please tell me from where the date formats are taken today? Are they fixed ? are they taken from the machine locale?(locale -k LC_TIME) Thanks in advance, Ortal

For inputs, the format is inferred based on rules/training data. You can look in the values array in the output for possible other meanings (duckling returns a single value that it thinks the data resolves to, and then a number of other values that the data may also resolve to, but have lower confidence than the single returned value).

For outputs, the time is based on RFC 3339. See https://github.com/facebook/duckling/blob/3d2f1939ef0a5ceb856e4bfcfefbed0b03775d5c/Duckling/Time/Types.hs#L739