The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Lingua::ENG::Numbers - Converts numeric values into their English string equivalents.

VERSION

version 0.1106

SYNOPSIS

        ## EXAMPLE 1

        use Lingua::ENG::Numbers qw(American);

        $n = new Lingua::ENG::Numbers(313721.23);
        if (defined $n) {
                $s = $n->get_string;
                print "$s\n";
        }


        ## EXAMPLE 2

        use Lingua::ENG::Numbers;

        $n = new Lingua::ENG::Numbers;
        $n->parse(-1281);
        print "N = " . $n->get_string . "\n";

REQUIRES

Perl 5, Exporter, Carp

DESCRIPTION

Number 2 word conversion for ENG.

Lingua::ENG::Numbers converts arbitrary numbers into human-oriented English text. Limited support is included for parsing standardly formatted numbers (i.e. '3,213.23'). But no attempt has been made to handle any complex formats. Support for multiple variants of English are supported. Currently only "American" formatting is supported.

To use the class, an instance is generated. The instance is then loaded with a number. This can occur either during construction of the instance or later, via a call to the parse method. The number is then analyzed and parsed into the english text equivalent.

The instance, now initialized, can be converted into a string, via the get_string method. This method takes the parsed data and converts it from a data structure into a formatted string. Elements of the string's formatting can be tweaked between calls to the get_string function. While such changes are unlikely, this has been done simply to provide maximum flexability.

METHODS

Creation

new Lingua::ENG::Numbers $numberString

Creates, optionally initializes, and returns a new instance.

INTERNAL FUNCTIONS

do_get_string
logn
log10
parse_number
parse_number_low
pow10
pow10Block
string_to_number

Initialization

$number->parse $numberString

Parses a number and (re)initializes an instance. Only a number from interval [0, 10^66) can be converted.

Output

$number->get_string

Returns a formatted string based on the most recent parse.

CLASS VARIABLES

$Lingua::ENG::Numbers::VERSION

The version of this class.

$Lingua::ENG::Numbers::MODE

The current locale mode. Currently only American is supported.

%Lingua::ENG::Numbers::INPUT_GROUP_DELIMITER

The delimiter which seperates number groups. Example: "1,321,323" uses the comma ',' as the group delimiter.

%Lingua::ENG::Numbers::INPUT_DECIMAL_DELIMITER

The delimiter which seperates the main number from its decimal part. Example: "132.2" uses the period '.' as the decimal delimiter.

%Lingua::ENG::Numbers::OUTPUT_BLOCK_DELIMITER

A character used at output time to convert the number into a string. Example: One Thousand, Two-Hundred and Twenty-Two point Four. Uses the space character ' ' as the block delimiter.

%Lingua::ENG::Numbers::OUTPUT_GROUP_DELIMITER

A character used at output time to convert the number into a string. Example: One Thousand, Two-Hundred and Twenty-Two point Four. Uses the comma ',' character as the group delimiter.

%Lingua::ENG::Numbers::OUTPUT_NUMBER_DELIMITER

A character used at output time to convert the number into a string. Example: One Thousand, Two-Hundred and Twenty-Two point Four. Uses the dash '-' character as the number delimiter.

%Lingua::ENG::Numbers::OUTPUT_DECIMAL_DELIMITER

A character used at output time to convert the number into a string. Example: One Thousand, Two-Hundred and Twenty-Two point Four. Uses the 'point' string as the decimal delimiter.

%Lingua::ENG::Numbers::NUMBER_NAMES

A list of names for numbers.

%Lingua::ENG::Numbers::SIGN_NAMES

A list of names for positive and negative signs.

$Lingua::ENG::Numbers::SIGN_POSITIVE

A constant indicating the the current number is positive.

$Lingua::ENG::Numbers::SIGN_NEGATIVE

A constant indicating the the current number is negative.

DIAGNOSTICS

Error: Lingua::ENG::Numbers does not support tag: '$tag'.

(F) The module has been invoked with an invalid locale.

Error: bad number format: '$number'.

(F) The number specified is not in a valid numeric format.

Error: bad number format: '.$number'.

(F) The decimal portion of number specified is not in a valid numeric format.

AUTHOR

Stephen Pandich, pandich@yahoo.com

Maintenance PetaMem s.r.o. <info@petamem.com>