NAME
Lingua::TH::Numbers - Convert and spell Thai numbers.
VERSION
Version 1.0.3
SYNOPSIS
use Lingua::TH::Numbers;
# Input.
my $ten = Lingua::TH::Numbers->new( '10' );
my $sip = Lingua::TH::Numbers->new( '๑๐' );
my $lop_sip = Lingua::TH::Numbers->new( '-๑๐' );
my $three_point_one_four = Lingua::TH::Numbers->new( '3.14' );
my $nueng_chut_sun_song = Lingua::TH::Numbers->new( '๑.๐๒' );
# Output.
print $ten->thai_numerals(), "\n";
print $sip->arabic_numerals(), "\n";
print $lop_sip->arabic_numerals(), "\n";
print $three_point_one_four->thai_numerals(), "\n";
print $nueng_chut_sun_song->arabic_numerals(), "\n";
# Spell.
print $three_point_one_four->spell(), "\n";
print $three_point_one_four->spell( output_type => 'thai' ), "\n";
print $nueng_chut_sun_song->spell( output_type => 'rtgs' ), "\n";
print $nueng_chut_sun_song->spell( output_type => 'rtgs', informal => 1 ), "\n";
METHODS
new()
Create a new Lingua::TH::Numbers object.
my $ten = Lingua::TH::Numbers->new( '10' );
my $sip = Lingua::TH::Numbers->new( '๑๐' );
my $lop_sip = Lingua::TH::Numbers->new( '-๑๐' );
my $three_point_one_four = Lingua::TH::Numbers->new( '3.14' );
my $nueng_chut_sun_song = Lingua::TH::Numbers->new( '๑.๐๒' );
The input can use either Thai or Arabic numerals, but not both at the same time.
thai_numerals()
Output the number stored in the object using thai numerals.
my $ten = Lingua::TH::Numbers->new( '10' );
print $ten->thai_numerals(), "\n";
arabic_numerals()
Output the number stored in the object using arabic numerals.
my $lop_sip = Lingua::TH::Numbers->new( '-๑๐' );
print $lop_sip->arabic_numerals(), "\n";
spell()
Spell the number stored in the object.
By default, spelling is done using Thai script, but the method also supports the spelling of the Royal Thai General System with the parameter output_mode set to rtgs.
This method also supports spelling shortcuts for informal language, using the parameter informal.
# Spell using Thai script.
print Lingua::TH::Numbers->new( '10' )->spell(), "\n";
# Spell using the Royal Thai General System.
print Lingua::TH::Numbers->new( '10' )->spell( output_mode => 'rtgs' ), "\n";
# Spell using Thai script, with informal shortcuts.
print Lingua::TH::Numbers->new( '10' )->spell( informal => 1 ), "\n";
# Spell using the Royal Thai General System, with informal shortcuts.
print Lingua::TH::Numbers->new( '10' )->spell( output_mode => 'rtgs', informal => 1 ), "\n";
INTERNAL FUNCTIONS
_spell_integer()
Spell the integer passed as parameter.
This internal function should not be used, as it is designed to handle a sub-case of spell()
only in order to spell integers lesser than 10,000,000.
my @spelling = Lingua::TH::Numbers::_spell_integer( 10, $output_mode_index, $is_informal );
AUTHOR
Guillaume Aubert, <aubertg at cpan.org>
.
CAVEAT
There's too many Unicode issues in Perl 5.6 (in particular with tr/// which this module uses) and Perl 5.6 is 10 year old at this point, so I decided to make Perl 5.8 the minimum requirement for this module after a lot of time spent jumping through pre-5.8 hoops.
If you really need this module and you are still using a version of Perl that predates 5.8, please let me know although I would really encourage you to upgrade.
BUGS
Please report any bugs or feature requests to bug-lingua-th-numbers at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=lingua-th-numbers. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Lingua::TH::Numbers
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
COPYRIGHT & LICENSE
Copyright 2011 Guillaume Aubert.
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License.
See http://dev.perl.org/licenses/ for more information.