Python Numerizer Library
Last Updated :
29 May, 2021
Numerizer is that library which will convert figures written in English in accordance with the International Number System. It can convert input composed of four periods which are one’s period, thousand’s period, million’s period and trillion’s period. Each period will be composed of three digits i.e. ones place, tens place and hundreds place. It is a widely used library for Natural Language Processing and DataScience.
Note: For converting Figures of Indian Number System you have to write it first in International Number System.
Installing Library:
pip install numerizer
Example 1:
Python3
from numerizer import numerize
a = int (numerize( 'Three' ))
print (a)
print (numerize( 'five thousand two hundred and twenty' ))
a = numerize( 'forty four thousand four hundred forty four' )
print (a)
print ( "Type" , type (a))
a = numerize( 'sixty billion forty million twenty thousand four hundred six' )
print (a)
|
Output :
3
5220
44444
Type
60040020406
Example 2:
Python3
from numerizer import numerize
a = numerize( '320 thousand three hundred twenty ' )
print (a)
a = numerize( '990 trillion 988 billion 881 million 999 thousand nine hundred ninety nine' )
print (a)
a = numerize( 'twenty nine one half' )
print (a)
type (a)
a = float (numerize( ' nine hundred ninety and two half' ))
print (a)
type (a)
a = numerize( 'two thousand four hundred twenty and three quarters' )
print (a)
|
Output:
320320
990988881999999
29.5
991.0
2420.75
Note: Numerize always takes string as input otherwise it will raise a SyntaxError.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...