duckling/Duckling/Temperature/Rules.hs
l5t de8af2395d EN/FR support temperature with decimal values (#408)
Summary:
Allowing the support of decimal values like in human body temperature. Example: 98.6°F
Pull Request resolved: https://github.com/facebook/duckling/pull/408

Reviewed By: girifb

Differential Revision: D17401806

Pulled By: patapizza

fbshipit-source-id: f04b768e2f6cb48c9c50977a5807d62e38f8d545
2019-09-17 10:34:25 -07:00

42 lines
954 B
Haskell

-- Copyright (c) 2016-present, Facebook, Inc.
-- All rights reserved.
--
-- This source code is licensed under the BSD-style license found in the
-- LICENSE file in the root directory of this source tree.
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
module Duckling.Temperature.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.Numeral.Types as TNumeral
import qualified Duckling.Temperature.Types as TTemperature
ruleNumeralAsTemp :: Rule
ruleNumeralAsTemp = Rule
{ name = "number as temp"
, pattern =
[ dimension Numeral
]
, prod = \case
(Token Numeral nd:_) ->
Just . Token Temperature $ valueOnly $ TNumeral.value nd
_ -> Nothing
}
rules :: [Rule]
rules =
[ ruleNumeralAsTemp
]