diff --git a/Duckling/Ranking/Classifiers/IT_XX.hs b/Duckling/Ranking/Classifiers/IT_XX.hs index b9981cbb7..a3408b084 100644 --- a/Duckling/Ranking/Classifiers/IT_XX.hs +++ b/Duckling/Ranking/Classifiers/IT_XX.hs @@ -327,10 +327,10 @@ classifiers unseen = -4.31748811353631, likelihoods = HashMap.fromList - [(" (latent time-of-day)", -0.9718605830289658), + [(" (latent time-of-day)", -0.9718605830289657), ("intersect by \"di\", \"della\", \"del\"", -3.20545280453606), ("day", -2.3581549441488563), ("Lunedi", -3.6109179126442243), - ("hour", -0.9718605830289658), + ("hour", -0.9718605830289657), ("two time tokens separated by `di`", -3.20545280453606), ("Domenica", -3.6109179126442243)], n = 33}}), diff --git a/Duckling/Temperature/EN/Corpus.hs b/Duckling/Temperature/EN/Corpus.hs index 0e9107c7f..9058ff7f9 100644 --- a/Duckling/Temperature/EN/Corpus.hs +++ b/Duckling/Temperature/EN/Corpus.hs @@ -25,16 +25,17 @@ allExamples = concat [ examples (simple Celsius 37) [ "37°C" , "37 ° celsius" + , "37 degrees C" , "37 degrees Celsius" , "thirty seven celsius" - , "37 degrees Celsius" - , "thirty seven celsius" + , "thirty seven Celsius" ] , examples (simple Fahrenheit 70) [ "70°F" , "70 ° Fahrenheit" , "70 degrees F" , "seventy Fahrenheit" + , "seventy fahrenheit" ] , examples (simple Fahrenheit 98.6) [ "98.6°F" @@ -52,6 +53,13 @@ allExamples = concat , "2 degrees below zero" , "2 below zero" ] + , examples (simple Kelvin 44) + [ "44°K" + , "44 kelvin" + , "44 kelvins" + , "fourty four kelvins" + , "44 kelvins" + ] , examples (between Degree (30, 40)) [ "between 30 and 40 degrees" , "from 30 degrees to 40 degrees" diff --git a/Duckling/Temperature/EN/Rules.hs b/Duckling/Temperature/EN/Rules.hs index 08653c2bb..175526a4c 100644 --- a/Duckling/Temperature/EN/Rules.hs +++ b/Duckling/Temperature/EN/Rules.hs @@ -62,6 +62,19 @@ ruleTemperatureFahrenheit = Rule _ -> Nothing } +ruleTemperatureKelvin :: Rule +ruleTemperatureKelvin = Rule + { name = " Kelvin" + , pattern = + [ Predicate $ isValueOnly True + , regex "k(elvin)?s?\\.?" + ] + , prod = \case + (Token Temperature td:_) -> Just . Token Temperature $ + withUnit TTemperature.Kelvin td + _ -> Nothing + } + ruleTemperatureBelowZero :: Rule ruleTemperatureBelowZero = Rule { name = " below zero" @@ -153,6 +166,7 @@ rules = [ ruleTemperatureDegrees , ruleTemperatureCelsius , ruleTemperatureFahrenheit + , ruleTemperatureKelvin , ruleTemperatureBelowZero , ruleIntervalBetween , ruleIntervalDash diff --git a/Duckling/Temperature/Types.hs b/Duckling/Temperature/Types.hs index 43ec337d8..2ded53660 100644 --- a/Duckling/Temperature/Types.hs +++ b/Duckling/Temperature/Types.hs @@ -26,7 +26,7 @@ import qualified Data.Text as Text import Duckling.Resolve (Resolve(..)) data TemperatureUnit = - Degree | Celsius | Fahrenheit + Degree | Celsius | Fahrenheit | Kelvin deriving (Eq, Generic, Hashable, Show, Ord, NFData) instance ToJSON TemperatureUnit where