From 84e6322006191ad1acc142f5557a1e7c7caacd67 Mon Sep 17 00:00:00 2001 From: Cris140 <60457418+Cris140@users.noreply.github.com> Date: Thu, 28 Oct 2021 14:53:27 -0400 Subject: [PATCH 1/3] Update lang_PT_BR.py --- num2words/lang_PT_BR.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/num2words/lang_PT_BR.py b/num2words/lang_PT_BR.py index 80eb5e7..2c50f03 100644 --- a/num2words/lang_PT_BR.py +++ b/num2words/lang_PT_BR.py @@ -53,6 +53,8 @@ class Num2Word_PT_BR(lang_PT.Num2Word_PT): ctext = "cento" if nnum < cnum: + if cnum < 100: + return ("%s e %s" % (ctext, ntext), cnum + nnum) return ("%s e %s" % (ctext, ntext), cnum + nnum) elif (not nnum % 1000000) and cnum > 1: @@ -75,7 +77,7 @@ class Num2Word_PT_BR(lang_PT.Num2Word_PT): for ext in ( 'mil', 'milhão', 'milhões', 'bilhão', 'bilhões', 'trilhão', 'trilhões', 'quatrilhão', 'quatrilhões'): - if re.match('.*{} e \\w*ento'.format(ext), result): + if re.match('.*{} e \\w*entos? (?=.*e)'.format(ext), result): result = result.replace( '{} e'.format(ext), '{},'.format(ext), 1 ) From 74ba6ee3b38370853f4e24d5a5da8a8a898531c2 Mon Sep 17 00:00:00 2001 From: Daniel-EST Date: Fri, 28 Jan 2022 15:30:48 -0300 Subject: [PATCH 2/3] Fixes savoirfairelinux/num2words#435 --- num2words/lang_PT_BR.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/num2words/lang_PT_BR.py b/num2words/lang_PT_BR.py index 80eb5e7..82e7eb4 100644 --- a/num2words/lang_PT_BR.py +++ b/num2words/lang_PT_BR.py @@ -49,7 +49,7 @@ class Num2Word_PT_BR(lang_PT.Num2Word_PT): if nnum < 1000000: return next ctext = "um" - elif cnum == 100 and not nnum == 1000: + elif cnum == 100 and nnum % 1000 != 0: ctext = "cento" if nnum < cnum: From 31a250eb9035ca301a183f3e19be82516aa68890 Mon Sep 17 00:00:00 2001 From: Daniel-EST Date: Fri, 28 Jan 2022 15:31:41 -0300 Subject: [PATCH 3/3] Tests fix for issue #435 --- tests/test_pt_BR.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_pt_BR.py b/tests/test_pt_BR.py index bbf9e8d..87e231b 100644 --- a/tests/test_pt_BR.py +++ b/tests/test_pt_BR.py @@ -80,6 +80,12 @@ class Num2WordsPTBRTest(TestCase): self.assertEqual( num2words(6000000, lang='pt_BR'), 'seis milhões' ) + self.assertEqual( + num2words(100000000, lang='pt_BR'), 'cem milhões' + ) + self.assertEqual( + num2words(100000000000, lang='pt_BR'), 'cem bilhões' + ) self.assertEqual( num2words(19000000000, lang='pt_BR'), 'dezenove bilhões' )