facebook / facebook/duckling

[ES] Time interval is upper-bound inclusive

Open Beginner friendly
#658 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
4.3k
Forks
740
PR merge metrics
No merged PRs in 30d

Description

Consider the following test case: `de 14 a 16 hs` ("from 14 to 16" in English). The output is as follows:

```
de - (interval) (de 14 a 16)
-- regex (de)
-- time-of-day (latent) (14)
-- -- integer (numeric) (14)
-- -- -- regex (14)
-- regex (a)
-- time-of-day (latent) (16)
-- -- integer (numeric) (16)
-- -- -- regex (16)
[Entity {dim = "time", body = "de 14 a 16", value = RVal Time (TimeValue (IntervalValue (InstantValue {vValue = 2013-02-12 14:00:00 -0200, vGrain = Hour},InstantValue {vValue = 2013-02-12 16:00:00 -0200, vGrain = Hour})) [IntervalValue (InstantValue {vValue = 2013-02-12 14:00:00 -0200, vGrain = Hour},InstantValue {vValue = 2013-02-12 16:00:00 -0200, vGrain = Hour}),IntervalValue (InstantValue {vValue = 2013-02-13 14:00:00 -0200, vGrain = Hour},InstantValue {vValue = 2013-02-13 16:00:00 -0200, vGrain = Hour}),IntervalValue (InstantValue {vValue = 2013-02-14 14:00:00 -0200, vGrain = Hour},InstantValue {vValue = 2013-02-14 16:00:00 -0200, vGrain = Hour})] Nothing), start = 0, end = 10, latent = False, enode = Node {nodeRange = Range 0 10, token = Token Time TimeData{latent=False, grain=Hour, form=Nothing, direction=Nothing, holiday=Nothing, hasTimezone=False}, children = [Node {nodeRange = Range 0 2, token = Token RegexMatch (GroupMatch []), children = [], rule = Nothing},Node {nodeRange = Range 3 5, token = Token Time TimeData{latent=True, grain=Hour, form=Just (TimeOfDay {hours = Just 14, is12H = False}), direction=Nothing, holiday=Nothing, hasTimezone=False}, children = [Node {nodeRange = Range 3 5, token = Token Numeral (NumeralData {value = 14.0, grain = Nothing, multipliable = False, okForAnyTime = True}), children = [Node {nodeRange = Range 3 5, token = Token RegexMatch (GroupMatch ["14"]), children = [], rule = Nothing}], rule = Just "integer (numeric)"}], rule = Just "time-of-day (latent)"},Node {nodeRange = Range 6 7, token = Token RegexMatch (GroupMatch []), children = [], rule = Nothing},Node {nodeRange = Range 8 10, token = Token Time TimeData{latent=True, grain=Hour, form=Just (TimeOfDay {hours = Just 16, is12H = False}), direction=Nothing, holiday=Nothing, hasTimezone=False}, children = [Node {nodeRange = Range 8 10, token = Token Numeral (NumeralData {value = 16.0, grain = Nothing, multipliable = False, okForAnyTime = True}), children = [Node {nodeRange = Range 8 10, token = Token RegexMatch (GroupMatch ["16"]), children = [], rule = Nothing}], rule = Just "integer (numeric)"}], rule = Just "time-of-day (latent)"}], rule = Just "de - (interval)"}}]
```

As you can see, the output is `14:00 - 16:00`. The API states that the upper bound should be exclusive, that is `14:00 - 17:00`. Other languages return the correct result (EN, DE, etc.) but not in Spanish. The cause is that the time interval is defined as "Open":

https://github.com/facebook/duckling/blob/84175d61d6f44d0db2abb42d67c6c4213762b64f/Duckling/Time/ES/Rules.hs#L801-L814

For example, in English the interval is "Closed". This yields the correct result.

https://github.com/facebook/duckling/blob/84175d61d6f44d0db2abb42d67c6c4213762b64f/Duckling/Time/EN/Rules.hs#L1385-L1398

---

The fix requires changing the type of interval from "Open" to "Closed" and adjust the tests.

Contributor guide

Open the contributing guide

Research direction

Start in Duckling/Time/ES/Rules.hs at the Spanish interval rule linked in the issue, and compare it with the corresponding English rule in Duckling/Time/EN/Rules.hs. Locate the Spanish tests and adjust them as needed; done means the `de 14 a 16 hs` case uses an exclusive upper bound and the tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
localization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.