module Duckling.Temperature.KO.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
ruleLatentTempDegrees :: Rule
ruleLatentTempDegrees = Rule
{ name = "<latent temp> degrees"
, pattern =
[ Predicate isLatent
, regex "\xb3c4|\x00b0"
]
, prod = \tokens -> case tokens of
(Token Temperature td:_) -> Just . Token Temperature $
withUnit TTemperature.Degree td
_ -> Nothing
}
ruleTemp :: Rule
ruleTemp = Rule
{ name = "섭씨 <temp>"
, pattern =
[ regex "\xc12d\xc528"
, dimension Temperature
]
, prod = \tokens -> case tokens of
(_:Token Temperature td:_) -> Just . Token Temperature $
withUnit TTemperature.Celsius td
_ -> Nothing
}
ruleTempC :: Rule
ruleTempC = Rule
{ name = "<temp> °C"
, pattern =
[ dimension Temperature
, regex "c"
]
, prod = \tokens -> case tokens of
(Token Temperature td:_) -> Just . Token Temperature $
withUnit TTemperature.Celsius td
_ -> Nothing
}
ruleTemp2 :: Rule
ruleTemp2 = Rule
{ name = "화씨 <temp>"
, pattern =
[ regex "\xd654\xc528"
, dimension Temperature
]
, prod = \tokens -> case tokens of
(_:Token Temperature td:_) -> Just . Token Temperature $
withUnit TTemperature.Fahrenheit td
_ -> Nothing
}
ruleTempF :: Rule
ruleTempF = Rule
{ name = "<temp> °F"
, pattern =
[ dimension Temperature
, regex "f"
]
, prod = \tokens -> case tokens of
(Token Temperature td:_) -> Just . Token Temperature $
withUnit TTemperature.Fahrenheit td
_ -> Nothing
}
rules :: [Rule]
rules =
[ ruleLatentTempDegrees
, ruleTemp
, ruleTemp2
, ruleTempC
, ruleTempF
]