duckling icon indicating copy to clipboard operation
duckling copied to clipboard

Utterance "winter 2020" not parsed correctly.

Open LucasLLC opened this issue 6 years ago • 3 comments

Utterance winter 2020 is broken down into two entities - winter and 2020. For all other seasons, the correct date range is returned (e.g. summer 2020, fall 2021, etc.).

Having a hard time finding the right rules to edit on this one. Assuming it has something to do with these lines:

ruleSeason :: Rule
ruleSeason = Rule
  { name = "last|this|next <season>"
  , pattern =
    [ regex "(this|current|next|last|past|previous) seasons?"
    ]
  , prod = \case
      (Token RegexMatch (GroupMatch (match:_)):_) -> do
        n <- case Text.toLower match of
               "this" -> Just 0
               "current" -> Just 0
               "last" -> Just (-1)
               "past" -> Just (-1)
               "previous" -> Just (-1)
               "next" -> Just 1
               _ -> Nothing
        tt $ predNth n False season
      _ -> Nothing
  }

ruleSeasons :: [Rule]
ruleSeasons = mkRuleSeasons
  [ ( "summer", "summer"     , monthDay  6 21, monthDay  9 23 )
  , ( "fall"  , "fall|autumn", monthDay  9 23, monthDay 12 21 )
  , ( "winter", "winter"     , monthDay 12 21, monthDay  3 20 )
  , ( "spring", "spring"     , monthDay  3 20, monthDay  6 21 )
  ]

in lines 956-982 of Duckling/Time/En/Rules.hs

LucasLLC avatar Jul 11 '18 20:07 LucasLLC

This is a pretty big one, it will affect all winter months beyond just EN. So far, I'm seeing duplicate behavior in ES, FR, RO, and PT (at least).

The root of the problem has to do with winter overlapping years, if I change the rules to have winter last from 12-21 to 12-30, we get the correct behavior, though I cannot tell why. Why would the time boundary for the rule affect whether or not we enter the intersection rule for a given language?

xtianjohns avatar Jul 20 '18 22:07 xtianjohns

I am facing the same issue. Can anyone help me in fixing it?

a2tm7a avatar Mar 30 '20 09:03 a2tm7a

Indeed @xtianjohns seems correct - there is some bug involving intersection when you cross year boundaries (at the very least). I investigated a bit yesterday, going to continue doing so now.

chessai avatar Jan 12 '21 21:01 chessai