Converting Numbers to Text
Converting Numbers to Text
am 14.03.2006 02:34:48 von MRX
Greetings all!
I was wondering if anyone knows of a way to convert a string of digits into
its various text counterparts as they could be spoken?
i.e. the input would be > 123 Main Street
The Output would be:
one two three Main Street
one twenty three Main Street
one hundred twenty three Main Street
one hundred and twenty three Main Street
Any ideas of a way to accomplish this? ...or a 3rd party tool that can do
the same?
Regards,
Max...
Re: Converting Numbers to Text
am 14.03.2006 04:22:05 von Michael Greb
On 2006-03-14, MRX wrote:
> Greetings all!
>
> I was wondering if anyone knows of a way to convert a string of digits into
> its various text counterparts as they could be spoken?
>
> i.e. the input would be > 123 Main Street
>
> The Output would be:
>
> one two three Main Street
> one twenty three Main Street
> one hundred twenty three Main Street
> one hundred and twenty three Main Street
>
> Any ideas of a way to accomplish this? ...or a 3rd party tool that can do
> the same?
Checkout Number::Spell, usage looks like:
use Number::Spell
my $string = spell_number(123);
It only supports American and European formatting which according to the
docs affects numbers >= one billion.
number : 20000000000 (2 * 10^11)
American format : twenty billion
European format : twenty thousand million
If you are interested in numbers formated for a different country,
Lingua::Num2Word.
--
Michael
michael@thegrebs.com
SpamStats: http://spam.thegrebs.com
Re: Converting Numbers to Text
am 14.03.2006 10:18:06 von chris-usenet
Michael Greb wrote:
> Checkout Number::Spell, usage looks like:
> use Number::Spell
> my $string = spell_number(123);
> It only supports American and European formatting which according to the
> docs affects numbers >= one billion.
> number : 20000000000 (2 * 10^11)
> American format : twenty billion
> European format : twenty thousand million
It might do American but it doesn't do English. Here, 123 is spoken as
"one hundred and twenty three". The 'eu' format flag doesn't affect
this, either.
Chris
Re: Converting Numbers to Text
am 14.03.2006 21:29:48 von Michael Greb
On 2006-03-14, Chris Davies wrote:
> Michael Greb wrote:
>> Checkout Number::Spell, usage looks like:
>> use Number::Spell
>> my $string = spell_number(123);
>
>> It only supports American and European formatting which according to the
>> docs affects numbers >= one billion.
>> number : 20000000000 (2 * 10^11)
>> American format : twenty billion
>> European format : twenty thousand million
>
> It might do American but it doesn't do English. Here, 123 is spoken as
> "one hundred and twenty three". The 'eu' format flag doesn't affect
> this, either.
123 eq 'one hundred and twenty three' in .us as well. What was the
output from this module, "one two three"? I've never used it.
--
Michael
michael@thegrebs.com
SpamStats: http://spam.thegrebs.com
Re: Converting Numbers to Text
am 15.03.2006 10:35:16 von chris-usenet
Michael Greb wrote:
> use Number::Spell
> my $string = spell_number(123);
On 2006-03-14, Chris Davies wrote:
> It might do American but it doesn't do English. Here, 123 is spoken as
> "one hundred and twenty three". The 'eu' format flag doesn't affect
> this, either.
Michael Greb wrote:
> 123 eq 'one hundred and twenty three' in .us as well. What was the
> output from this module, "one two three"? I've never used it.
The output from 123 is "one hundred twenty three", which is exactly how
I would have expected American colleagues to say the number. (I've never
heard the "and" from an American speaking such phrases.) I'm intruiged to
see you say that you'd have also expected "one hundred and twenty three".
Chris
Re: Converting Numbers to Text
am 15.03.2006 13:13:41 von Matt Garrish
"Chris Davies" wrote in message
news:kn3le3-h0f.ln1@news.roaima.co.uk...
> Michael Greb wrote:
>> use Number::Spell
>> my $string = spell_number(123);
>
> On 2006-03-14, Chris Davies wrote:
>> It might do American but it doesn't do English. Here, 123 is spoken as
>> "one hundred and twenty three". The 'eu' format flag doesn't affect
>> this, either.
>
> Michael Greb wrote:
>> 123 eq 'one hundred and twenty three' in .us as well. What was the
>> output from this module, "one two three"? I've never used it.
>
> The output from 123 is "one hundred twenty three", which is exactly how
> I would have expected American colleagues to say the number. (I've never
> heard the "and" from an American speaking such phrases.) I'm intruiged to
> see you say that you'd have also expected "one hundred and twenty three".
>
Most people I know would say "one twenty three" or "a hundred and twenty
three", but then I am Canadian... : )
Matt
Re: Converting Numbers to Text
am 18.03.2006 20:07:55 von markhobley
MRX wrote:
> Greetings all!
>
> I was wondering if anyone knows of a way to convert a string of digits into
> its various text counterparts as they could be spoken?
>
I saw a website a while ago which mentioned a competition to write a program
to do just that. There were postings of program listings in many different
programming languages. I tested some of the programs here. They worked just
fine.
I'm searching the net now to see if I can find that website again.
I'll post the url, if I find it.
Regards,
Mark.
--
Mark Hobley
393 Quinton Road West
QUINTON
Birmingham
B32 1QE
Telephone: (0121) 247 1596
International: 0044 121 247 1596
Email: markhobley at hotpop dot donottypethisbit com
http://markhobley.yi.org/