A package to convert words to numbers
Project description
NumWord
NumWord is a Python package that converts numbers written in words to their numeric representation and vice versa.
Features
- Convert words to numbers (supports decimals and large values).
- Convert numbers to words.
- Language support:
- English (
en) - Hindi (
hi) - French (
fr)
- English (
- Convert numbers to humanized formats:
1500000→1.5M1.5M→10L/10 लाख
- Convert currencies from one to another (using live exchange rates).
Installation
pip install -r requirements.txt
Usage
🔢 Convert word to number
from NumWord import WordToNumber
word_to_num_converter = WordToNumber()
# English
print(word_to_num_converter.convert("one hundred twenty three point four five six"))
# Output: 123.456
# Hindi
print(word_to_num_converter.convert("एक सौ तेईस दशमलव चार पांच छह", lang='hi'))
# Output: 123.456
# French
print(word_to_num_converter.convert("cent vingt-trois virgule quatre cinq six", lang="fr"))
# Output: 123.456
🗣️ Convert number to word
from NumWord import NumberToWord
num_to_word_converter = NumberToWord()
# English
print(num_to_word_converter.convert(123.456))
# Output: one hundred twenty-three point four five six
# Hindi
print(num_to_word_converter.convert(123.456, lang='hi'))
# Output: एक सौ तेईस दशमलव चार पांच छह
# French
print(num_to_word_converter.convert(123.456, lang='fr'))
# Output: cent vingt-trois virgule quatre cinq six
📏 Convert to/from humanized number formats
from NumWord import HumanizeNumber
humanize_number = HumanizeNumber()
# Convert to humanized format in English
print(humanize_number.convert(1500000, lang='en'))
# Output: 1.5M
# Convert to Hindi format
print(humanize_number.convert("1.5M", lang="en", to_lang="hi"))
# Output: 15 लाख
# Convert to shorthand Indian format
print(humanize_number.convert("1.5M", lang="en", to_lang="en-hi"))
# Output: 15L
💱 Currency conversion
from NumWord import Currency
currency = Currency()
# Convert USD to EUR
print(currency.convert(100, "USD", "EUR", with_symbol=False))
# Output: 88.37 EUR
# Convert EUR to INR with currency symbol
print(currency.convert(50, "EUR", "INR", with_symbol=True))
# Output: ₹ 4781.83
# Note: Currency exchange rates update once per day
🧪 Running Tests
python -m unittest discover tests
📄 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 numword-0.0.5.tar.gz.
File metadata
- Download URL: numword-0.0.5.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd729e611d5b1acc0ec41e500f48835875510386a63bfbc3c98c7ed50f26c88d
|
|
| MD5 |
d3fac69d315658849684f321f81e44e7
|
|
| BLAKE2b-256 |
cd0bfeeca21ccefad0ec3e057cb186f641d4140d708c79b3f130b87e07ba0650
|
Provenance
The following attestation bundles were made for numword-0.0.5.tar.gz:
Publisher:
python-publish.yml on HarshitDalal/NumWord
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
numword-0.0.5.tar.gz -
Subject digest:
cd729e611d5b1acc0ec41e500f48835875510386a63bfbc3c98c7ed50f26c88d - Sigstore transparency entry: 206646443
- Sigstore integration time:
-
Permalink:
HarshitDalal/NumWord@b61518705721fdc3e09375abe3ebd9068bbc42ea -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/HarshitDalal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b61518705721fdc3e09375abe3ebd9068bbc42ea -
Trigger Event:
release
-
Statement type:
File details
Details for the file numword-0.0.5-py3-none-any.whl.
File metadata
- Download URL: numword-0.0.5-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ac6819e88ac5f89e284dd0e2df9bd41e718bbdca9b73917cd38fce8e98fc300
|
|
| MD5 |
766f55d5846313a4d8896cb511202cc3
|
|
| BLAKE2b-256 |
ee0417618b7793a2859c33bf5555c0bd71aaea0f68a23773af1d4b1dab6eeda2
|
Provenance
The following attestation bundles were made for numword-0.0.5-py3-none-any.whl:
Publisher:
python-publish.yml on HarshitDalal/NumWord
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
numword-0.0.5-py3-none-any.whl -
Subject digest:
4ac6819e88ac5f89e284dd0e2df9bd41e718bbdca9b73917cd38fce8e98fc300 - Sigstore transparency entry: 206646444
- Sigstore integration time:
-
Permalink:
HarshitDalal/NumWord@b61518705721fdc3e09375abe3ebd9068bbc42ea -
Branch / Tag:
refs/tags/v0.0.5 - Owner: https://github.com/HarshitDalal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b61518705721fdc3e09375abe3ebd9068bbc42ea -
Trigger Event:
release
-
Statement type: