Words To Numbers
Convert words to numbers. Optionally fuzzy match the words to numbers.
npm install words-to-numbers
If the whole string passed is a number then it will return a Number
type otherwise it will return the original string with all instances of numbers replaced.
TODO: Add functionality for parsing mixed numbers and words. PRs welcome.
Basic Examples
;; //100; //105; //125; //4030; //6005002; //1111; //20569; //5000000000000000000; //100; //105; //125; //4030; //6005002; //1111; //20569
Multiple numbers in a string
Returns a string with all instances replaced.
) // 'there were 20569 X in the 5000000000000000000 Y'
With Fuzzy Matching
Uses Jaro distance to find the best match for the number words. Don't rely on this being completely accurate...
;; //100; //2005; //3000726
Decimal Points
;; //10.5; //3.1415926
Ordinal Numbers
;; //1; //2; //3; //14; //25; //34; //47; //53; //60; //72; //89; //96; //108; //110; //199
Commonjs
const wordsToNumbers = ;; //100;