mirror of
https://github.com/facebook/duckling.git
synced 2024-09-11 21:27:13 +03:00
Duration/EN: Leverage TimeGrain for number.number hours
Summary: also kill redundant `isGrain` helper from `Time`. Reviewed By: dwhit, haoxuany Differential Revision: D18937649 fbshipit-source-id: ed658cc3bac70e6592dabae536a31a4c2da8a578
This commit is contained in:
parent
0ebaf378dc
commit
a6b7253aa4
@ -101,7 +101,8 @@ ruleDurationDotNumeralHours :: Rule
|
||||
ruleDurationDotNumeralHours = Rule
|
||||
{ name = "number.number hours"
|
||||
, pattern =
|
||||
[ regex "(\\d+)\\.(\\d+) *h((ou)?rs?)?"
|
||||
[ regex "(\\d+)\\.(\\d+)"
|
||||
, Predicate $ isGrain TG.Hour
|
||||
]
|
||||
, prod = \case
|
||||
(Token RegexMatch (GroupMatch (h:m:_)):_) -> do
|
||||
|
@ -17,6 +17,7 @@ import Data.Text (Text)
|
||||
import Prelude
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Ordinal.Types (OrdinalData (..))
|
||||
import Duckling.Time.Helpers
|
||||
|
@ -18,13 +18,14 @@ import Data.Text (Text)
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Ordinal.Types (OrdinalData (..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types (GroupMatch(..))
|
||||
import Duckling.Time.Computed
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.HolidayHelpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
import qualified Duckling.Time.Types as TTime
|
||||
|
@ -10,7 +10,8 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Time.EL.Rules
|
||||
( rules ) where
|
||||
( rules
|
||||
) where
|
||||
|
||||
import Data.HashMap.Strict (HashMap)
|
||||
import Data.Text (Text)
|
||||
@ -19,14 +20,14 @@ import qualified Data.HashMap.Strict as HashMap
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (duration)
|
||||
import Duckling.Duration.Types (DurationData (DurationData))
|
||||
import Duckling.Duration.Helpers (duration, isGrain)
|
||||
import Duckling.Duration.Types (DurationData(DurationData))
|
||||
import Duckling.Numeral.Helpers (parseInt, numeralMapEL)
|
||||
import Duckling.Numeral.Types (NumeralData (..))
|
||||
import Duckling.Ordinal.Types (OrdinalData (..), isBetween)
|
||||
import Duckling.Numeral.Types (NumeralData(..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..), isBetween)
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
|
@ -20,7 +20,7 @@ import Prelude
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (duration)
|
||||
import Duckling.Duration.Helpers (duration, isGrain)
|
||||
import Duckling.Duration.Types (DurationData (..))
|
||||
import Duckling.Numeral.Helpers (isNatural, parseInt)
|
||||
import Duckling.Numeral.Types (NumeralData (..))
|
||||
|
@ -10,17 +10,19 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Time.ES.Rules
|
||||
( rules ) where
|
||||
( rules
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Ordinal.Types (OrdinalData (..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
import qualified Duckling.Time.Types as TTime
|
||||
|
@ -10,18 +10,20 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Time.GA.Rules
|
||||
( rules ) where
|
||||
( rules
|
||||
) where
|
||||
|
||||
import Data.Text (Text)
|
||||
import Prelude
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import qualified Duckling.TimeGrain.Types as TG
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
import qualified Duckling.TimeGrain.Types as TG
|
||||
|
||||
ruleArInn :: Rule
|
||||
ruleArInn = Rule
|
||||
|
@ -9,7 +9,8 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Time.HE.Rules
|
||||
( rules ) where
|
||||
( rules
|
||||
) where
|
||||
|
||||
import Data.Maybe
|
||||
import Data.String
|
||||
@ -18,12 +19,13 @@ import Prelude
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Numeral.Types (NumeralData (..))
|
||||
import Duckling.Ordinal.Types (OrdinalData (..))
|
||||
import Duckling.Numeral.Types (NumeralData(..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
|
@ -19,12 +19,13 @@ import Prelude
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Numeral.Types (NumeralData (..))
|
||||
import Duckling.Ordinal.Types (OrdinalData (..))
|
||||
import Duckling.Numeral.Types (NumeralData(..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
|
@ -13,7 +13,7 @@ module Duckling.Time.Helpers
|
||||
( -- Patterns
|
||||
hasNoDirection, isADayOfWeek, isAMonth, isAnHourOfDay, isAPartOfDay
|
||||
, isATimeOfDay, isDurationGreaterThan, isDOMInteger, isDOMOrdinal, isDOMValue
|
||||
, isGrain, isGrainFinerThan, isGrainCoarserThan, isGrainOfTime
|
||||
, isGrainFinerThan, isGrainCoarserThan, isGrainOfTime
|
||||
, isIntegerBetween, isNotLatent , isOrdinalBetween, isMidnightOrNoon
|
||||
, isOkWithThisNext, sameGrain, hasTimezone, hasNoTimezone, today
|
||||
-- Production
|
||||
@ -267,10 +267,6 @@ shiftTimezone providedSeries pred1 =
|
||||
-- -----------------------------------------------------------------
|
||||
-- Patterns
|
||||
|
||||
isGrain :: TG.Grain -> Predicate
|
||||
isGrain value (Token TimeGrain grain) = grain == value
|
||||
isGrain _ _ = False
|
||||
|
||||
isGrainFinerThan :: TG.Grain -> Predicate
|
||||
isGrainFinerThan value (Token Time TimeData{TTime.timeGrain = g}) = g < value
|
||||
isGrainFinerThan _ _ = False
|
||||
|
@ -10,19 +10,21 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Time.IT.Rules
|
||||
( rules ) where
|
||||
( rules
|
||||
) where
|
||||
|
||||
import Data.Text (Text)
|
||||
import Prelude
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Numeral.Types (NumeralData(..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
|
@ -21,15 +21,15 @@ import Prelude
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (duration)
|
||||
import Duckling.Duration.Types (DurationData (..))
|
||||
import Duckling.Duration.Helpers (duration, isGrain)
|
||||
import Duckling.Duration.Types (DurationData(..))
|
||||
import Duckling.Numeral.Helpers (isNatural, parseInt)
|
||||
import Duckling.Numeral.Types (NumeralData (..))
|
||||
import Duckling.Ordinal.Types (OrdinalData (..))
|
||||
import Duckling.Numeral.Types (NumeralData(..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Computed
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Duration.Types as TDuration
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
|
@ -16,11 +16,12 @@ import Prelude
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Ordinal.Types (OrdinalData (..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
import qualified Duckling.Time.Types as TTime
|
||||
|
@ -10,17 +10,19 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Time.NB.Rules
|
||||
( rules ) where
|
||||
( rules
|
||||
) where
|
||||
|
||||
import Data.Text (Text)
|
||||
import Prelude
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Ordinal.Types (OrdinalData (..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Data.Text as Text
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
|
@ -18,14 +18,14 @@ import Prelude
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (duration)
|
||||
import Duckling.Duration.Helpers (duration, isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Numeral.Types (NumeralData (..))
|
||||
import Duckling.Ordinal.Types (OrdinalData (..))
|
||||
import Duckling.Numeral.Types (NumeralData(..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.HolidayHelpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
|
@ -10,17 +10,19 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Time.PL.Rules
|
||||
( rules ) where
|
||||
( rules
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Time.Computed
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
|
@ -18,15 +18,16 @@ import Prelude
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import Duckling.Ordinal.Types (OrdinalData (..))
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
import qualified Duckling.Time.Types as TTime
|
||||
import qualified Duckling.TimeGrain.Types as TG
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
|
||||
ruleSHourmintimeofday :: Rule
|
||||
ruleSHourmintimeofday = Rule
|
||||
|
@ -16,10 +16,11 @@ import Data.Text (Text)
|
||||
import Prelude
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Data.Text as Text
|
||||
import qualified Duckling.Time.Types as TTime
|
||||
|
@ -10,17 +10,19 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Time.SV.Rules
|
||||
( rules ) where
|
||||
( rules
|
||||
) where
|
||||
|
||||
import Data.Text (Text)
|
||||
import Prelude
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Ordinal.Types (OrdinalData (..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Data.Text as Text
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
|
@ -10,18 +10,20 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Time.UK.Rules
|
||||
( rules ) where
|
||||
( rules
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Ordinal.Types (OrdinalData (..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
import qualified Duckling.Time.Types as TTime
|
||||
|
@ -9,19 +9,21 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Time.VI.Rules
|
||||
( rules ) where
|
||||
( rules
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers (isGrain)
|
||||
import Duckling.Numeral.Helpers (parseInt)
|
||||
import Duckling.Numeral.Types (NumeralData(..))
|
||||
import Duckling.Ordinal.Types (OrdinalData(..))
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Time.Helpers
|
||||
import Duckling.Time.Types (TimeData (..))
|
||||
import Duckling.Time.Types (TimeData(..))
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
import qualified Duckling.Ordinal.Types as TOrdinal
|
||||
|
Loading…
Reference in New Issue
Block a user