All Projects → finnfiddle → Words To Numbers

finnfiddle / Words To Numbers

Licence: mit
JS library to convert textual words to numbers with optional fuzzy text matching

Programming Languages

javascript
184084 projects - #8 most used programming language
es6
455 projects

Labels

Projects that are alternatives of or similar to Words To Numbers

Node Connect Pg Simple
A simple, minimal PostgreSQL session store for Connect/Express
Stars: ✭ 166 (-23.15%)
Mutual labels:  node-js
Nodejs Master Class
🛠 This repository contains the homework assignment for Node.js Master Class that is focused on building a RESTful API, web app GUI, and a CLI in plain Node JS with no NPM or 3rd-party libraries
Stars: ✭ 182 (-15.74%)
Mutual labels:  node-js
Awesome Nodejs
A curated collection of best NodeJS Resources ✍️
Stars: ✭ 197 (-8.8%)
Mutual labels:  node-js
Robot Js
Native system automation for node.js
Stars: ✭ 169 (-21.76%)
Mutual labels:  node-js
Plugin Nvm
Node version manager wrapper for Fish shell
Stars: ✭ 173 (-19.91%)
Mutual labels:  node-js
Titra
titra - modern open source project time tracking for freelancers and small teams
Stars: ✭ 189 (-12.5%)
Mutual labels:  node-js
Postgres Migrations
🐦 A Stack Overflow-inspired PostgreSQL migration library with strict ordering and immutable migrations
Stars: ✭ 161 (-25.46%)
Mutual labels:  node-js
Bit
A tool for component-driven application development.
Stars: ✭ 14,443 (+6586.57%)
Mutual labels:  node-js
Jspp
JS++, a sound static/dynamic programming language for web development
Stars: ✭ 177 (-18.06%)
Mutual labels:  node-js
Flake Idgen
Flake ID generator yields k-ordered, conflict-free ids in a distributed environment in Node.js
Stars: ✭ 196 (-9.26%)
Mutual labels:  node-js
Xpcms
基于node的cms系统, 后端采用node+koa+redis,并通过本人封装的redis库实现数据操作,前端采用vue+ts+vuex开发,后台管理系统采用react全家桶开发
Stars: ✭ 170 (-21.3%)
Mutual labels:  node-js
Discordrpcmaker
Cross-platform Discord Rich Presence Maker, WITH BUTTONS!
Stars: ✭ 165 (-23.61%)
Mutual labels:  node-js
Obs Studio Node
libOBS (OBS Studio) for Node.Js, Electron and similar tools
Stars: ✭ 193 (-10.65%)
Mutual labels:  node-js
Electrode
Web applications with node.js and React
Stars: ✭ 2,033 (+841.2%)
Mutual labels:  node-js
Basic Mmo Phaser
Very basic multiplayer online game example made with Phaser, Node.js and Socket.io
Stars: ✭ 198 (-8.33%)
Mutual labels:  node-js
Lib4dev
Find awesome libraries and make your development fast.
Stars: ✭ 165 (-23.61%)
Mutual labels:  node-js
Focus Budget Manager
Budget Manager application built with Vue.js, Node.js, Express.js and MongoDB
Stars: ✭ 189 (-12.5%)
Mutual labels:  node-js
Evote
A voting application that leverages Hyperledger Fabric and the IBM Blockchain Platform to record and tally ballots.
Stars: ✭ 208 (-3.7%)
Mutual labels:  node-js
Vm2
Advanced vm/sandbox for Node.js
Stars: ✭ 2,738 (+1167.59%)
Mutual labels:  node-js
Node Pg Pubsub
A Publish/Subscribe implementation on top of PostgreSQL NOTIFY/LISTEN
Stars: ✭ 194 (-10.19%)
Mutual labels:  node-js

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

import wordsToNumbers from 'words-to-numbers';
wordsToNumbers('one hundred'); //100
wordsToNumbers('one hundred and five'); //105
wordsToNumbers('one hundred and twenty five'); //125
wordsToNumbers('four thousand and thirty'); //4030
wordsToNumbers('six million five thousand and two'); //6005002
wordsToNumbers('a thousand one hundred and eleven'); //1111
wordsToNumbers('twenty thousand five hundred and sixty nine'); //20569
wordsToNumbers('five quintillion'); //5000000000000000000
wordsToNumbers('one-hundred'); //100
wordsToNumbers('one-hundred and five'); //105
wordsToNumbers('one-hundred and twenty-five'); //125
wordsToNumbers('four-thousand and thirty'); //4030
wordsToNumbers('six-million five-thousand and two'); //6005002
wordsToNumbers('a thousand, one-hundred and eleven'); //1111
wordsToNumbers('twenty-thousand, five-hundred and sixty-nine'); //20569

Multiple numbers in a string

Returns a string with all instances replaced.

wordsToNumbers('there were twenty-thousand, five-hundred and sixty-nine X in the five quintillion Y')) // '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...

import wordsToNumbers from 'words-to-numbers';
wordsToNumbers('won huntred', {fuzzy: true}); //100
wordsToNumbers('too thousant and fiev', {fuzzy: true}); //2005
wordsToNumbers('tree millyon sefen hunderd and twinty sex', {fuzzy: true}); //3000726

Decimal Points

import wordsToNumbers from 'words-to-numbers';
wordsToNumbers('ten point five'); //10.5
wordsToNumbers('three point one four one five nine two six'); //3.1415926

Ordinal Numbers

import wordsToNumbers from 'words-to-numbers';
wordsToNumbers('first'); //1
wordsToNumbers('second'); //2
wordsToNumbers('third'); //3
wordsToNumbers('fourteenth'); //14
wordsToNumbers('twenty fifth'); //25
wordsToNumbers('thirty fourth'); //34
wordsToNumbers('forty seventh'); //47
wordsToNumbers('fifty third'); //53
wordsToNumbers('sixtieth'); //60
wordsToNumbers('seventy second'); //72
wordsToNumbers('eighty ninth'); //89
wordsToNumbers('ninety sixth'); //96
wordsToNumbers('one hundred and eighth'); //108
wordsToNumbers('one hundred and tenth'); //110
wordsToNumbers('one hundred and ninety ninth'); //199

Commonjs

const { wordsToNumbers } = require('words-to-numbers');
wordsToNumbers('one hundred'); //100;

Implied Hundreds

wordsToNumbers('nineteen eighty four', { impliedHundreds: true }); //1984
wordsToNumbers('one thirty', { impliedHundreds: true }); //130
wordsToNumbers('six sixty two', { impliedHundreds: true }); //662
wordsToNumbers('ten twelve', { impliedHundreds: true }); //1012
wordsToNumbers('nineteen ten', { impliedHundreds: true }); //1910
wordsToNumbers('twenty ten', { impliedHundreds: true }); //2010
wordsToNumbers('twenty seventeen', { impliedHundreds: true }); //2017
wordsToNumbers('twenty twenty', { impliedHundreds: true }); //2020
wordsToNumbers('twenty twenty one', { impliedHundreds: true }); //2021
wordsToNumbers('fifty sixty three', { impliedHundreds: true }); //5063
wordsToNumbers('fifty sixty', { impliedHundreds: true }); //5060
wordsToNumbers('fifty sixty three thousand', { impliedHundreds: true }); //5063000
wordsToNumbers('one hundred thousand', { impliedHundreds: true }); //100000
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].