mirror of
https://github.com/facebook/duckling.git
synced 2024-11-28 16:54:59 +03:00
Duration/RO: Fix for values above 20
Summary: Same as previous commits. Reviewed By: haoxuany Differential Revision: D8325566 fbshipit-source-id: d4f1ae57cabdbdf8149f0673e6b7832496c2c88c
This commit is contained in:
parent
567450beea
commit
bac1245f45
@ -38,6 +38,7 @@ allExamples = concat
|
|||||||
, examples (DurationData 45 Minute)
|
, examples (DurationData 45 Minute)
|
||||||
[ "trei sferturi de oră"
|
[ "trei sferturi de oră"
|
||||||
, "45min"
|
, "45min"
|
||||||
|
, "45 de minute"
|
||||||
]
|
]
|
||||||
, examples (DurationData 12 Week)
|
, examples (DurationData 12 Week)
|
||||||
[ "doișpe saptamanile"
|
[ "doișpe saptamanile"
|
||||||
|
@ -7,18 +7,22 @@
|
|||||||
|
|
||||||
|
|
||||||
{-# LANGUAGE GADTs #-}
|
{-# LANGUAGE GADTs #-}
|
||||||
|
{-# LANGUAGE LambdaCase #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module Duckling.Duration.RO.Rules
|
module Duckling.Duration.RO.Rules
|
||||||
( rules ) where
|
( rules
|
||||||
|
) where
|
||||||
|
|
||||||
import Prelude
|
|
||||||
import Data.String
|
import Data.String
|
||||||
|
import Prelude
|
||||||
|
|
||||||
import Duckling.Dimensions.Types
|
import Duckling.Dimensions.Types
|
||||||
import Duckling.Duration.Helpers
|
import Duckling.Duration.Helpers
|
||||||
import qualified Duckling.TimeGrain.Types as TG
|
import Duckling.Numeral.Helpers (numberWith)
|
||||||
import Duckling.Types
|
import Duckling.Types
|
||||||
|
import qualified Duckling.Numeral.Types as TNumeral
|
||||||
|
import qualified Duckling.TimeGrain.Types as TG
|
||||||
|
|
||||||
ruleQuarterOfAnHour :: Rule
|
ruleQuarterOfAnHour :: Rule
|
||||||
ruleQuarterOfAnHour = Rule
|
ruleQuarterOfAnHour = Rule
|
||||||
@ -54,7 +58,7 @@ ruleOUnitofduration = Rule
|
|||||||
[ regex "o|un"
|
[ regex "o|un"
|
||||||
, dimension TimeGrain
|
, dimension TimeGrain
|
||||||
]
|
]
|
||||||
, prod = \tokens -> case tokens of
|
, prod = \case
|
||||||
(_:Token TimeGrain grain:_) -> Just . Token Duration $ duration grain 1
|
(_:Token TimeGrain grain:_) -> Just . Token Duration $ duration grain 1
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
}
|
}
|
||||||
@ -66,11 +70,27 @@ ruleExactInJurDeDuration = Rule
|
|||||||
[ regex "(exact|aproximativ|(i|î)n jur de)"
|
[ regex "(exact|aproximativ|(i|î)n jur de)"
|
||||||
, dimension Duration
|
, dimension Duration
|
||||||
]
|
]
|
||||||
, prod = \tokens -> case tokens of
|
, prod = \case
|
||||||
(_:token:_) -> Just token
|
(_:token:_) -> Just token
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ruleIntegerDeUnitofduration :: Rule
|
||||||
|
ruleIntegerDeUnitofduration = Rule
|
||||||
|
{ name = "<integer> <unit-of-duration>"
|
||||||
|
, pattern =
|
||||||
|
[ numberWith TNumeral.value (>= 20)
|
||||||
|
, regex "de"
|
||||||
|
, dimension TimeGrain
|
||||||
|
]
|
||||||
|
, prod = \case
|
||||||
|
(Token Numeral TNumeral.NumeralData{TNumeral.value = v}:
|
||||||
|
_:
|
||||||
|
Token TimeGrain grain:
|
||||||
|
_) -> Just . Token Duration . duration grain $ floor v
|
||||||
|
_ -> Nothing
|
||||||
|
}
|
||||||
|
|
||||||
rules :: [Rule]
|
rules :: [Rule]
|
||||||
rules =
|
rules =
|
||||||
[ ruleExactInJurDeDuration
|
[ ruleExactInJurDeDuration
|
||||||
@ -78,4 +98,5 @@ rules =
|
|||||||
, ruleOUnitofduration
|
, ruleOUnitofduration
|
||||||
, ruleQuarterOfAnHour
|
, ruleQuarterOfAnHour
|
||||||
, ruleTreiSferturiDeOra
|
, ruleTreiSferturiDeOra
|
||||||
|
, ruleIntegerDeUnitofduration
|
||||||
]
|
]
|
||||||
|
@ -10,15 +10,16 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module Duckling.TimeGrain.RO.Rules
|
module Duckling.TimeGrain.RO.Rules
|
||||||
( rules ) where
|
( rules
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Data.String
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import Prelude
|
import Prelude
|
||||||
import Data.String
|
|
||||||
|
|
||||||
import Duckling.Dimensions.Types
|
import Duckling.Dimensions.Types
|
||||||
import qualified Duckling.TimeGrain.Types as TG
|
|
||||||
import Duckling.Types
|
import Duckling.Types
|
||||||
|
import qualified Duckling.TimeGrain.Types as TG
|
||||||
|
|
||||||
grains :: [(Text, String, TG.Grain)]
|
grains :: [(Text, String, TG.Grain)]
|
||||||
grains = [ ("secunde (grain)", "sec(und(a|e|ă))?", TG.Second)
|
grains = [ ("secunde (grain)", "sec(und(a|e|ă))?", TG.Second)
|
||||||
|
Loading…
Reference in New Issue
Block a user