mirror of
https://github.com/facebook/duckling.git
synced 2024-11-28 08:34:46 +03:00
bf89e34365
Reviewed By: JoelMarcey Differential Revision: D15439223 fbshipit-source-id: c5af3cb06318748142fe503945b38beffadfc28a
51 lines
1.3 KiB
Haskell
51 lines
1.3 KiB
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.Volume.KO.Rules
|
|
( rules ) where
|
|
|
|
import Data.String
|
|
import Data.Text (Text)
|
|
import Prelude
|
|
|
|
import Duckling.Dimensions.Types
|
|
import Duckling.Types
|
|
import Duckling.Regex.Types
|
|
import Duckling.Volume.Helpers
|
|
import Duckling.Numeral.Helpers (isPositive)
|
|
import qualified Duckling.Volume.Types as TVolume
|
|
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
|
|
}
|
|
|
|
rules :: [Rule]
|
|
rules =
|
|
[
|
|
]
|
|
++ rulesVolumes
|