Skip to main content

A Python library for converting words to numbers.

Project description

🔢 Word to Number Converter (Multisystem: American, Indian & Nepali)

A simple yet powerful Python package to convert number words into numeric form. Inspired by w2n by Akshay Nagpal, but extended to support Indian and Nepali numbering systems such as lakh, crore, arba, and decimals.


✨ Features

  • ✅ Converts words like five hundred twenty five into 525
  • ✅ Supports American system: million, billion, trillion
  • ✅ Supports Indian/Nepali system: lakh, crore, arba
  • ✅ Handles decimal points: point four five0.45
  • ✅ Easy to integrate into Python applications

📦 Installation

Install using pip:

pip install WordToNumber

OR

Just copy the WordToNumber.py file into your project from the Source Code.


🚀 Usage

from WordToNumber import word_to_num

# American system
print(word_to_num('two million five hundred thousand'))  # 2500000

# Indian system
print(word_to_num('two crore fifty lakh'))  # 25000000

# Extended Nepali system with arba
print(word_to_num('one arba two crore'))  # 1020000000

# Decimal numbers
print(word_to_num('one hundred point five'))  # 100.5

🧠 Supported Vocabulary

🔢 Basic Numbers:

  • zero to nineteen
  • twenty, thirty, ..., ninety

🧱 Place Values:

American:

  • hundred, thousand, million, billion, trillion

Indian/Nepali:

  • hundred, thousand
  • lakh, lac, lakhs
  • crore, arba

Decimal:

  • point

🧪 Function Overview

word_to_num(number_sentence)

  • Main function to convert a sentence into a number.
  • Returns int or float.

📄 Example Conversions

Input Output
ten thousand 10000
two crore fifty lakh 25000000
one arba two crore 1020000000
one hundred point five 100.5
seventy five lakh twenty one 7500021
twelve point zero six seven 12.067

💡 Inspired By

akshaynagpal/w2n — A minimalistic library for word to number conversion in Python.

This project builds on top of that idea by supporting regional systems like Indian and Nepali with added robustness and flexibility.


🤝 Contributing

We welcome contributions! If you'd like to contribute to this Python Package Project, please check out our Contribution Guidelines.


🤗 Code of Conduct

Please review our Code of Conduct before participating in this app.


🪪 LICENSE

This project is licensed under the MIT License.


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

wordtonumber-1.1.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

wordtonumber-1.1.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file wordtonumber-1.1.0.tar.gz.

File metadata

  • Download URL: wordtonumber-1.1.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for wordtonumber-1.1.0.tar.gz
Algorithm Hash digest
SHA256 81cf6340e2891f444aea0a723dbb8bec2bd40aacbd0c16594fed50265594bd62
MD5 1d28aac80b088a0459ad7192fa8e51ce
BLAKE2b-256 b9915514fcd863153fd96c7ba43007b300a0e433a2029fbc50b6eadf1877d556

See more details on using hashes here.

File details

Details for the file wordtonumber-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: wordtonumber-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for wordtonumber-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce3d8bf2092ecc69c357f79dc10821c8d57b336c890aa61eba05e59f2e053640
MD5 abb40fa1e27eae5293dc9801b4e1b002
BLAKE2b-256 4d8653506914a301a00cdf0f902950ed5ebc112a924807e500beca401ef56c41

See more details on using hashes here.

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