Skip to main content

A demo package for converting numbers to french words.

Project description

juskata

A demo package for converting numbers to french words.

Installation

$ pip install juskata

Usage

juskata provides a class Num2Words that can be used to convert numbers to words. The class takes a single argument lang which specifies the language style to use - either "FR" for French or "BE" for Belgium-style French.

Right now, only integer numbers within the range 0-999 999 are supported.

There are two methods available in the class:

  • convert_num(num: int) -> str: Converts a number to words.
  • convert_num_list(num_list: List[int]) -> List[str]: Converts a list of numbers to a list of words.
from juskata import Num2Words

# initialize the class
n2w_fr = Num2Words(lang="FR")

# convert a number to words
print(n2w_fr.convert_num(17))  # dix-sept
print(n2w_fr.convert_num(80))  # quatre-vingts
print(n2w_fr.convert_num(180000))  # cent-quatre-vingt-milles

# convert a list of numbers to words
n2w_fr.convert_num_list([17, 80, 180000])  # ['dix-sept', 'quatre-vingts' 'cent-quatre-vingt-milles']


# initialize the class for Belgium-style French
n2w_be = Num2Words(lang="BE")

# convert a number to words
print(n2w_be.convert_num(17))  # dix-sept
print(n2w_be.convert_num(80))  # quatre-vingts
print(n2w_be.convert_num(180000))  # cent-quatre-vingt-milles

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

juskata was created by oceanumeric. It is licensed under the terms of the MIT license.

Credits

juskata was created with cookiecutter and the py-pkgs-cookiecutter project template.

During the development of this package, I found the following resources helpful:

Almost all the code mentioned above used recursion to certain extent. However, I found my implementation to be more readable and easier to understand. The above implementations also have bugs in the conversion of numbers to words.

Acknowledgements

Since I am not native French speaker, I had to rely on the internet to understand the French number system. I found the following resources helpful:

  • Conversion d'un chiffre en toutes lettres
    • I used this website to verify the conversion of numbers to words and generate text for doing unit tests.
  • Github Copilot was used to generate some of the code snippets in the implementation
    • Copilot was not very helpful for giving the correct implementation of the conversion of numbers to words.
    • However, it was helpful in generating the boilerplate code for the package, such as unit tests, and writing the README.md file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

juskata-0.1.0.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

juskata-0.1.0-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page