Related Articles
Python Numerizer Library
• Last Updated : 19 Feb, 2020

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:

 `# Importing Numerize function``# From Numerizer Library``from` `numerizer ``import` `numerize`` ` `  ` `# We can get interger value``# in output by converting explicitly``a ``=` `int``(numerize(``'Three'``))``print``(a)``print``(numerize(``'five thousand two hundred and twenty'``))`` ` ` ` `# If we are not converting our``# output explicitly into integer``# then by default it will return ``# a string value``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:

 `# Importing Numerize function``# From Numerizer Library``from` `numerizer ``import` `numerize`` ` ` ` `# here we can also pass numerical``# values with corresponding periods``# it will still give same output``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)``  ` `# here we can also get float values``# in our output by using "half" and ``# "quarter" terms in input``a ``=` `numerize(``'twenty nine one half'``)``print``(a)``type``(a)``  ` `# here we are explicitly converting``# our output into float type ``a ``=` `float``(numerize(``' nine hundred ninety and two half'``))`` ` `# it will add two half``# (i.e. 1/2+1/2) to our no``# which will add 1 to our answer ``print``(a)``type``(a)``  ` `a ``=` `numerize(``'two thousand four hundred twenty and three quarters'``)`` ` `# it will add (3/4) to our answer``print``(a)`

Output:

```320320
990988881999999
29.5
991.0
2420.75
```

Note: Numerize always takes string as input otherwise it will raise a `SyntaxError`.

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up