mirror of
https://github.com/facebook/duckling.git
synced 2024-11-28 08:34:46 +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)
|
||||
[ "trei sferturi de oră"
|
||||
, "45min"
|
||||
, "45 de minute"
|
||||
]
|
||||
, examples (DurationData 12 Week)
|
||||
[ "doișpe saptamanile"
|
||||
|
@ -7,18 +7,22 @@
|
||||
|
||||
|
||||
{-# LANGUAGE GADTs #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.Duration.RO.Rules
|
||||
( rules ) where
|
||||
( rules
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
import Data.String
|
||||
import Prelude
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Duration.Helpers
|
||||
import qualified Duckling.TimeGrain.Types as TG
|
||||
import Duckling.Numeral.Helpers (numberWith)
|
||||
import Duckling.Types
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
import qualified Duckling.TimeGrain.Types as TG
|
||||
|
||||
ruleQuarterOfAnHour :: Rule
|
||||
ruleQuarterOfAnHour = Rule
|
||||
@ -54,7 +58,7 @@ ruleOUnitofduration = Rule
|
||||
[ regex "o|un"
|
||||
, dimension TimeGrain
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
, prod = \case
|
||||
(_:Token TimeGrain grain:_) -> Just . Token Duration $ duration grain 1
|
||||
_ -> Nothing
|
||||
}
|
||||
@ -66,11 +70,27 @@ ruleExactInJurDeDuration = Rule
|
||||
[ regex "(exact|aproximativ|(i|î)n jur de)"
|
||||
, dimension Duration
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
, prod = \case
|
||||
(_:token:_) -> Just token
|
||||
_ -> 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 =
|
||||
[ ruleExactInJurDeDuration
|
||||
@ -78,4 +98,5 @@ rules =
|
||||
, ruleOUnitofduration
|
||||
, ruleQuarterOfAnHour
|
||||
, ruleTreiSferturiDeOra
|
||||
, ruleIntegerDeUnitofduration
|
||||
]
|
||||
|
@ -10,15 +10,16 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Duckling.TimeGrain.RO.Rules
|
||||
( rules ) where
|
||||
( rules
|
||||
) where
|
||||
|
||||
import Data.String
|
||||
import Data.Text (Text)
|
||||
import Prelude
|
||||
import Data.String
|
||||
|
||||
import Duckling.Dimensions.Types
|
||||
import qualified Duckling.TimeGrain.Types as TG
|
||||
import Duckling.Types
|
||||
import qualified Duckling.TimeGrain.Types as TG
|
||||
|
||||
grains :: [(Text, String, TG.Grain)]
|
||||
grains = [ ("secunde (grain)", "sec(und(a|e|ă))?", TG.Second)
|
||||
|
Loading…
Reference in New Issue
Block a user