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.
- ✅ Converts words like
five hundred twenty five
into525
- ✅ Supports American system:
million
,billion
,trillion
- ✅ Supports Indian/Nepali system:
lakh
,crore
,arba
- ✅ Handles decimal points:
point four five
→0.45
- ✅ Easy to integrate into Python applications
Install using pip:
pip install WordToNumber
OR
Just copy the WordToNumber.py
file into your project from the Source Code.
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
zero
tonineteen
twenty
,thirty
, ...,ninety
hundred
,thousand
,million
,billion
,trillion
hundred
,thousand
lakh
,lac
,lakhs
crore
,arba
point
- Main function to convert a sentence into a number.
- Returns
int
orfloat
.
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 |
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.
We welcome contributions! If you'd like to contribute to this Python Package Project, please check out our Contribution Guidelines.
Please review our Code of Conduct before participating in this app.
This project is licensed under the MIT License.