module Duckling.Temperature.RO.Rules
( rules ) where
import Prelude
import Data.String
import Duckling.Dimensions.Types
import Duckling.Temperature.Helpers
import qualified Duckling.Temperature.Types as TTemperature
import Duckling.Types
ruleLatentTempGrade :: Rule
ruleLatentTempGrade = Rule
{ name = "<latent temp> grade"
, pattern =
[ dimension Temperature
, regex "(grade)|°"
]
, prod = \tokens -> case tokens of
(Token Temperature td:_) -> Just . Token Temperature $
withUnit TTemperature.Degree td
_ -> Nothing
}
ruleTempCelcius :: Rule
ruleTempCelcius = Rule
{ name = "<temp> Celcius"
, pattern =
[ dimension Temperature
, regex "c(el[cs]?(ius)?)?\\.?"
]
, prod = \tokens -> case tokens of
(Token Temperature td:_) -> Just . Token Temperature $
withUnit TTemperature.Celsius td
_ -> Nothing
}
ruleTempFahrenheit :: Rule
ruleTempFahrenheit = Rule
{ name = "<temp> Fahrenheit"
, pattern =
[ dimension Temperature
, regex "f(ah?rh?eh?n(h?eit)?)?\\.?"
]
, prod = \tokens -> case tokens of
(Token Temperature td:_) -> Just . Token Temperature $
withUnit TTemperature.Fahrenheit td
_ -> Nothing
}
rules :: [Rule]
rules =
[ ruleLatentTempGrade
, ruleTempCelcius
, ruleTempFahrenheit
]