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 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

numword-0.0.3.tar.gz (13.2 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.3-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

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

Hashes for numword-0.0.3.tar.gz
Algorithm Hash digest
SHA256 85071e6a0edfbff794b8fd39e5ebdb0b5760bc69168021a5d52b89e0399abb26
MD5 ce10d7200c8f2b8288d627b1f4a80d7e
BLAKE2b-256 ab57e51aa01b5059ba4966f2d7e4346cbcaf242ccd11b7882ab260233264ba45

See more details on using hashes here.

Provenance

The following attestation bundles were made for numword-0.0.3.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.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

Hashes for NumWord-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 21a181a8ebb0c84670e233f983af50dc1edcb0da79b3bddfc4064c3bf161f66d
MD5 981979c9ac5db7248004fc7fa0569745
BLAKE2b-256 0e2535d3a892a157297513c01f02d7b876b10f8b4ea91cd42b344c9f743219ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for NumWord-0.0.3-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