From 8a8f55700269192e691e03779c90861dceadef39 Mon Sep 17 00:00:00 2001 From: Amr Keleg Date: Wed, 7 Apr 2021 12:23:25 -0700 Subject: [PATCH] Add more variants of egp to EN and AR AmountOfMoney dimension (#590) Summary: These are popular variants/abbreviations of Egyptian pounds. All these forms are documented on wikipedia (https://en.wikipedia.org/wiki/Egyptian_pound) Pull Request resolved: https://github.com/facebook/duckling/pull/590 Reviewed By: haoxuany Differential Revision: D27598249 Pulled By: chessai fbshipit-source-id: 42ae9115b1def48c58e50a6deb624c3407c029f3 --- Duckling/AmountOfMoney/AR/Corpus.hs | 2 ++ Duckling/AmountOfMoney/AR/Rules.hs | 10 ++++++++++ Duckling/AmountOfMoney/EN/Corpus.hs | 6 ++++++ Duckling/AmountOfMoney/EN/Rules.hs | 20 ++++++++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/Duckling/AmountOfMoney/AR/Corpus.hs b/Duckling/AmountOfMoney/AR/Corpus.hs index fb3add06..378667c8 100644 --- a/Duckling/AmountOfMoney/AR/Corpus.hs +++ b/Duckling/AmountOfMoney/AR/Corpus.hs @@ -86,6 +86,8 @@ allExamples = concat [ "42 EGP" , "42 جنيه مصري" , "42 جنيهات مصريه" + , "42 ج.م" + , "42 ج.م." ] , examples (simple QAR 42) [ "42 QAR" diff --git a/Duckling/AmountOfMoney/AR/Rules.hs b/Duckling/AmountOfMoney/AR/Rules.hs index 5b5976db..a6d61f1a 100644 --- a/Duckling/AmountOfMoney/AR/Rules.hs +++ b/Duckling/AmountOfMoney/AR/Rules.hs @@ -51,6 +51,15 @@ rulePounds = Rule , prod = \_ -> Just . Token AmountOfMoney $ currencyOnly Pound } +ruleEgpAbrreviation :: Rule +ruleEgpAbrreviation = Rule + { name = "EGP abbreviation" + , pattern = + [ regex "ج[.]م[.]?" + ] + , prod = \_ -> Just . Token AmountOfMoney $ currencyOnly EGP + } + ruleDinars :: Rule ruleDinars = Rule { name = "dinars" @@ -390,6 +399,7 @@ rules = [ ruleUnitAmount , ruleCent , rulePounds + , ruleEgpAbrreviation , ruleDinars , ruleDirhams , ruleRiyals diff --git a/Duckling/AmountOfMoney/EN/Corpus.hs b/Duckling/AmountOfMoney/EN/Corpus.hs index af82f519..8751da8e 100644 --- a/Duckling/AmountOfMoney/EN/Corpus.hs +++ b/Duckling/AmountOfMoney/EN/Corpus.hs @@ -149,6 +149,12 @@ allExamples = concat , examples (simple EGP 42) [ "42 EGP" , "42 egyptianpound" + , "42 LE" + , "42 L.E" + , "42 l.e." + , "42 le" + , "42 geneh" + , "42 genihat masriya" ] , examples (simple QAR 42) [ "42 QAR" diff --git a/Duckling/AmountOfMoney/EN/Rules.hs b/Duckling/AmountOfMoney/EN/Rules.hs index 341edd9a..75cd7eff 100644 --- a/Duckling/AmountOfMoney/EN/Rules.hs +++ b/Duckling/AmountOfMoney/EN/Rules.hs @@ -65,6 +65,24 @@ ruleOtherPounds = Rule _ -> Nothing } +ruleEgpAbrreviation :: Rule +ruleEgpAbrreviation = Rule + { name = "livre égyptienne" + , pattern = + [ regex "[lL].?[eE].?" + ] + , prod = \_ -> Just . Token AmountOfMoney $ currencyOnly EGP + } + +ruleEgpArabizi :: Rule +ruleEgpArabizi = Rule + { name = "geneh" + , pattern = + [ regex "[Gg][eiy]*n[eiy]*h(at)?( m[aiey]?sr[eiy]+a?)?" + ] + , prod = \_ -> Just . Token AmountOfMoney $ currencyOnly EGP + } + ruleRiyals :: Rule ruleRiyals = Rule { name = "riyals" @@ -405,6 +423,8 @@ rules = , ruleIntervalDash , ruleKopiyka , ruleOtherPounds + , ruleEgpAbrreviation + , ruleEgpArabizi , rulePounds , rulePrecision , ruleRinggit