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:
- Ruby Implementation by GaspardPO
- Rust Implementation by Ballasi
- Python Implementation by savoirfairelinux
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 implementationCopilot
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file juskata-0.1.0.tar.gz
.
File metadata
- Download URL: juskata-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.10 Linux/5.15.0-46-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18a566ade2126831c4d1e85825b7c5e6ff60b377b5401d295c5d8613dffff772 |
|
MD5 | 2788a4215c8a90a60a06f202fe2503a2 |
|
BLAKE2b-256 | a13a6386ca4ab55a2ecf79851978ef93570660205862966a4869a2b555c0c22e |
File details
Details for the file juskata-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: juskata-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.10.10 Linux/5.15.0-46-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b406feefd58e8e251ba4353eb5a39b7b7731fd1370c4549f15cc78fa7c0ac384 |
|
MD5 | ecf358eec86a78f1371aaf4dc99a9075 |
|
BLAKE2b-256 | 8d8799f04aa9d5126234c34ddbd4b23377a6eaf83788547bbec7ab618ea3931f |