facebook/duckling

Making intervals 'inclusive - inclusive'

emlautarom1 opened this issue · 1 comments

I know that there are several questions related to how intervals are handled inclusive - exclusive. So far, I've found the following issues:

Nevertheless, I was wondering what would I need to change in the code to get the behavior inclusive - inclusive. As far as I understand, the reason of the current behavior is the following function:

timeInterval :: TimeIntervalType -> TimeObject -> TimeObject -> TimeObject
timeInterval
intervalType
TimeObject{start = s1, grain = g1}
TimeObject{start = s2, end = e2, grain = g2} = TimeObject
{ start = s1
, grain = g'
, end = Just $ case intervalType of
Open -> s2
Closed -> fromMaybe (TG.add s2 g2' 1) e2
}
where
g' = min g1 g2
g2'
| g1 < TG.Day && g2 < TG.Day = g'
| otherwise = g2

In particular, the line

Closed -> fromMaybe (TG.add s2 g2' 1) e2

Instead, if we did Closed -> fromMaybe s2 e2 we would effectively get the desired behavior - inclusive - inclusive.

Now, is this correct? Is there any other part of the code that assumes that intervals are inclusive - exclusive or is this change enough to make things work? I've tested it locally and, besides the fact that the whole test suit fails with mismatched predicates, the only issue is that some languages like Chinese have ambiguous parses.

I think you are correct wrt the code, but changing this would break essentially every user of duckling, so I'm not really in favour of changing it.