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 (13 days ago) RSS 2.0 feedStarStarStarStar 60%Total: 170 This week: 12All time: 8,091 This week: 80Up
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
Nominee
Vote
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
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:170
This week:12
All time:8,091
This week:80Up
User Ratings User Comments (1)
 All timeMonth
Utility:75%StarStarStarStar75%Equal
Consistency:75%StarStarStarStar75%Equal
Documentation:75%StarStarStarStar75%Equal
Examples:75%StarStarStarStar75%Equal
Tests:--
Videos:--
Overall:60%StarStarStarStar60%Equal
Rank:11864Up