diff --git a/Duckling/Temperature/RO/Corpus.hs b/Duckling/Temperature/RO/Corpus.hs index c2c9a2210..7208280fd 100644 --- a/Duckling/Temperature/RO/Corpus.hs +++ b/Duckling/Temperature/RO/Corpus.hs @@ -9,10 +9,11 @@ {-# LANGUAGE OverloadedStrings #-} module Duckling.Temperature.RO.Corpus - ( corpus ) where + ( corpus + ) where -import Prelude import Data.String +import Prelude import Duckling.Locale import Duckling.Resolve @@ -30,7 +31,9 @@ allExamples = concat , "37 grade Celsius" , "treizeci si sapte celsius" , "37 grade Celsius" + , "37 de grade de Celsius" , "treizeci si sapte celsius" + , "treizeci si sapte de celsius" ] , examples (simple Fahrenheit 70) [ "70°F" @@ -41,5 +44,6 @@ allExamples = concat , examples (simple Degree 45) [ "45°" , "45 grade" + , "45 de grade" ] ] diff --git a/Duckling/Temperature/RO/Rules.hs b/Duckling/Temperature/RO/Rules.hs index 800a9c7e2..850f36bc4 100644 --- a/Duckling/Temperature/RO/Rules.hs +++ b/Duckling/Temperature/RO/Rules.hs @@ -7,27 +7,29 @@ {-# LANGUAGE GADTs #-} +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} module Duckling.Temperature.RO.Rules - ( rules ) where + ( rules + ) where -import Prelude import Data.String +import Prelude import Duckling.Dimensions.Types import Duckling.Temperature.Helpers -import qualified Duckling.Temperature.Types as TTemperature import Duckling.Types +import qualified Duckling.Temperature.Types as TTemperature ruleLatentTempGrade :: Rule ruleLatentTempGrade = Rule { name = " grade" , pattern = [ Predicate $ isValueOnly False - , regex "(grade)|°" + , regex "(de )?(grade)|°" ] - , prod = \tokens -> case tokens of + , prod = \case (Token Temperature td:_) -> Just . Token Temperature $ withUnit TTemperature.Degree td _ -> Nothing @@ -38,9 +40,9 @@ ruleTempCelcius = Rule { name = " Celcius" , pattern = [ Predicate $ isValueOnly True - , regex "c(el[cs]?(ius)?)?\\.?" + , regex "(de )?c(el[cs]?(ius)?)?\\.?" ] - , prod = \tokens -> case tokens of + , prod = \case (Token Temperature td:_) -> Just . Token Temperature $ withUnit TTemperature.Celsius td _ -> Nothing @@ -51,9 +53,9 @@ ruleTempFahrenheit = Rule { name = " Fahrenheit" , pattern = [ Predicate $ isValueOnly True - , regex "f(ah?rh?eh?n(h?eit)?)?\\.?" + , regex "(de )?f(ah?rh?eh?n(h?eit)?)?\\.?" ] - , prod = \tokens -> case tokens of + , prod = \case (Token Temperature td:_) -> Just . Token Temperature $ withUnit TTemperature.Fahrenheit td _ -> Nothing