2017-03-08 21:33:55 +03:00
|
|
|
-- 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. An additional grant
|
|
|
|
-- of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
|
|
|
|
|
|
|
|
{-# LANGUAGE GADTs #-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
|
|
|
module Duckling.Distance.Rules
|
|
|
|
( rules
|
|
|
|
) where
|
|
|
|
|
|
|
|
|
|
|
|
import Data.String
|
|
|
|
import Prelude
|
|
|
|
|
|
|
|
import Duckling.Dimensions.Types
|
|
|
|
import Duckling.Distance.Helpers
|
2017-03-16 23:42:15 +03:00
|
|
|
import Duckling.Numeral.Types (NumeralData (..))
|
|
|
|
import qualified Duckling.Numeral.Types as TNumeral
|
2017-03-08 21:33:55 +03:00
|
|
|
import Duckling.Types
|
|
|
|
|
2017-03-16 23:42:15 +03:00
|
|
|
ruleNumeralAsDistance :: Rule
|
|
|
|
ruleNumeralAsDistance = Rule
|
2017-03-08 21:33:55 +03:00
|
|
|
{ name = "number as distance"
|
|
|
|
, pattern =
|
2017-03-14 23:19:13 +03:00
|
|
|
[ dimension Numeral
|
2017-03-08 21:33:55 +03:00
|
|
|
]
|
|
|
|
, prod = \tokens -> case tokens of
|
2017-03-16 23:42:15 +03:00
|
|
|
(Token Numeral NumeralData {TNumeral.value = v}:_) ->
|
2017-03-08 21:33:55 +03:00
|
|
|
Just . Token Distance $ distance v
|
|
|
|
_ -> Nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
rules :: [Rule]
|
|
|
|
rules =
|
2017-03-16 23:42:15 +03:00
|
|
|
[ ruleNumeralAsDistance
|
2017-03-08 21:33:55 +03:00
|
|
|
]
|