Skip Menu |

This queue is for tickets about the Lingua-NL-Numbers CPAN distribution.

Report information
The Basics
Id: 7158
Status: open
Priority: 0/
Queue: Lingua-NL-Numbers

People
Owner: Nobody in particular
Requestors: vvvv767 [...] hotmail.com
Cc: randomcoder1 [...] gmail.com
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Some numbers are not being converted correct
if a convert 201011, i get "twee honderd duizend, en elf". But this represents 200011 if a convert 20101011, i get "twintig miljard, een honderd duizend, en elf". But this represents 20100011 if a convert 21101011, i get "een en twintig miljard, een honderd duizend, en elf". But this represents 21100011 if a convert 22101011, i get "twee en twintig miljard, een honderd duizend, en elf". But this represents 22100011 if a convert 23101011, i get "drie en twintig miljard, een honderd duizend, en elf". But this represents 23100011 if a convert 24101011, i get "vier en twintig miljard, een honderd duizend, en elf". But this represents 24100011 if a convert 25101011, i get "vijf en twintig miljard, een honderd duizend, en elf". But this represents 25100011 if a convert 26101011, i get "zes en twintig miljard, een honderd duizend, en elf". But this represents 26100011 if a convert 27101011, i get "zeven en twintig miljard, een honderd duizend, en elf". But this represents 27100011 if a convert 28101011, i get "acht en twintig miljard, een honderd duizend, en elf". But this represents 28100011 if a convert 29101011, i get "negen en twintig miljard, een honderd duizend, en elf". But this represents 29100011
So I learned how to spell numbers in dutch. I took a look at the bug report and fixed it. I am sending a patch as well as a test file. In the process of fixing the bugs I've also used Lingua::NL::Numbers::GroeneBoekje to compare results. On Wed Jul 28 11:17:44 2004, VXX wrote: Show quoted text
> if a convert 201011, i get "twee honderd duizend, en elf". But this > represents 200011 > > if a convert 20101011, i get "twintig miljard, een honderd duizend, en > elf". But this represents 20100011 > > if a convert 21101011, i get "een en twintig miljard, een honderd > duizend, en elf". But this represents 21100011 > > if a convert 22101011, i get "twee en twintig miljard, een honderd > duizend, en elf". But this represents 22100011 > > if a convert 23101011, i get "drie en twintig miljard, een honderd > duizend, en elf". But this represents 23100011 > > if a convert 24101011, i get "vier en twintig miljard, een honderd > duizend, en elf". But this represents 24100011 > > if a convert 25101011, i get "vijf en twintig miljard, een honderd > duizend, en elf". But this represents 25100011 > > if a convert 26101011, i get "zes en twintig miljard, een honderd > duizend, en elf". But this represents 26100011 > > if a convert 27101011, i get "zeven en twintig miljard, een honderd > duizend, en elf". But this represents 27100011 > > if a convert 28101011, i get "acht en twintig miljard, een honderd > duizend, en elf". But this represents 28100011 > > if a convert 29101011, i get "negen en twintig miljard, een honderd > duizend, en elf". But this represents 29100011
-- Your bugs , they are afraid of me.
--- Numbers.pm 2002-08-02 01:16:51.000000000 +0300 +++ /usr/local/share/perl/5.10.0/Lingua/NL/Numbers.pm 2009-11-11 10:55:08.000000000 +0200 @@ -70,10 +70,10 @@ # tens of billions if( defined($digits->[10]) && ($digits->[10] != 0) ) { my $temp = $self->_formatTens( $digits->[9], $digits->[10] ); - unshift @{$ret_array}, "$temp biljoen"; + unshift @{$ret_array}, "$temp miljard"; } elsif( defined($digits->[9]) && ($digits->[9] != 0) ) { - unshift @{$ret_array}, $self->_formatLarge( $digits->[9], ' biljoen' ); + unshift @{$ret_array}, $self->_formatLarge( $digits->[9], ' miljard' ); }; # hundreds of millions @@ -89,10 +89,10 @@ # tens of millions if( defined($digits->[7]) && ($digits->[7] != 0) ) { my $temp = $self->_formatTens( $digits->[6], $digits->[7] ); - unshift @{$ret_array}, "$temp miljard"; + unshift @{$ret_array}, "$temp miljoen"; } elsif( defined($digits->[6]) && ($digits->[6] != 0) ) { - unshift @{$ret_array}, $self->_formatLarge( $digits->[6], ' miljard' ); + unshift @{$ret_array}, $self->_formatLarge( $digits->[6], ' miljoen' ); }; # hundreds of thousands @@ -110,10 +110,12 @@ my $temp = $self->_formatTens( $digits->[3], $digits->[4] ); unshift @{$ret_array}, "$temp duizend"; } - elsif( defined($digits->[3]) && ($digits->[3] == 1) ) { - unshift @{$ret_array}, ' duizend'; + elsif( defined($digits->[3]) && ($digits->[3] == 1) ) { # is 1 + my $temp = 'duizend'; + $temp = 'een '.$temp if @$digits > 4; + unshift @{$ret_array}, $temp; } - elsif( defined($digits->[3]) && ($digits->[3] != 0) ) { + elsif( defined($digits->[3]) && ($digits->[3] != 0) ) { # is > 1 unshift @{$ret_array}, $self->_formatLarge( $digits->[3], ' duizend' ); };
# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More qw/no_plan/; #BEGIN { plan tests => 1 }; use Lingua::NL::Numbers; #use Lingua::NL::Numbers::GroeneBoekje; my $numbers = Lingua::NL::Numbers->new; #my $better = Lingua::NL::Numbers::GroeneBoekje->new; sub ts { my ($give,$expect) = @_; # print "GIVEN: [$give] GOT: [".$numbers->parse($give)."] EXPECTED [".$better->parse($give)."]\n"; ok($numbers->parse( $give ) eq $expect, $expect); } ts(123,'honderd drieentwintig'); ts(221011,'twee honderd een en twintig duizend, en elf'); ts(201011,'twee honderd een duizend, en elf'); ts(1000,'duizend'); ts(2000,'twee duizend'); ts(22,'tweeentwintig'); ts(2345678,'twee miljoen drie honderd vijf en veertig duizend, zeshonderd achtenzeventig'); ts(1000000000,'een miljard'); ts(23101011,'drie en twintig miljoen een honderd een duizend, en elf');