Converting text to numeric values in Python

mahabub.devs3
Mahabubur Rahman
Published on Oct, 20 2024 1 min read 0 comments
image

numerizer is a Python module to convert natural language numerics into ints and floats. 

Installation

The numerizer library can be installed from PyPI as follows:

$ pip install numerizer

Usage

>>> from numerizer import numerize
>>> numerize('forty two')
'42'
>>> numerize('forty-two')
'42'
>>> numerize('four hundred and sixty two')
'462'
>>> numerize('one fifty')
'150'
>>> numerize('twelve hundred')
'1200'
>>> numerize('twenty one thousand four hundred and seventy three')
'21473'
>>> numerize('one million two hundred and fifty thousand and seven')
'1250007'
>>> numerize('one billion and one')
'1000000001'
>>> numerize('nine and three quarters')
'9.75'
>>> numerize('platform nine and three quarters')
'platform 9.75'

 

 

0 Comments