mirror of
https://github.com/facebook/duckling.git
synced 2024-12-01 08:19:36 +03:00
Add myr
Summary: Add MYR(Malaysia currency) into amountOfMoney in EN. Closes https://github.com/facebookincubator/duckling/pull/40 Reviewed By: blandinw Differential Revision: D5218026 Pulled By: patapizza fbshipit-source-id: 5fd179e
This commit is contained in:
parent
cd3f3dd2f4
commit
c6c1330ed5
@ -110,4 +110,31 @@ allExamples = concat
|
||||
[ "42 SAR"
|
||||
, "42 Saudiriyal"
|
||||
]
|
||||
, examples (AmountOfMoneyValue MYR 42)
|
||||
[ "42 MYR"
|
||||
, "42 RM"
|
||||
, "RM 42"
|
||||
, "MYR 42"
|
||||
, "42MYR"
|
||||
, "42RM"
|
||||
, "RM42"
|
||||
, "MYR42"
|
||||
, "ringgit 42"
|
||||
, "42 ringgit"
|
||||
, "42 malaysia ringgit"
|
||||
, "malaysia ringgit 42"
|
||||
, "42 malaysian ringgit"
|
||||
, "malaysian ringgit 42"
|
||||
, "42 malaysia ringgits"
|
||||
, "malaysia ringgits 42"
|
||||
, "42 malaysian ringgits"
|
||||
, "malaysian ringgits 42"
|
||||
]
|
||||
, examples (AmountOfMoneyValue MYR 20.43)
|
||||
[ "20 ringgit and 43c"
|
||||
, "20 ringgit and 43 sen"
|
||||
, "twenty ringgit 43 sens"
|
||||
, "20 ringgit 43"
|
||||
, "twenty ringgit and 43"
|
||||
]
|
||||
]
|
||||
|
@ -85,11 +85,20 @@ ruleDirham = Rule
|
||||
, prod = \_ -> Just . Token AmountOfMoney $ currencyOnly AED
|
||||
}
|
||||
|
||||
ruleRinggit :: Rule
|
||||
ruleRinggit = Rule
|
||||
{ name = "ringgit"
|
||||
, pattern =
|
||||
[ regex "(malaysian? )?ringgits?"
|
||||
]
|
||||
, prod = \_ -> Just . Token AmountOfMoney $ currencyOnly MYR
|
||||
}
|
||||
|
||||
ruleCent :: Rule
|
||||
ruleCent = Rule
|
||||
{ name = "cent"
|
||||
, pattern =
|
||||
[ regex "cents?|penn(y|ies)|pence"
|
||||
[ regex "cents?|penn(y|ies)|pence|sens?"
|
||||
]
|
||||
, prod = \_ -> Just . Token AmountOfMoney $ currencyOnly Cent
|
||||
}
|
||||
@ -188,5 +197,6 @@ rules =
|
||||
, ruleOtherPounds
|
||||
, rulePounds
|
||||
, rulePrecision
|
||||
, ruleRinggit
|
||||
, ruleRiyals
|
||||
]
|
||||
|
@ -14,21 +14,21 @@ module Duckling.AmountOfMoney.Rules
|
||||
) where
|
||||
|
||||
import Data.HashMap.Strict (HashMap)
|
||||
import qualified Data.HashMap.Strict as HashMap
|
||||
import Data.Maybe
|
||||
import Data.String
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as Text
|
||||
import Prelude
|
||||
import qualified Data.HashMap.Strict as HashMap
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import Duckling.AmountOfMoney.Helpers
|
||||
import Duckling.AmountOfMoney.Types (Currency(..), AmountOfMoneyData (..))
|
||||
import qualified Duckling.AmountOfMoney.Types as TAmountOfMoney
|
||||
import Duckling.Dimensions.Types
|
||||
import Duckling.Numeral.Types (NumeralData (..))
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
import Duckling.Regex.Types
|
||||
import Duckling.Types
|
||||
import qualified Duckling.AmountOfMoney.Types as TAmountOfMoney
|
||||
import qualified Duckling.Numeral.Types as TNumeral
|
||||
|
||||
currencies :: HashMap Text Currency
|
||||
currencies = HashMap.fromList
|
||||
@ -64,6 +64,8 @@ currencies = HashMap.fromList
|
||||
, ("krw", KRW)
|
||||
, ("kwd", KWD)
|
||||
, ("lbp", LBP)
|
||||
, ("myr", MYR)
|
||||
, ("rm", MYR)
|
||||
, ("nok", NOK)
|
||||
, ("\x00a3", Pound)
|
||||
, ("pt", PTS)
|
||||
@ -84,7 +86,7 @@ ruleCurrencies :: Rule
|
||||
ruleCurrencies = Rule
|
||||
{ name = "currencies"
|
||||
, pattern =
|
||||
[ regex "(aed|aud|brl|\x00a2|c|\\$|dollars?|egp|(e|\x20ac)uro?s?|\x20ac|gbp|hrk|idr|inr|\x00a5|jpy|krw|kwd|lbp|nok|\x00a3|pta?s?|qar|rs\\.?|ron|rupees?|sar|sek|sgb|us(d|\\$)|vnd|yen)"
|
||||
[ regex "(aed|aud|brl|\x00a2|c|\\$|dollars?|egp|(e|\x20ac)uro?s?|\x20ac|gbp|hrk|idr|inr|\x00a5|jpy|krw|kwd|lbp|myr|rm|nok|\x00a3|pta?s?|qar|rs\\.?|ron|rupees?|sar|sek|sgb|us(d|\\$)|vnd|yen)"
|
||||
]
|
||||
, prod = \tokens -> case tokens of
|
||||
(Token RegexMatch (GroupMatch (match:_)):_) -> do
|
||||
|
@ -44,6 +44,7 @@ data Currency
|
||||
| KRW
|
||||
| KWD
|
||||
| LBP
|
||||
| MYR
|
||||
| NOK
|
||||
| PTS
|
||||
| QAR
|
||||
@ -73,6 +74,7 @@ instance ToJSON Currency where
|
||||
toJSON KRW = "KRW"
|
||||
toJSON KWD = "KWD"
|
||||
toJSON LBP = "LBP"
|
||||
toJSON MYR = "MYR"
|
||||
toJSON NOK = "NOK"
|
||||
toJSON PTS = "PTS"
|
||||
toJSON QAR = "QAR"
|
||||
|
Loading…
Reference in New Issue
Block a user