A package to convert words to numbers
Project description
NumWord
NumWord is a Python package that converts numbers written in words to their numerical representation.
Features
- Convert single digits, two digits, large numbers, decimal numbers, and mixed numbers from words to numbers.
- Convert numbers to words.
- Supports English language.
- Supports Hindi language.
- Supports convert number into humanize number e.g.
- 1500000 -> 1.5M
- 1.5M -> 10L / 10 लाख
Installation
To install the package, use pip:
pip install -r requirements.txt
Usage
Here is an example of how to use the NumWord package:
Convert number word into number
from NumWord import WordToNumber
word_to_num_converter = WordToNumber()
# Convert words to numbers in English
result = word_to_num_converter.convert("one hundred twenty three point four five six")
print(result) # Output: 123.456
# Convert words to numbers in Hindi
result = word_to_num_converter.convert("एक सौ तेईस दशमलव चार पांच छह", lang='hi')
print(result) # Output: 123.456
Convert number into number word
from NumWord import NumberToWord
num_to_word_converter = NumberToWord()
# Convert numbers to words in English
result = num_to_word_converter.convert(123.456)
print(result) # Output: one hundred twenty-three point four five six
# Convert numbers to words in Hindi
result = num_to_word_converter.convert(123.456, lang='hi')
print(result) # Output: एक सौ तेईस दशमलव चार पांच छह
Convert number into Humanize Number or convert one number system to another humanize number system
from NumWord import HumanizeNumber
humanize_number = HumanizeNumber()
result = humanize_number.convert(1500000, lang='en')
print(result) # Output: 1.5M
result = humanize_number.convert("1.5M", lang="en", to_lang="hi")
print(result) # Output: 15 लाख
result = humanize_number.convert("1.5M", lang="en", to_lang="en-hi")
print(result) # Output: 15L
Running Tests
To run the tests, use the following command:
python -m unittest discover tests
License
This project is licensed under the MIT License - see the MIT 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.3.tar.gz.
File metadata
- Download URL: numword-0.0.3.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85071e6a0edfbff794b8fd39e5ebdb0b5760bc69168021a5d52b89e0399abb26
|
|
| MD5 |
ce10d7200c8f2b8288d627b1f4a80d7e
|
|
| BLAKE2b-256 |
ab57e51aa01b5059ba4966f2d7e4346cbcaf242ccd11b7882ab260233264ba45
|
Provenance
The following attestation bundles were made for numword-0.0.3.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.3.tar.gz -
Subject digest:
85071e6a0edfbff794b8fd39e5ebdb0b5760bc69168021a5d52b89e0399abb26 - Sigstore transparency entry: 173799034
- Sigstore integration time:
-
Permalink:
HarshitDalal/NumWord@6b945c41706cc350563f1c019c9be5c0a9331763 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/HarshitDalal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6b945c41706cc350563f1c019c9be5c0a9331763 -
Trigger Event:
release
-
Statement type:
File details
Details for the file NumWord-0.0.3-py3-none-any.whl.
File metadata
- Download URL: NumWord-0.0.3-py3-none-any.whl
- Upload date:
- Size: 12.8 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 |
21a181a8ebb0c84670e233f983af50dc1edcb0da79b3bddfc4064c3bf161f66d
|
|
| MD5 |
981979c9ac5db7248004fc7fa0569745
|
|
| BLAKE2b-256 |
0e2535d3a892a157297513c01f02d7b876b10f8b4ea91cd42b344c9f743219ee
|
Provenance
The following attestation bundles were made for NumWord-0.0.3-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.3-py3-none-any.whl -
Subject digest:
21a181a8ebb0c84670e233f983af50dc1edcb0da79b3bddfc4064c3bf161f66d - Sigstore transparency entry: 173799036
- Sigstore integration time:
-
Permalink:
HarshitDalal/NumWord@6b945c41706cc350563f1c019c9be5c0a9331763 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/HarshitDalal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6b945c41706cc350563f1c019c9be5c0a9331763 -
Trigger Event:
release
-
Statement type: