english2number
Converts English words to numbers.
Last updated 4 years ago by tsavo .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install english2number 
SYNC missed versions from official npm registry.

The English2Number Javascript Library

build status coverage report dependencies Status npm version

Codeship Status for TSavo/english2number-js Codacy Badge Codacy Badge Code Climate Test Coverage Issue Count CircleCI

What it does

Converts English words to numbers.

The following inputs will return this number: 123,456,789,001

  • "one hundred and twenty-three billion, four hundred and fifty-six million, seven hundred and eighty-nine thousand and one" (cardinal)
  • "a hundred and twenty-three billion, four hundred and fifty-six million, seven hundred and eighty-nine thousand and one" (cardinal)
  • "one hundred twenty-three billion, four hundred fifty-six million, seven hundred eighty-nine thousand, one" (cardinal)
  • "one hundred twenty-three billion four hundred fifty-six million seven hundred eighty-nine thousand one" (cardinal)
  • "a hundred twenty-three billion, four hundred fifty-six million, seven hundred eighty-nine thousand, and one" (cardinal)
  • "a hundred and twenty-three billion, four hundred and fifty-six million, seven hundred and eighty-nine thousand and first" (ordinal)
  • "one hundred twenty-three billion, four hundred fifty-six million, seven hundred eighty-nine thousand, first" (ordinal)

And in fact really any reasonable combination of cardinal and ordinal English speech patterns for describing numbers.

What's the limit?

It doesn't parse anything bigger than decillion, which is 33 zeros after the 1, or 1000000000000000000000000000000000.

If you think it should, it would be trivial to add larger number support, but Javascript can't realistically represent that precision anyway. Perhaps a BigNumber version of this library would be in order.

Installation

npm install --save english2number 

Example Usage

As a module:

var toNumber = require("english2number");

toNumber("one hundred and twenty-three billion, four hundred and fifty-six million, seven hundred and eighty-nine thousand and one") // 123,456,789,001

Why not numeral.js?

numeral.js is an amazing library for dealing with numerals, but it lacks support for English parsing.

Contributing

Pull requests are welcome, please file any bugs on https://github.com/tsavo/english2number-js

Current Tags

  • 1.0.8                                ...           latest (4 years ago)

13 Versions

  • 1.0.8                                ...           4 years ago
  • 1.0.7                                ...           4 years ago
  • 1.0.6                                ...           4 years ago
  • 1.0.5                                ...           4 years ago
  • 1.0.4                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 5
Last Month 11
Dependencies (0)
None
Dev Dependencies (12)
Dependents (3)

Copyright 2014 - 2016 © taobao.org |