PHP Classes
elePHPant
Icontem

PHP Convert Words to Numbers: Convert text with an amount to its numeric value

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2016-12-21 (2 months ago) RSS 2.0 feedStarStarStarStar 60%Total: 212 This week: 2All time: 7,807 This week: 461Up
Version License PHP version Categories
cwordstonumbers 1.2BSD License5PHP 5, Text processing, Math, Parsers
Description Author

This class can can convert text with an amount to its numeric value.

It takes a text string with a number or money amount in English and converts it to the respective number.

The class can automatically detect the numbers using native English or Indian alternatives, like billion or crore.

It returns either the number as integer or formatted string according to the detected number system.

It can deal with words entered in different order, or add values of expressions that represent sums of the numbers like "twelve hundred and twelve hundred and twenty three hundred".

Innovation Award
PHP Programming Innovation award nominee
December 2016
Number 2


Prize: One copy of DWebPro Standard License
Very often applications need to be able to spell numbers using words in a given language. There are many solutions for that because it is a relatively easy problem.

However, there are not many solutions that do the opposite, i.e. take text written in a given language that represents a certain amount and return the number value of the amount that.

This class does precisely that. It takes a text representing an amount in English and returns the number that is spelled.

It is pretty smart to the point of understanding the different ordering that an amount can be spelled as well when the amount is spelled using Indian word variants like lakh and crore instead of millions and billions.

Manuel Lemos
  Performance   Level  
Name: Mohammed Asad <contact>
Classes: 2 packages by
Country: India India
Age: 28
All time rank: 3698260 in India India
Week rank: 300 Up25 in India India Up
Innovation award
Innovation award
Nominee: 2x

Details

INTRODUCTION:

This class is created for converting the words( that represents the digits) to numbers again like thousand to 1000, hundred to 100 or so.

The main purpose for creating this class is just to help someone who was looking for this and I also had lot of free time.

CHALLENGES faced to make this work:

-- changing the order of the words and the different probability of words order.

-- Committing spelling mistakes or using extra gaps or unwanted characters.

-- Using indian and western system together (like billion crore). :P

FEATURES:

-- It can automatically detect the entered number system either be indian or western.

-- This can also help to get the digits for terms like twelve hundred or twenty five hundred.

-- You can also find the sum of the numbers by typing them like (eg.twelve hundred and twelve hundred and twenty three hundred),well it know its the hard way, but still you can do it.

-- It can format automatically based on the detected number system if the formatting is enabled.

-- Pretty simple to use, it. Just create and object and call the displayNumbers method.

LIMITATIONS:

-- Indian number system limit is till ninty nine lakh crore and ninty nine lakh and so on. (99,99,999,99,99,999)

-- Western number system limit is till nine hundred and ninty nine billion and so one (999,999,999,999)

-- Using wrong ordered words might create a chaos (I am not responsible if your machine explodes)

-- Currently Supports only ENGLISH LANGUAGE

LANGUAGE SUPPORT:

ONLY ENGLISH

Screenshots  
  • Western_Conversion
  • Indian_Conversion
  Files folder image Files  
File Role Description
Files folder imagecwordstonumbers (2 files, 3 directories)

  Files folder image Files  /  cwordstonumbers  
File Role Description
Files folder imageconfig (1 file)
Files folder imagesrc (1 file)
Files folder imagetests (2 files)
  Accessible without login Plain text file LICENSE Lic. License text
  Accessible without login Plain text file README.txt Doc. Documentation

  Files folder image Files  /  cwordstonumbers  /  config  
File Role Description
  Accessible without login Plain text file words_to_numbers_mapper.json Data Auxiliary data

  Files folder image Files  /  cwordstonumbers  /  src  
File Role Description
  Plain text file cWordsToNumbers.class.php Class Class source

  Files folder image Files  /  cwordstonumbers  /  tests  
File Role Description
  Accessible without login Plain text file simpleConversion.php Example Example script
  Accessible without login Plain text file simpleWebFormConversion.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 75%
Total:212
This week:2
All time:7,807
This week:461Up
User Ratings User Comments (1)
 All time
Utility:75%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:75%StarStarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:60%StarStarStarStar
Rank:1193