Skip to main content

A package to convert words to numbers

Project description

NumWord

Manual Test Daily Test PyPI PyPI Downloads License MIT codecov

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)
  • Convert numbers to humanized formats:
    • 15000001.5M
    • 1.5M10L / 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

numword-0.0.4.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numword-0.0.4-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file numword-0.0.4.tar.gz.

File metadata

  • Download URL: numword-0.0.4.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for numword-0.0.4.tar.gz
Algorithm Hash digest
SHA256 024f04927e9a75ce30ad373f3f1556e29742084622c28cb588aa0ab148c27429
MD5 9af1a064fe64eeef2a0a0dd32a53b517
BLAKE2b-256 bccd5c82db559fa60d3364c2a498b675b4ed87e248f171821866816e0800b5ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for numword-0.0.4.tar.gz:

Publisher: python-publish.yml on HarshitDalal/NumWord

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file numword-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: numword-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for numword-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9ceb89b8c8812c5a513546d6595bb73a975359f906928f515ddf5a72f1a9912c
MD5 aee715d88bae19d7a374904f52dd65ed
BLAKE2b-256 4172461cd4a7bbd3bdff6876f2cedecba4d1b3ebb0a0f8f2bdb206326c50d57c

See more details on using hashes here.

Provenance

The following attestation bundles were made for numword-0.0.4-py3-none-any.whl:

Publisher: python-publish.yml on HarshitDalal/NumWord

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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