NAME
Lingua::EN::Words2Nums - convert English text to numbers
SYNOPSIS
use Lingua::EN::Words2Nums;
$num=words2nums("one thousand and one");
$num=words2nums("twenty-second");
$num=words2nums("15 billion, 6 million, and ninteen");
DESCRIPTION
This module converts English text into numbers. It supports both ordinal and cardinal numbers, negative numbers, and numbers larger than one billion.
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.
VARIABLES
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
- $Lingua::EN::Words2Nums::debug
-
Default: 0. If set to a true value, outputs on standard error some useful messages if parsing fails for some reason.
- $Lingua::EN::Words2Nums::million
-
Default: 10 ** 9. This is the number that will be returned for "one million". It defaults to the American version; the English will want to set it to 10 ** 12.
NOTES
It does not understand decimals or fractions, yet.
It happens that it can do some simple math such as "fourteen minus five", but don't count on that working in the future.
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.
AUTHOR
Copyright © 2001 Joey Hess <joey@kitenet.net>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 189:
Non-ASCII character seen before =encoding in '©'. Assuming CP1252