diff --git a/Duckling/AmountOfMoney/EN/Corpus.hs b/Duckling/AmountOfMoney/EN/Corpus.hs index cac0419e..4d6fa930 100644 --- a/Duckling/AmountOfMoney/EN/Corpus.hs +++ b/Duckling/AmountOfMoney/EN/Corpus.hs @@ -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" + ] ] diff --git a/Duckling/AmountOfMoney/EN/Rules.hs b/Duckling/AmountOfMoney/EN/Rules.hs index ee9570cf..db18fcd2 100644 --- a/Duckling/AmountOfMoney/EN/Rules.hs +++ b/Duckling/AmountOfMoney/EN/Rules.hs @@ -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 ] diff --git a/Duckling/AmountOfMoney/Rules.hs b/Duckling/AmountOfMoney/Rules.hs index bb9538d2..10f6129e 100644 --- a/Duckling/AmountOfMoney/Rules.hs +++ b/Duckling/AmountOfMoney/Rules.hs @@ -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 diff --git a/Duckling/AmountOfMoney/Types.hs b/Duckling/AmountOfMoney/Types.hs index 6e01cc2c..dc8526a3 100644 --- a/Duckling/AmountOfMoney/Types.hs +++ b/Duckling/AmountOfMoney/Types.hs @@ -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"