0.0.1 • Published 11 years ago

text2num v0.0.1

Weekly downloads
3
License
-
Repository
github
Last release
11 years ago

text2num.js

Convert English phrases to their numerical equivalent. Code translated from and embellished on: https://github.com/ghewgill/text2num

Build Status

Installation

npm install text2num

Usage

require('text2num')

# Simple
var number = text2num("three")
# number == 3

# Longer
text2num("sixty thousand five hundred two")
# 60502

# Use hyphens if you like
text2num("six-hundred three")
# 603

# And the word "and"
text2num("six-hundred and three")
# 603

# Use decimals
text2num("fifty point two")
# 50.2

text2num("fifty dot two")
# 50.2

# Longer decimals
text2num("fifty point two hundred one")
# 50.201

text2num("fifty point two thousand and fifty two")
# 50.2052

Additions welcome!

Just send a pull request