Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 12 commits into from Aug 3, 2022

Conversation

gonsalet
Copy link
Contributor

@gonsalet gonsalet commented Feb 16, 2022

Fixes #444, #449 by gonsalet

Changes proposed in this pull request:

  • 'lang_ES.py':
    • orthography fixes: Added missing accents "dieciséis", "veintiún", "dólar", "dólares".
    • currency fixes:
      • Fixed pound cent names ("penny"->"penique", "pence"->"peniques").
      • Improved currency gender handling:
        • Separated handling of the genders of the "dollars" part and the "cents" part (each part can have its own gender).
        • Added handling for feminine hundred numbers ("doscientas libras", "trescientas libras"...).
        • Fix: Now "veintiuna", "treinta y una"... are used for feminine currencies, instead of "veintiún", "treinta y un"... (source: https://www.rae.es/dpd/una , section 2.2).
        • Added 'TRY' and 'ITL' to feminine currency list CURRENCIES_UNA.
        • Created feminine "cents" list CENTS_UNA.
      • Updated/fixed error messages in line with 'base.py'.
  • 'test_es.py':
    • Updated with the new correct accents "dieciséis", "veintiún", "dólar", "dólares".
    • Updated with the new correct penique/peniques names.
    • Updated feminine currency examples with correct forms ("una lira", "veintiuna liras", "ochenta y una liras", "trescientas cincuenta liras").
    • Added test covering specifically new fix penny->penique.
    • Added test covering specifically new feminine "cents" handling (81.21, 'ochenta y una libras con veintiuna piastras').
    • All other code changes are already covered in existing tests.
  • 'bin/num2words': Fixed accent in Spanish examples ("centimos"->"céntimos"), thus making the example consistent with actual current behaviour (not affected by this pull request).
  • 'README.rst': Fixed accent in Spanish command line examples ("centimos"->"céntimos"), thus making the example consistent with actual current behaviour (not affected by this pull request).

Status

  • READY
  • [] HOLD
  • [] WIP (Work-In-Progress)

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 #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 and others added 6 commits February 16, 2022 17:09
…es); fixed accents in test_es.py (dieciséis, dólar, dólares, veintiún)
Fixed:
./num2words/lang_ES.py:366:56: E261 at least two spaces before inline comment
./num2words/lang_ES.py:366:80: E501 line too long (100 > 79 characters)
@gonsalet
Copy link
Contributor Author

gonsalet commented Feb 21, 2022

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
Copy link
Collaborator

erozqba commented Mar 5, 2022

@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. 😭

@gonsalet
Copy link
Contributor Author

gonsalet commented Mar 5, 2022

Thanks @erozqba!

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

@gonsalet
Copy link
Contributor Author

gonsalet commented Mar 5, 2022

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

Fixed accent in Spanish examples ("centimos"->"céntimos"), thus making the example consistent with actual current behaviour.
@gonsalet
Copy link
Contributor Author

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

Fixed accent in Spanish command line examples ("centimos"->"céntimos"), thus making the example consistent with actual current behaviour.
@gonsalet
Copy link
Contributor Author

gonsalet commented Mar 21, 2022

@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
Copy link
Contributor

@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

@gonsalet gonsalet changed the title [ES] Added missing accents ("dieciséis", "dólar", "dólares", "veintiún"), fixed pound cent names [ES] Added missing accents ("dieciséis", "dólar", "dólares", "veintiún"), improved currency gender handling, fixed pound cent names Mar 23, 2022
@coveralls
Copy link

Pull Request Test Coverage Report for Build 2698520765

  • 15 of 15 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.003%) to 96.289%

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

💛 - Coveralls

@mrodriguezg1991 mrodriguezg1991 merged commit 4d4ca04 into savoirfairelinux:master Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[es] Wrong orthography in Spanish: accents in "deciséis", "dólar", "dólares", "veintiún"
4 participants