akshaynagpal / w2n

Convert number words (eg. twenty one) to numeric digits (21)
http://w2n.readthedocs.io
MIT License
169 stars 78 forks source link

Replacing word numbers with digits in a string #39

Closed psychemedia closed 5 years ago

psychemedia commented 5 years ago

word2number seems to be able to pull numbers from words out of a more general string:

w2n.word_to_num("I count it at two million three thousand nine hundred and eighty four or thereabouts")

#returns: 2003984

but is there also a way of plugging that back in to the original string?

For example, if I wanted something like:

w2n.word_to_num("I count it at two million three thousand nine hundred and eighty four or thereabouts", replace=True)

#returns: "I count it at 2003984 or thereabouts"
akshaynagpal commented 5 years ago

Not as of now. You will have to process that with additional code at your end.