A module to convert numbers to words for Indian languages and English.
To install the module, run the following command:
pip install indic-numtowords
To use the library, import it using the following command:
from indic_numtowords import num2words
- Converts numbers into words in various languages:
words = num2words(38, lang='ta')
#output: 'முப்பத்து எட்டு'
- Returns variations for numbers:
words = num2words(150, lang='hi', variations=True)
#output: ['एक सौ पचास', 'डेढ़ सौ']
- Converts each digit separately:
words = num2words(420, lang='doi', split=True)
#output: 'चार दो सिफर'
The num2words
function accepts the following parameters:
number
: (int) The non-negative integer to convert into words.lang
: (str) The ISO code for the target language. Defaults to English (en
).variations
: (bool, optional) If set toTrue
, returns variations of the number.split
: (bool, optional) IfTrue
, converts each digit separately into its word form.
The following languages are supported by the num2words
module:
as
: Assamesebn
: Bengalibrx
: Bododoi
: Dogrien
: Englishgu
: Gujaratihi
: Hindikn
: Kannadaks
: Kashmirikok
: Konkanimai
: Maithiliml
: Malayalammr
: Marathimni
: Manipurine
: Nepalior
: Odiapa
: Punjabisa
: Sanskritsd
: Sindhita
: Tamilte
: Teluguur
: Urdu
This package contains work on converting numbers to words. The contents of this package can also be downloaded from our GitHub repo.
Distributed under the MIT license. See LICENSE for more information.