{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-}
module Duckling.Temperature.HR.Rules
( rules ) where
import Data.String
import Prelude
import Duckling.Dimensions.Types
import Duckling.Temperature.Helpers
import Duckling.Temperature.Types (TemperatureData (..))
import Duckling.Types
import qualified Duckling.Temperature.Types as TTemperature
ruleLatentTempStupnjevi :: Rule
ruleLatentTempStupnjevi :: Rule
ruleLatentTempStupnjevi = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<latent temp> stupnjevi"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Bool -> Predicate
isValueOnly Bool
False
, String -> PatternItem
regex String
"deg\\.?|stupa?nj((ev)?a)?|°"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Temperature a
td:[Token]
_) -> Token -> Maybe Token
forall a. a -> Maybe a
Just (Token -> Maybe Token)
-> (TemperatureData -> Token) -> TemperatureData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dimension TemperatureData -> TemperatureData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TemperatureData
Temperature (TemperatureData -> Maybe Token) -> TemperatureData -> Maybe Token
forall a b. (a -> b) -> a -> b
$
TemperatureUnit -> TemperatureData -> TemperatureData
withUnit TemperatureUnit
TTemperature.Degree a
TemperatureData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTempCelzij :: Rule
ruleTempCelzij :: Rule
ruleTempCelzij = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<temp> Celzij"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Bool -> Predicate
isValueOnly Bool
True
, String -> PatternItem
regex String
"c(elz?(ija?)?)?\\.?"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Temperature a
td:[Token]
_) -> Token -> Maybe Token
forall a. a -> Maybe a
Just (Token -> Maybe Token)
-> (TemperatureData -> Token) -> TemperatureData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dimension TemperatureData -> TemperatureData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TemperatureData
Temperature (TemperatureData -> Maybe Token) -> TemperatureData -> Maybe Token
forall a b. (a -> b) -> a -> b
$
TemperatureUnit -> TemperatureData -> TemperatureData
withUnit TemperatureUnit
TTemperature.Celsius a
TemperatureData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
ruleTempFahrenheit :: Rule
ruleTempFahrenheit :: Rule
ruleTempFahrenheit = Rule :: Text -> Pattern -> Production -> Rule
Rule
{ name :: Text
name = Text
"<temp> Fahrenheit"
, pattern :: Pattern
pattern =
[ Predicate -> PatternItem
Predicate (Predicate -> PatternItem) -> Predicate -> PatternItem
forall a b. (a -> b) -> a -> b
$ Bool -> Predicate
isValueOnly Bool
True
, String -> PatternItem
regex String
"f(ah?rh?eh?n(h?eit)?)?\\.?"
]
, prod :: Production
prod = \[Token]
tokens -> case [Token]
tokens of
(Token Dimension a
Temperature a
td:[Token]
_) -> Token -> Maybe Token
forall a. a -> Maybe a
Just (Token -> Maybe Token)
-> (TemperatureData -> Token) -> TemperatureData -> Maybe Token
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dimension TemperatureData -> TemperatureData -> Token
forall a.
(Resolve a, Eq a, Hashable a, Show a, NFData a) =>
Dimension a -> a -> Token
Token Dimension TemperatureData
Temperature (TemperatureData -> Maybe Token) -> TemperatureData -> Maybe Token
forall a b. (a -> b) -> a -> b
$
TemperatureUnit -> TemperatureData -> TemperatureData
withUnit TemperatureUnit
TTemperature.Fahrenheit a
TemperatureData
td
[Token]
_ -> Maybe Token
forall a. Maybe a
Nothing
}
rules :: [Rule]
rules :: [Rule]
rules =
[ Rule
ruleLatentTempStupnjevi
, Rule
ruleTempCelzij
, Rule
ruleTempFahrenheit
]