savoirfairelinux / num2words

Modules to convert numbers to words. 42 --> forty-two
GNU Lesser General Public License v2.1
820 stars 497 forks source link

[ES] Added missing accents ("dieciséis", "dólar", "dólares", "veintiún"), improved currency gender handling, fixed pound cent names #443

Closed gonsalet closed 2 years ago

gonsalet commented 2 years ago

Fixes https://github.com/savoirfairelinux/num2words/issues/444, https://github.com/savoirfairelinux/num2words/issues/449 by gonsalet

Changes proposed in this pull request:

Status

How to verify this change

>>> from num2words import num2words
>>> num2words('16', lang='es')
'dieciséis'
>>> num2words('1', lang='es', to='currency', currency='USD')
'un dólar con cero centavos'
>>> num2words('16', lang='es', to='currency', currency='USD')
'dieciséis dólares con cero centavos'
>>> num2words('21', lang='es', to='currency', currency='CAD')
'veintiún dólares con cero centavos'
>>> num2words('2.00', lang='es', to='currency', currency='GBP')
'dos libras con cero peniques'
>>> num2words('2.01', lang='es', to='currency', currency='GBP')
'dos libras con un penique'
>>> num2words('350.90', lang='es', to='currency', currency='GBP')
'trescientas cincuenta libras con noventa peniques'
>>> num2words('21.01', lang='es', to='currency', currency='TRY')
'veintiuna liras con un kuruş'
>>> num2words('21.01', lang='es', to='currency', currency='ITL')
'veintiuna liras con un céntimo'
>>> num2words('21.01', lang='es', to='currency', currency='EGP')
'veintiuna libras con una piastra'
>>> from num2words import num2words
>>> num2words('-12', to='ordinal', lang='es')
[...]
TypeError: El número negativo -12 no puede ser tratado como un ordinal.
>>> num2words('-12.3456', to='ordinal', lang='es')
[...]
TypeError: El float -12.3456 no puede ser tratado como un ordinal.
>>> num2words('100000000000000000000000000000000000000000000', lang='es')
[...]
OverflowError: abs(100000000000000000000000000000000000000000000) deber ser inferior a 1000000000000000000000000000.
$num2words --help
  num2words: convert numbers into words.
  [...]
  $num2words 2.14 -l es --to currency
  dos euros con catorce céntimos

Additional notes

This PR includes the fixes proposed in currently open pull request https://github.com/savoirfairelinux/num2words/pull/291 by @ekbrown

The added accents are the correct orthography. These words were not correct without the added accents. Orthography checked against official Diccionario de la lengua española ( https://dle.rae.es/ ).

The pound cents "penny" and "pence" were untranslated or inconsistently translated in several parts of the code. Checked that the correct "penique" and "peniques" are now used throughout.

Feminine currency handling is now correct, with independent handling of the "dollars" part and the "cents" part of the currency. Rules checked against official Diccionario panhispánico de dudas ( https://www.rae.es/dpd/una , section 2.2 ).

Pull request checklist General Can the branch be merged automatically? Yes. Testing Do the unit tests pass? Yes. Adding new code Is the code PEP8 compliant? Yes. Is the code covered by tests? Yes.

gonsalet commented 2 years ago

Hi @erozqba, I think this pull request would need a review but I'm not sure who to ask.

I think this is a small but useful fix for Spanish, since it fixes the orthography of a basic number (16, from "dieciseis" to "dieciséis"), along with a few other accent-related orthography fixes.

I've followed the steps in CONTRIBUTING, and I can take any additional steps I might have missed.

erozqba commented 2 years ago

@gonsalet I think your changes are good!

I don't know why the test and coveralls have not run and the new maintainers at Savoir Faire Linux removed me from the list of reviewers with write access, so I cannot approve your PR. :sob:

gonsalet commented 2 years ago

Thanks @erozqba!

I guess I'll try to contact Savoir Faire Linux to see if a current maintainer can check this.

gonsalet commented 2 years ago

@support-savoirfairelinux anyone who could review this pull request? Thanks!

gonsalet commented 2 years ago

@mromdhane anyone who could review this pull request? Thanks!

gonsalet commented 2 years ago

@mrodriguezg1991 anyone who could review this pull request? I guess there's a lot of maintenance to be done on this project, so I understand that this pull request might not be high priority, but I'm around in case this pull requires any additional steps. Thanks in any case!

mrodriguezg1991 commented 2 years ago

@gonsalet There are some issues with the CI to be able to merge new pull request, I am currently waiting for access in order to be able to maintain the project, as soon as all the issues are solved, i will be working on answering all requests. Thanks for your input on the project

coveralls commented 2 years ago

Pull Request Test Coverage Report for Build 2698520765


Totals Coverage Status
Change from base Build 2698290568: 0.003%
Covered Lines: 6704
Relevant Lines: 6887

💛 - Coveralls