1

I am doing sentence comparison between actual text and speech to text. on this scenario I need to convert the number names one point ninety nine percent to 1.99%.

input : you will get discount of one point ninety nine percent.

output : you will get discount of 1.99%.

any suggestions or any libraries which will help to get rid of this situations. Thanks for your input.

  • Similar question: https://stackoverflow.com/questions/70161/how-to-read-values-from-numbers-written-as-words – Stef May 17 '22 at 16:20
  • See also this package: https://github.com/ShailChoksi/text2digits – Stef May 17 '22 at 16:21
  • I do encourage you to try solving the problem yourself, though. The algorithm is quite fun and actually quite simple. – Stef May 17 '22 at 16:21
  • If you have a list of words such as '`two hundred thousand three hundred ninety three'`, you should break it into three parts `a, b, c`, where `b` is the "biggest" word, `a` is the list of words that come before, and `c` the list of words that come after; here `a = 'two hundred'`, `b = 'thousand'`, `c = 'three hundred ninety three'`. Then use the recurrence formula `text2int(a, b, c) = text2int(a) * word2int(b) + text2int(c)`. – Stef May 17 '22 at 16:24
  • The algorithm described above is for integers; you can expand it a little looking for `'point'` and `'percent'` and other things. – Stef May 17 '22 at 16:26

0 Answers0