words-to-numbers icon indicating copy to clipboard operation
words-to-numbers copied to clipboard

Needed something like this library

Open getify opened this issue 3 years ago • 0 comments

I recently needed something like this library. My use-case is converting numeric sentences from speech-recognition libraries (like PocketSphinx.js). Unfortunately, after surveying this library, I had several concerns and unaddressed wants:

  • Several open/unaddressed bugs reported and not triaged for quite awhile -- is this project still maintained?
  • A few known-unsupported conversions (listed in the tests)
  • Supporting a few looser forms of english number sentences
  • Exact outputs (via string) instead of as numbers (with floating point quirks)
  • Operate in a mode that errors if contents in the string aren't recognized as valid (such as "four thousand six million")
  • Ability to collect individual digits as a single number (like "one two three four" -> "1234")
  • Able to specify an optional formatter option: unit-place separator (,)
  • Zero-dependency lib that could run in the browser with no build-steps/etc
  • Wanted to expose an AST result from parsing such that other number formatting/localization would be possible as custom serialization from the AST
  • I did not need/want the fuzzy matching or the multiple numbers per string features -- wasn't clear if I could disable those?

In the end, I decided to implement a parser/compiler to suit my needs, rather than adapting this library from its current form. Just wanted to share my efforts in case they're useful to anyone (including this project):

https://gist.github.com/getify/83e6fae8f54c1d38f89132a130493f98

getify avatar Feb 24 '21 03:02 getify