A package to convert numbers to words and vice-versa
Project description
Number Word Converter
A Python library for converting numbers to words and vice versa. Supports both integers and decimal numbers.
Features
- Convert numbers to English words
- Convert English words to numbers
- Support for:
- Integers
- Decimal numbers
- Negative numbers
- Large numbers (up to trillion)
Installation
For Users
pip install num-word-converter
For Developers
git clone https://github.com/lazorikv/num-word-converter.git
cd num-word-converter
pip install -e .
Usage
Number to Words
from num_word_converter import num_to_word
# Integer conversion
print(num_to_word(42)) # Output: "forty-two"
# Decimal conversion
print(num_to_word(3.14)) # Output: "three point one four"
# Negative numbers
print(num_to_word(-7)) # Output: "negative seven"
# Large numbers
print(num_to_word(1000000)) # Output: "one million"
Words to Number
from num_word_converter import word_to_num
# Integer words
print(word_to_num("forty-two")) # Output: 42
# Decimal words
print(word_to_num("three point one four")) # Output: 3.14
# Negative numbers
print(word_to_num("negative seven")) # Output: -7
# Large numbers
print(word_to_num("one million")) # Output: 1000000
Error Handling
The library includes several error types for proper error handling:
NonNumberInputError: Input is not a numberComplexNumberInputError: Input is a complex numberFractionTooLongError: Fractional part is too longScaleOutOfOrderError: Scale words are in wrong orderNoConversionForWordError: Word cannot be converted
Limitations
- Supports numbers up to trillion
- Maximum 10 decimal places for floating point numbers
- English language only
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file num_word_converter-1.0.8.tar.gz.
File metadata
- Download URL: num_word_converter-1.0.8.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77ddc61637a3e45e609c4c261e22c89a2fe8cb0129ec832c8ccf168326a10b3d
|
|
| MD5 |
c8b7914e9aa28c9b085551e399f96ebd
|
|
| BLAKE2b-256 |
f6a393372eea652305f26e9286a0981ffe19d637e233aa3a55e11e017d564faa
|
File details
Details for the file num_word_converter-1.0.8-py3-none-any.whl.
File metadata
- Download URL: num_word_converter-1.0.8-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4100e4bbb7087bb9be4ae6ff6d6abcac3a52b674df56c03d82f5667bfa4506a6
|
|
| MD5 |
9523156ee7d0c2e1cbd8e88d8670716b
|
|
| BLAKE2b-256 |
4b316ed904dbd6e0ddfa8ee1b333c6e12da846044038ad1aeeca9c506b1db7c3
|