Quantity/EN: Support k.g k.g. (#570)

Summary:
Adding . in between kilogram units used to be extracted as a Numeral
instead of Quantity.

Pull Request resolved: https://github.com/facebook/duckling/pull/570

Reviewed By: patapizza

Differential Revision: D26199687

Pulled By: chessai

fbshipit-source-id: 65e39f20296946d5762d7180b12878f4e66ea701
This commit is contained in:
Amr Keleg 2021-02-03 12:35:01 -08:00 committed by Facebook GitHub Bot
parent 496842d16a
commit e673ba5e84
2 changed files with 15 additions and 1 deletions

View File

@ -47,12 +47,18 @@ allExamples = concat
, examples (simple Gram 2 Nothing)
[ "2 grams"
, "0.002 kg"
, "2 g."
, "2 gs"
, "2/1000 kilograms"
, "2000 milligrams"
, "2,000 milligrams"
]
, examples (simple Gram 1000 Nothing)
[ "a kilogram"
, "a kg"
, "1 k.g."
, "1 k.gs"
, "1000 gs"
]
, examples (simple Pound 1 Nothing)
[ "a Pound"

View File

@ -33,7 +33,7 @@ import qualified Duckling.Quantity.Types as TQuantity
quantities :: [(Text, String, TQuantity.Unit)]
quantities =
[ ("<quantity> cups", "(cups?)", TQuantity.Cup)
, ("<quantity> grams", "(((m(illi)?)|(k(ilo)?))?g(ram)?s?)", TQuantity.Gram)
, ("<quantity> grams", "(((m(illi)?[.]?)|(k(ilo)?)[.]?)?g(ram)?s?[.]?)[.]?", TQuantity.Gram)
, ("<quantity> lb", "((lb|pound)s?)", TQuantity.Pound)
, ("<quantity> oz", "((ounces?)|oz)", TQuantity.Ounce)
]
@ -44,10 +44,18 @@ opsMap = HashMap.fromList
, ( "milligrams", (/ 1000))
, ( "mg" , (/ 1000))
, ( "mgs" , (/ 1000))
, ( "m.g" , (/ 1000))
, ( "m.gs" , (/ 1000))
, ( "m.g." , (/ 1000))
, ( "m.g.s" , (/ 1000))
, ( "kilogram" , (* 1000))
, ( "kilograms" , (* 1000))
, ( "kg" , (* 1000))
, ( "kgs" , (* 1000))
, ( "k.g" , (* 1000))
, ( "k.gs" , (* 1000))
, ( "k.g." , (* 1000))
, ( "k.g.s" , (* 1000))
]
ruleNumeralQuantities :: [Rule]