05 Feb 2010 22:39:20 UTC
- Distribution: Lingua-EN-Words2Nums
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (4)
- Testers (16543 / 5 / 0)
- KwaliteeBus factor: 0
- 74.49% Coverage
- License: unknown
- Activity24 month
- Download (7.24KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
Lingua::EN::Words2Nums - convert English text to numbers
use Lingua::EN::Words2Nums; $num=words2nums("two thousand and one"); $num=words2nums("twenty-second"); $num=words2nums("15 billion, 6 million, and ninteen");
This module converts English text into numbers. It supports both ordinal and cardinal numbers, negative numbers, and very large numbers.
The main subroutine, which is exported by default, is words2nums(). This subroutine, when fed a string, will attempt to convert it into a number. If it succeeds, the number will be returned. If it fails, it returns undef.
There are a number of variables that can be used to tweak the behavior of this module. For example, debugging can be be enabled by setting $Lingua::EN::Words2Nums::debug=1
Default: 0. If set to a true value, outputs on standard error some useful messages if parsing fails for some reason.
Default: 10 ** 9. This is the number that will be returned for "one billion". It defaults to the American version; the English will want to set it to 10 ** 12. Setting this number automatically changes all the larger numbers (trillion, quadrillion, etc) to match.
It does not understand decimals or fractions, yet.
Scores are supported, eg: "four score and ten". So are dozens. So is a baker's dozen. And a gross.
Various mispellings of numbers are understood.
While it handles googol correctly, googolplex is too large to fit in perl's standard scalar type, and "inf" will be returned.
Copyright 2001-2003 Joey Hess <email@example.com>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Lingua::EN::Words2Nums, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Lingua::EN::Words2Nums
For more information on module installation, please visit the detailed CPAN module installation guide.