NL/amount-of-money (#504)

Summary:
Currently values like 1000.000 (in Dutch . is thousand separator) are not recognised, as the ruleDecimalWithThousandsSeparator requires the decimal part (e.g. 1000.000,34) to be present. This PR adds some data and changes the ruleDecimalWithThousandsSeparator to make the decimal part optional.

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

Reviewed By: patapizza, girifb

Differential Revision: D26078885

Pulled By: chessai

fbshipit-source-id: b1679c713e1d17a168d34a3cc556b6c36a571d75
This commit is contained in:
michaelmarien 2021-01-26 12:22:43 -08:00 committed by Facebook GitHub Bot
parent f2798021b6
commit 28ddc3bff7
3 changed files with 16 additions and 1 deletions

View File

@ -46,6 +46,8 @@ allExamples = concat
[ "$10K"
, "10k$"
, "$10000"
, "$10.000"
, "$10.000,00"
, "10000,00 $"
]
, examples (simple USD 3.14)

View File

@ -76,6 +76,14 @@ allExamples = concat
[ "0,77"
, ",77"
]
, examples (NumeralValue 100000)
[ "100.000"
, "100.000,0"
, "100000"
, "100K"
, "100k"
, "honderd duizend"
]
, examples (NumeralValue 300)
[ "3 honderd"
, "drie honderd"
@ -83,6 +91,8 @@ allExamples = concat
, examples (NumeralValue 5000)
[ "5 duizend"
, "vijf duizend"
, "5.000"
, "5.000,00"
]
, examples (NumeralValue 144)
[ "gros"
@ -94,6 +104,9 @@ allExamples = concat
]
, examples (NumeralValue 20000)
[ "twintig duizend"
, "20.000"
, "20000"
, "20.000,00"
]
, examples (NumeralValue 0.2)
[ "1/5"

View File

@ -62,7 +62,7 @@ ruleDecimalWithThousandsSeparator :: Rule
ruleDecimalWithThousandsSeparator = Rule
{ name = "decimal with thousands separator"
, pattern =
[ regex "(\\d+(\\.\\d\\d\\d)+,\\d+)"
[ regex "(\\d+(\\.\\d\\d\\d)+(,\\d+)?)"
]
, prod = \tokens -> case tokens of
(Token RegexMatch (GroupMatch (match:_)):