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
|
2019-05-22 20:36:43 +03:00
|
|
|
-- LICENSE file in the root directory of this source tree.
|
2017-03-08 21:33:55 +03:00
|
|
|
|
|
|
|
|
|
|
|
{-# LANGUAGE GADTs #-}
|
2018-08-24 21:17:30 +03:00
|
|
|
{-# LANGUAGE LambdaCase #-}
|
2017-03-08 21:33:55 +03:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
|
|
|
module Duckling.Volume.KO.Rules
|
|
|
|
( rules ) where
|
|
|
|
|
|
|
|
import Data.String
|
2018-08-24 21:17:30 +03:00
|
|
|
import Data.Text (Text)
|
|
|
|
import Prelude
|
2017-03-08 21:33:55 +03:00
|
|
|
|
|
|
|
import Duckling.Dimensions.Types
|
|
|
|
import Duckling.Types
|
2018-08-24 21:17:30 +03:00
|
|
|
import Duckling.Regex.Types
|
2017-03-08 21:33:55 +03:00
|
|
|
import Duckling.Volume.Helpers
|
2018-08-24 21:17:30 +03:00
|
|
|
import Duckling.Numeral.Helpers (isPositive)
|
2017-03-08 21:33:55 +03:00
|
|
|
import qualified Duckling.Volume.Types as TVolume
|
2018-08-24 21:17:30 +03:00
|
|
|
import qualified Duckling.Numeral.Types as TNumeral
|
|
|
|
|
|
|
|
volumes :: [(Text, String, TVolume.Unit)]
|
|
|
|
volumes = [ ("<latent vol> ml" , "ml|(밀|미)리리터" , TVolume.Millilitre)
|
|
|
|
, ("<vol> hectoliters" , "(핵|헥)토리터" , TVolume.Hectolitre)
|
|
|
|
, ("<vol> liters" , "(l|리터)" , TVolume.Litre)
|
|
|
|
, ("<latent vol> gallon", "gal(l?ons?)?|갤(런|론)" , TVolume.Gallon)
|
|
|
|
]
|
|
|
|
|
|
|
|
rulesVolumes :: [Rule]
|
|
|
|
rulesVolumes = map go volumes
|
|
|
|
where
|
|
|
|
go :: (Text, String, TVolume.Unit) -> Rule
|
|
|
|
go (name, regexPattern, u) = Rule
|
|
|
|
{ name = name
|
|
|
|
, pattern =
|
|
|
|
[ regex regexPattern
|
|
|
|
]
|
|
|
|
, prod = \_ -> Just . Token Volume $ unitOnly u
|
|
|
|
}
|
2017-03-08 21:33:55 +03:00
|
|
|
|
|
|
|
rules :: [Rule]
|
|
|
|
rules =
|
2018-08-24 21:17:30 +03:00
|
|
|
[
|
2017-03-08 21:33:55 +03:00
|
|
|
]
|
2018-08-24 21:17:30 +03:00
|
|
|
++ rulesVolumes
|