savoirfairelinux / num2words

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

Some tests in French (Belgium) are not correct. #532

Open Vincent-Stragier opened 1 year ago

Vincent-Stragier commented 1 year ago

French (Belgium) is a really complex with numbers and even as a native speaker, numbers are quite difficult to write correctly. I've been through the tests and some seem to be wrongs.

Some interesting references from Wikipedia (maybe not the most reliable sources, but at least they exist):

Big numbers names (in French) Numbers in French (in French)

Alternative (edit)

I'd really like this package to handle all the languages, but for the time being, I made my own package to handle all the French numbers. More information here: https://pypi.org/project/nombres-vers-lettres/. Feel free to open issues, or use it to improve this package (although my code is more spaghetti like, but it is also tested and linted).

The rest of the issue

Cardinal

https://github.com/savoirfairelinux/num2words/blob/872510dd8bfea767916067f60856fc9c360059fe/tests/test_fr_be.py#L28-L35

https://github.com/savoirfairelinux/num2words/blob/872510dd8bfea767916067f60856fc9c360059fe/tests/test_fr_be.py#L39-L40

The correct tests would be:

 (729, 'sept cent vingt-neuf'), 
 (894, 'huit cent nonante-quatre'), 
 (999, 'neuf cent nonante-neuf'), 
 (7232, 'sept mille deux cent trente-deux'), 
 (8569, 'huit mille cinq cent soixante-neuf'), 
 (9539, 'neuf mille cinq cent trente-neuf'), 
 (1000000, 'un million'), 
 (1000001, 'un million un'), 
 [...]
 (1000000000000000000, 'un trillion'), 
 (1000000000000000000000, 'un trilliard'), 

Ordinal

https://github.com/savoirfairelinux/num2words/blob/872510dd8bfea767916067f60856fc9c360059fe/tests/test_fr_be.py#L52-L54

The correct tests would be:

    (1000000,  'millionième'),
    (1000000000000000, 'billiardième'),
    (1000000000000000000, 'trillionième')  # over 1e18 is not supported

Also, you should test for (2000000, 'deux millionièmes'),, etc.

Currency EUR

https://github.com/savoirfairelinux/num2words/blob/872510dd8bfea767916067f60856fc9c360059fe/tests/test_fr_be.py#L58

https://github.com/savoirfairelinux/num2words/blob/872510dd8bfea767916067f60856fc9c360059fe/tests/test_fr_be.py#L64

The correct tests would be:

    (1.00, 'un euro et zéro centime'),
    [...]
    (100.00, 'cent euros et zéro centime'),

Currency FRF

https://github.com/savoirfairelinux/num2words/blob/872510dd8bfea767916067f60856fc9c360059fe/tests/test_fr_be.py#L58

https://github.com/savoirfairelinux/num2words/blob/872510dd8bfea767916067f60856fc9c360059fe/tests/test_fr_be.py#L64

The correct tests would be:

    (1.00, 'un franc et zéro centime'),
    [...]
    (100.00, 'cent francs et zéro centime'),