diff --git a/Duckling/Duration/RO/Corpus.hs b/Duckling/Duration/RO/Corpus.hs index 641e682e..a73b7e19 100644 --- a/Duckling/Duration/RO/Corpus.hs +++ b/Duckling/Duration/RO/Corpus.hs @@ -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" diff --git a/Duckling/Duration/RO/Rules.hs b/Duckling/Duration/RO/Rules.hs index 634fe163..5818ff1e 100644 --- a/Duckling/Duration/RO/Rules.hs +++ b/Duckling/Duration/RO/Rules.hs @@ -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 = " " + , 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 ] diff --git a/Duckling/TimeGrain/RO/Rules.hs b/Duckling/TimeGrain/RO/Rules.hs index 2be608ad..967bed9e 100644 --- a/Duckling/TimeGrain/RO/Rules.hs +++ b/Duckling/TimeGrain/RO/Rules.hs @@ -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)