mirror of
https://github.com/facebook/duckling.git
synced 2024-12-02 22:46:17 +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)
|
||||
-- [ "1954"
|
||||
-- ]
|
||||
, examples (datetime (2013, 5, 1, 0, 0, 0) Month)
|
||||
[ "May"
|
||||
]
|
||||
, examples (datetimeInterval
|
||||
((2013, 2, 12, 4, 0, 0), (2013, 2, 12, 12, 0, 0)) Hour)
|
||||
[ "morning"
|
||||
|
@ -1198,19 +1198,19 @@ ruleDaysOfWeek = mkRuleDaysOfWeek
|
||||
]
|
||||
|
||||
ruleMonths :: [Rule]
|
||||
ruleMonths = mkRuleMonths
|
||||
[ ( "January" , "january|jan\\.?" )
|
||||
, ( "February" , "february|feb\\.?" )
|
||||
, ( "March" , "march|mar\\.?" )
|
||||
, ( "April" , "april|apr\\.?" )
|
||||
, ( "May" , "may" )
|
||||
, ( "June" , "june|jun\\.?" )
|
||||
, ( "July" , "july|jul\\.?" )
|
||||
, ( "August" , "august|aug\\.?" )
|
||||
, ( "September", "september|sept?\\.?" )
|
||||
, ( "October" , "october|oct\\.?" )
|
||||
, ( "November" , "november|nov\\.?" )
|
||||
, ( "December" , "december|dec\\.?" )
|
||||
ruleMonths = mkRuleMonthsWithLatent
|
||||
[ ( "January" , "january|jan\\.?" , False )
|
||||
, ( "February" , "february|feb\\.?" , False )
|
||||
, ( "March" , "march|mar\\.?" , False )
|
||||
, ( "April" , "april|apr\\.?" , False )
|
||||
, ( "May" , "may" , True )
|
||||
, ( "June" , "june|jun\\.?" , False )
|
||||
, ( "July" , "july|jul\\.?" , False )
|
||||
, ( "August" , "august|aug\\.?" , False )
|
||||
, ( "September", "september|sept?\\.?", False )
|
||||
, ( "October" , "october|oct\\.?" , False )
|
||||
, ( "November" , "november|nov\\.?" , False )
|
||||
, ( "December" , "december|dec\\.?" , False )
|
||||
]
|
||||
|
||||
rulePartOfMonth :: Rule
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
{-# LANGUAGE GADTs #-}
|
||||
{-# LANGUAGE NoRebindableSyntax #-}
|
||||
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
|
||||
module Duckling.Time.Helpers
|
||||
( -- Patterns
|
||||
@ -28,8 +28,8 @@ module Duckling.Time.Helpers
|
||||
-- Other
|
||||
, getIntValue, timeComputed
|
||||
-- Rule constructors
|
||||
, mkRuleInstants, mkRuleDaysOfWeek, mkRuleMonths, mkRuleSeasons
|
||||
, mkRuleHolidays, mkRuleHolidays'
|
||||
, mkRuleInstants, mkRuleDaysOfWeek, mkRuleMonths, mkRuleMonthsWithLatent
|
||||
, mkRuleSeasons, mkRuleHolidays, mkRuleHolidays'
|
||||
) where
|
||||
|
||||
import Data.Maybe
|
||||
@ -646,10 +646,14 @@ mkRuleDaysOfWeek daysOfWeek = zipWith go daysOfWeek [1..7]
|
||||
mkSingleRegexRule name ptn . tt . mkOkForThisNext $ dayOfWeek i
|
||||
|
||||
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
|
||||
go (name, ptn) i =
|
||||
mkSingleRegexRule name ptn . tt . mkOkForThisNext $ month i
|
||||
go (name, ptn, latent) i =
|
||||
mkSingleRegexRule name ptn . tt . (if latent then mkLatent else id)
|
||||
. mkOkForThisNext $ month i
|
||||
|
||||
mkRuleSeasons :: [(Text, String, TimeData, TimeData)] -> [Rule]
|
||||
mkRuleSeasons = map go
|
||||
|
Loading…
Reference in New Issue
Block a user