Utility to identify english number words in text and to convert them to actual numbers.
This library is based on the Perl libraries Lingua-EN-FindNumber and Lingua-EN-Words2Nums.
npm install numstr
Takes a number written in english and converts it to a number.
var words2nums = require('numstr').words2nums;
console.log(words2nums('one thousand nine hundred seventy six')); // 1976
Identifies english numbers in a string and returns an array
var extractNumbers = require('numstr').extractNumbers;
console.log(extractNumbers('He ate five pies')); // [{text: 'five', index: 8}]
Replaces english numbers with actual numbers in a string
var numify = require('numstr').numify;
console.log(numify('I ran twenty six miles')); // I ran 26 miles
Currently supports negative numbers and numbers up to decillions along with common phrases like 'score', 'gross', 'dozen', 'bakersdozen' and more.
Does not currently support fractions or decimals