facebook / duckling

Language, engine, and tooling for expressing, testing, and evaluating composable language rules on input strings.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Time intervals are too large by one grain

noblepreplan opened this issue · comments

I'm seeing what appears to be some kind of bounding issue in Duckling when calling the API parse function. I'll fire off a request and get the expected response, except that the duration is too long. A few examples:

[{"body":"today 2PM to today 3PM","start":0,"value":{"values":[{"to":{"value":"2023-12-06T16:00:00.000-08:00","grain":"hour"},"from":{"value":"2023-12-06T14:00:00.000-08:00","grain":"hour"},"type":"interval"}],"to":{"value":"2023-12-06T16:00:00.000-08:00","grain":"hour"},"from":{"value":"2023-12-06T14:00:00.000-08:00","grain":"hour"},"type":"interval"},"end":22,"dim":"time","latent":false}]

[{"body":"today 4PM to today 4:30PM","start":0,"value":{"values":[{"to":{"value":"2023-12-06T16:31:00.000-08:00","grain":"minute"},"from":{"value":"2023-12-06T16:00:00.000-08:00","grain":"minute"},"type":"interval"}],"to":{"value":"2023-12-06T16:31:00.000-08:00","grain":"minute"},"from":{"value":"2023-12-06T16:00:00.000-08:00","grain":"minute"},"type":"interval"},"end":25,"dim":"time","latent":false}]

[{"body":"today 4PM to today 5:15PM","start":0,"value":{"values":[{"to":{"value":"2023-12-06T17:16:00.000-08:00","grain":"minute"},"from":{"value":"2023-12-06T16:00:00.000-08:00","grain":"minute"},"type":"interval"}],"to":{"value":"2023-12-06T17:16:00.000-08:00","grain":"minute"},"from":{"value":"2023-12-06T16:00:00.000-08:00","grain":"minute"},"type":"interval"},"end":25,"dim":"time","latent":false}]

In each case we can see that the duration is too long by the value of one grain, whether that be an extra hour or an extra minute. It's as if Duckling is inclusive on both ends of the duration and then uses a ceiling function to round it up. Maybe I'm missing a configuration option or an API option to prevent this behavior, but I'm not seeing anything outright. Is there something I can do to prevent this?

I'm also seeing this if I try to use "between 2PM and 3PM". I get a 2 hour block instead. The rules file for EN Time seems to indicate that this should be a closed interval if I'm reading it correctly, so we shouldn't be seeing the extra grain as it should be an exclusive endpoint.

duckling bounds are upper-exclusive. this is not a bug.