mirror of
https://github.com/facebook/duckling.git
synced 2025-01-06 04:53:13 +03:00
Time/EN: Make "may" latent
Summary: Extended method for making months from a pair, to take a 3-tuple, including a flag indicating whether to make the result latent. Implement the previous mkRuleMonths method in terms of this. Reviewed By: patapizza Differential Revision: D7491037 fbshipit-source-id: 4d4c41b46dc0390e17b521480f3daf8306f23834
This commit is contained in:
parent
fe0807dced
commit
fd267ee80b
@ -118,6 +118,9 @@ latentCorpus = (testContext, testOptions {withLatent = True}, xs)
|
|||||||
--, examples (datetime (1954, 1, 1, 0, 0, 0) Year)
|
--, examples (datetime (1954, 1, 1, 0, 0, 0) Year)
|
||||||
-- [ "1954"
|
-- [ "1954"
|
||||||
-- ]
|
-- ]
|
||||||
|
, examples (datetime (2013, 5, 1, 0, 0, 0) Month)
|
||||||
|
[ "May"
|
||||||
|
]
|
||||||
, examples (datetimeInterval
|
, examples (datetimeInterval
|
||||||
((2013, 2, 12, 4, 0, 0), (2013, 2, 12, 12, 0, 0)) Hour)
|
((2013, 2, 12, 4, 0, 0), (2013, 2, 12, 12, 0, 0)) Hour)
|
||||||
[ "morning"
|
[ "morning"
|
||||||
|
@ -1198,19 +1198,19 @@ ruleDaysOfWeek = mkRuleDaysOfWeek
|
|||||||
]
|
]
|
||||||
|
|
||||||
ruleMonths :: [Rule]
|
ruleMonths :: [Rule]
|
||||||
ruleMonths = mkRuleMonths
|
ruleMonths = mkRuleMonthsWithLatent
|
||||||
[ ( "January" , "january|jan\\.?" )
|
[ ( "January" , "january|jan\\.?" , False )
|
||||||
, ( "February" , "february|feb\\.?" )
|
, ( "February" , "february|feb\\.?" , False )
|
||||||
, ( "March" , "march|mar\\.?" )
|
, ( "March" , "march|mar\\.?" , False )
|
||||||
, ( "April" , "april|apr\\.?" )
|
, ( "April" , "april|apr\\.?" , False )
|
||||||
, ( "May" , "may" )
|
, ( "May" , "may" , True )
|
||||||
, ( "June" , "june|jun\\.?" )
|
, ( "June" , "june|jun\\.?" , False )
|
||||||
, ( "July" , "july|jul\\.?" )
|
, ( "July" , "july|jul\\.?" , False )
|
||||||
, ( "August" , "august|aug\\.?" )
|
, ( "August" , "august|aug\\.?" , False )
|
||||||
, ( "September", "september|sept?\\.?" )
|
, ( "September", "september|sept?\\.?", False )
|
||||||
, ( "October" , "october|oct\\.?" )
|
, ( "October" , "october|oct\\.?" , False )
|
||||||
, ( "November" , "november|nov\\.?" )
|
, ( "November" , "november|nov\\.?" , False )
|
||||||
, ( "December" , "december|dec\\.?" )
|
, ( "December" , "december|dec\\.?" , False )
|
||||||
]
|
]
|
||||||
|
|
||||||
rulePartOfMonth :: Rule
|
rulePartOfMonth :: Rule
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
{-# LANGUAGE GADTs #-}
|
{-# LANGUAGE GADTs #-}
|
||||||
{-# LANGUAGE NoRebindableSyntax #-}
|
{-# LANGUAGE NoRebindableSyntax #-}
|
||||||
|
{-# LANGUAGE TupleSections #-}
|
||||||
|
|
||||||
module Duckling.Time.Helpers
|
module Duckling.Time.Helpers
|
||||||
( -- Patterns
|
( -- Patterns
|
||||||
@ -28,8 +28,8 @@ module Duckling.Time.Helpers
|
|||||||
-- Other
|
-- Other
|
||||||
, getIntValue, timeComputed
|
, getIntValue, timeComputed
|
||||||
-- Rule constructors
|
-- Rule constructors
|
||||||
, mkRuleInstants, mkRuleDaysOfWeek, mkRuleMonths, mkRuleSeasons
|
, mkRuleInstants, mkRuleDaysOfWeek, mkRuleMonths, mkRuleMonthsWithLatent
|
||||||
, mkRuleHolidays, mkRuleHolidays'
|
, mkRuleSeasons, mkRuleHolidays, mkRuleHolidays'
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
@ -646,10 +646,14 @@ mkRuleDaysOfWeek daysOfWeek = zipWith go daysOfWeek [1..7]
|
|||||||
mkSingleRegexRule name ptn . tt . mkOkForThisNext $ dayOfWeek i
|
mkSingleRegexRule name ptn . tt . mkOkForThisNext $ dayOfWeek i
|
||||||
|
|
||||||
mkRuleMonths :: [(Text, String)] -> [Rule]
|
mkRuleMonths :: [(Text, String)] -> [Rule]
|
||||||
mkRuleMonths months = zipWith go months [1..12]
|
mkRuleMonths = mkRuleMonthsWithLatent . map (uncurry (,, False))
|
||||||
|
|
||||||
|
mkRuleMonthsWithLatent :: [(Text, String, Bool)] -> [Rule]
|
||||||
|
mkRuleMonthsWithLatent months = zipWith go months [1..12]
|
||||||
where
|
where
|
||||||
go (name, ptn) i =
|
go (name, ptn, latent) i =
|
||||||
mkSingleRegexRule name ptn . tt . mkOkForThisNext $ month i
|
mkSingleRegexRule name ptn . tt . (if latent then mkLatent else id)
|
||||||
|
. mkOkForThisNext $ month i
|
||||||
|
|
||||||
mkRuleSeasons :: [(Text, String, TimeData, TimeData)] -> [Rule]
|
mkRuleSeasons :: [(Text, String, TimeData, TimeData)] -> [Rule]
|
||||||
mkRuleSeasons = map go
|
mkRuleSeasons = map go
|
||||||
|
Loading…
Reference in New Issue
Block a user