| 1 | package Lingua::NL::Numbers; | ||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||
| 3 | 1 | $VERSION = '1.3'; | |||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||
| 7 | 1 | my $numbers = { | |||||||||||||||||||||||||||||||||||
| 8 | 0 => 'nul', | ||||||||||||||||||||||||||||||||||||
| 9 | 1 => 'een', | ||||||||||||||||||||||||||||||||||||
| 10 | 2 => 'twee', | ||||||||||||||||||||||||||||||||||||
| 11 | 3 => 'drie', | ||||||||||||||||||||||||||||||||||||
| 12 | 4 => 'vier', | ||||||||||||||||||||||||||||||||||||
| 13 | 5 => 'vijf', | ||||||||||||||||||||||||||||||||||||
| 14 | 6 => 'zes', | ||||||||||||||||||||||||||||||||||||
| 15 | 7 => 'zeven', | ||||||||||||||||||||||||||||||||||||
| 16 | 8 => 'acht', | ||||||||||||||||||||||||||||||||||||
| 17 | 9 => 'negen', | ||||||||||||||||||||||||||||||||||||
| 18 | 10 => 'tien', | ||||||||||||||||||||||||||||||||||||
| 19 | 11 => 'elf', | ||||||||||||||||||||||||||||||||||||
| 20 | 12 => 'twaalf', | ||||||||||||||||||||||||||||||||||||
| 21 | 13 => 'dertien', | ||||||||||||||||||||||||||||||||||||
| 22 | 14 => 'veertien', | ||||||||||||||||||||||||||||||||||||
| 23 | 15 => 'vijftien', | ||||||||||||||||||||||||||||||||||||
| 24 | 16 => 'zestien', | ||||||||||||||||||||||||||||||||||||
| 25 | 17 => 'zeventien', | ||||||||||||||||||||||||||||||||||||
| 26 | 18 => 'achtien', | ||||||||||||||||||||||||||||||||||||
| 27 | 19 => 'negentien', | ||||||||||||||||||||||||||||||||||||
| 28 | 20 => 'twintig', | ||||||||||||||||||||||||||||||||||||
| 29 | 30 => 'dertig', | ||||||||||||||||||||||||||||||||||||
| 30 | 40 => 'veertig', | ||||||||||||||||||||||||||||||||||||
| 31 | 50 => 'vijftig', | ||||||||||||||||||||||||||||||||||||
| 32 | 60 => 'zestig', | ||||||||||||||||||||||||||||||||||||
| 33 | 70 => 'zeventig', | ||||||||||||||||||||||||||||||||||||
| 34 | 80 => 'tachtig', | ||||||||||||||||||||||||||||||||||||
| 35 | 90 => 'negentig', | ||||||||||||||||||||||||||||||||||||
| 36 | }; | ||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||
| 38 | sub new | ||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $number = shift || ''; | ||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $self = {}; | |||||||||||||||||||||||||||||||||||
| 44 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if( $number =~ /\d+/ ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 47 | 0 | return( $self->parse($number) ); | |||||||||||||||||||||||||||||||||||
| 48 | }; | ||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||
| 50 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||
| 51 | }; | ||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||
| 54 | sub parse | ||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=28 SCAR=67.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 57 | 0 | my $number = shift; | |||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $digits; | |||||||||||||||||||||||||||||||||||
| 60 | 0 | my $ret = ''; | |||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if( defined($numbers->{$number}) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 63 | 0 | $ret = $numbers->{$number}; | |||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||
| 65 | else { | ||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $ret_array = []; | |||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||
| 68 | 0 | @{$digits} = reverse( split('', $number) ); | |||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||
| 70 | # tens of billions | ||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if( defined($digits->[10]) && ($digits->[10] != 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $digits->[10] and $digits->[10] != 0
MC/DC0%0/2
defined $digits->[10] and $digits->[10] != 0
defined $digits->[10]
$digits->[10] != 0
Truth table0%0/3
A and B
A= defined $digits->[10]B= $digits->[10] != 0
| |||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $temp = $self->_formatTens( $digits->[9], $digits->[10] ); | |||||||||||||||||||||||||||||||||||
| 73 | 0 | unshift @{$ret_array}, "$temp biljoen"; | |||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||
| 75 | ▶ | elsif( defined($digits->[9]) && ($digits->[9] != 0) ) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $digits->[9] and $digits->[9] != 0
MC/DC0%0/2
defined $digits->[9] and $digits->[9] != 0
defined $digits->[9]
$digits->[9] != 0
Truth table0%0/3
A and B
A= defined $digits->[9]B= $digits->[9] != 0
| |||||||||||||||||||||||||||||||||||||
| 76 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[9], ' biljoen' ); | |||||||||||||||||||||||||||||||||||
| 77 | }; | ||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||
| 79 | # hundreds of millions | ||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if( defined($digits->[8]) && ($digits->[8] != 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $digits->[8] and $digits->[8] != 0
MC/DC0%0/2
defined $digits->[8] and $digits->[8] != 0
defined $digits->[8]
$digits->[8] != 0
Truth table0%0/3
A and B
A= defined $digits->[8]B= $digits->[8] != 0
| |||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if( ($digits->[7] == 0) && ($digits->[6] == 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$digits->[7] == 0 and $digits->[6] == 0
MC/DC0%0/2
$digits->[7] == 0 and $digits->[6] == 0
$digits->[7] == 0
$digits->[6] == 0
Truth table0%0/3
A and B
A= $digits->[7] == 0B= $digits->[6] == 0
| |||||||||||||||||||||||||||||||||||||
| 82 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[8], ' honderd miljard' ); | |||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||
| 84 | else { | ||||||||||||||||||||||||||||||||||||
| 85 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[8], ' honderd' ); | |||||||||||||||||||||||||||||||||||
| 86 | }; | ||||||||||||||||||||||||||||||||||||
| 87 | }; | ||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||
| 89 | # tens of millions | ||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if( defined($digits->[7]) && ($digits->[7] != 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $digits->[7] and $digits->[7] != 0
MC/DC0%0/2
defined $digits->[7] and $digits->[7] != 0
defined $digits->[7]
$digits->[7] != 0
Truth table0%0/3
A and B
A= defined $digits->[7]B= $digits->[7] != 0
| |||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $temp = $self->_formatTens( $digits->[6], $digits->[7] ); | |||||||||||||||||||||||||||||||||||
| 92 | 0 | unshift @{$ret_array}, "$temp miljard"; | |||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||
| 94 | ▶ | elsif( defined($digits->[6]) && ($digits->[6] != 0) ) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $digits->[6] and $digits->[6] != 0
MC/DC0%0/2
defined $digits->[6] and $digits->[6] != 0
defined $digits->[6]
$digits->[6] != 0
Truth table0%0/3
A and B
A= defined $digits->[6]B= $digits->[6] != 0
| |||||||||||||||||||||||||||||||||||||
| 95 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[6], ' miljard' ); | |||||||||||||||||||||||||||||||||||
| 96 | }; | ||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||
| 98 | # hundreds of thousands | ||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if( defined($digits->[5]) && ($digits->[5] != 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $digits->[5] and $digits->[5] != 0
MC/DC0%0/2
defined $digits->[5] and $digits->[5] != 0
defined $digits->[5]
$digits->[5] != 0
Truth table0%0/3
A and B
A= defined $digits->[5]B= $digits->[5] != 0
| |||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if( ($digits->[4] == 0) && ($digits->[3] == 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$digits->[4] == 0 and $digits->[3] == 0
MC/DC0%0/2
$digits->[4] == 0 and $digits->[3] == 0
$digits->[4] == 0
$digits->[3] == 0
Truth table0%0/3
A and B
A= $digits->[4] == 0B= $digits->[3] == 0
| |||||||||||||||||||||||||||||||||||||
| 101 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[5], ' honderd duizend' ); | |||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||
| 103 | else { | ||||||||||||||||||||||||||||||||||||
| 104 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[5], ' honderd' ); | |||||||||||||||||||||||||||||||||||
| 105 | }; | ||||||||||||||||||||||||||||||||||||
| 106 | }; | ||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||
| 108 | # tens of thousands | ||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if( defined($digits->[4]) && ($digits->[4] != 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
defined $digits->[4] and $digits->[4] != 0
MC/DC0%0/2
defined $digits->[4] and $digits->[4] != 0
defined $digits->[4]
$digits->[4] != 0
Truth table0%0/3
A and B
A= defined $digits->[4]B= $digits->[4] != 0
| |||||||||||||||||||||||||||||||||||||
| 110 | 0 | my $temp = $self->_formatTens( $digits->[3], $digits->[4] ); | |||||||||||||||||||||||||||||||||||
| 111 | 0 | unshift @{$ret_array}, "$temp duizend"; | |||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||
| 113 | ▶ | elsif( defined($digits->[3]) && ($digits->[3] == 1) ) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $digits->[3] and $digits->[3] == 1
MC/DC0%0/2
defined $digits->[3] and $digits->[3] == 1
defined $digits->[3]
$digits->[3] == 1
Truth table0%0/3
A and B
A= defined $digits->[3]B= $digits->[3] == 1
| |||||||||||||||||||||||||||||||||||||
| 114 | 0 | unshift @{$ret_array}, ' duizend'; | |||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||
| 116 | ▶ | elsif( defined($digits->[3]) && ($digits->[3] != 0) ) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $digits->[3] and $digits->[3] != 0
MC/DC0%0/2
defined $digits->[3] and $digits->[3] != 0
defined $digits->[3]
$digits->[3] != 0
Truth table0%0/3
A and B
A= defined $digits->[3]B= $digits->[3] != 0
| |||||||||||||||||||||||||||||||||||||
| 117 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[3], ' duizend' ); | |||||||||||||||||||||||||||||||||||
| 118 | }; | ||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||
| 120 | # hundreds | ||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if( defined($digits->[2]) && ($digits->[2] == 1) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $digits->[2] and $digits->[2] == 1
MC/DC0%0/2
defined $digits->[2] and $digits->[2] == 1
defined $digits->[2]
$digits->[2] == 1
Truth table0%0/3
A and B
A= defined $digits->[2]B= $digits->[2] == 1
| |||||||||||||||||||||||||||||||||||||
| 122 | 0 | unshift @{$ret_array}, 'honderd'; | |||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||
| 124 | ▶ | elsif( defined($digits->[2]) && ($digits->[2] != 0) ) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $digits->[2] and $digits->[2] != 0
MC/DC0%0/2
defined $digits->[2] and $digits->[2] != 0
defined $digits->[2]
$digits->[2] != 0
Truth table0%0/3
A and B
A= defined $digits->[2]B= $digits->[2] != 0
| |||||||||||||||||||||||||||||||||||||
| 125 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[2], 'honderd' ); | |||||||||||||||||||||||||||||||||||
| 126 | }; | ||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||
| 128 | # tens | ||||||||||||||||||||||||||||||||||||
| 129 | 0 | unshift @{$ret_array}, $self->_formatTens( $digits->[0], $digits->[1], 'en' ); | |||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||
| 131 | 0 | $ret = $self->_sortReturn( $ret_array, $digits ); | |||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||
| 133 | }; | ||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||
| 135 | 0 | return( $ret ); | |||||||||||||||||||||||||||||||||||
| 136 | }; | ||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||
| 139 | sub _sortReturn | ||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
_sortReturn: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 142 | 0 | my $ret_array = shift; | |||||||||||||||||||||||||||||||||||
| 143 | 0 | my $digits = shift; | |||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $large_nums = 0; | |||||||||||||||||||||||||||||||||||
| 146 | 0 | my $ret = ''; | |||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $size = @{$ret_array}; | |||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if( $size == 1 ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 151 | 0 | return( $ret_array->[0] ); | |||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||
| 153 | elsif( $size > 1 ) { | ||||||||||||||||||||||||||||||||||||
| 154 | 0 | $large_nums = 1; | |||||||||||||||||||||||||||||||||||
| 155 | }; | ||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | for( my $i = $size; $i > 0; $i-- ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if( defined($ret_array->[$i]) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if( $ret_array->[$i] =~ /(miljard|duizend)/ ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 161 | 0 | $ret .= $ret_array->[$i] .', '; | |||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||
| 163 | else { | ||||||||||||||||||||||||||||||||||||
| 164 | 0 | $ret .= $ret_array->[$i] .' '; | |||||||||||||||||||||||||||||||||||
| 165 | }; | ||||||||||||||||||||||||||||||||||||
| 166 | }; | ||||||||||||||||||||||||||||||||||||
| 167 | }; | ||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if( ($digits->[0] == 0) && ($digits->[1] == 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$digits->[0] == 0 and $digits->[1] == 0
MC/DC0%0/2
$digits->[0] == 0 and $digits->[1] == 0
$digits->[0] == 0
$digits->[1] == 0
Truth table0%0/3
A and B
A= $digits->[0] == 0B= $digits->[1] == 0
| |||||||||||||||||||||||||||||||||||||
| 170 | # do nothing | ||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||
| 172 | ▶ | elsif( ($digits->[0] == 0) || ($digits->[1] == 0) || ($digits->[1] == 1) ) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$digits->[0] == 0 or $digits->[1] == 0 or $digits->[1] == 1
$digits->[0] == 0 or $digits->[1] == 0
MC/DC0%0/3
$digits->[0] == 0 or $digits->[1] == 0 or $digits->[1] == 1
$digits->[0] == 0
$digits->[1] == 0
$digits->[1] == 1
Truth table0%0/4
A or B or C
A= $digits->[0] == 0B= $digits->[1] == 0C= $digits->[1] == 1
| |||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if( $large_nums ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 174 | 0 | $ret .= ' en '; | |||||||||||||||||||||||||||||||||||
| 175 | }; | ||||||||||||||||||||||||||||||||||||
| 176 | 0 | $ret .= $ret_array->[0]; | |||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||
| 178 | else { | ||||||||||||||||||||||||||||||||||||
| 179 | 0 | $ret .= ' '. $ret_array->[0]; | |||||||||||||||||||||||||||||||||||
| 180 | }; | ||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||
| 182 | 0 | $ret =~ s/(^ |\s{2,}| $)/ /g; | |||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||
| 184 | 0 | return( $ret ); | |||||||||||||||||||||||||||||||||||
| 185 | }; | ||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||
| 188 | sub _formatTens | ||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
_formatTens: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 191 | 0 | my $units = shift; | |||||||||||||||||||||||||||||||||||
| 192 | 0 | my $tens = shift; | |||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | my $en = shift || ' en '; | ||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ' en '
MC/DC0%0/1
shift() || ' en '
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||
| 195 | # Both digits are zero | ||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | unless( $units || $tens ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$units or $tens
MC/DC0%0/2
$units or $tens
$units
$tens
Truth table0%0/3
A or B
A= $unitsB= $tens
| |||||||||||||||||||||||||||||||||||||
| 197 | 0 | return; | |||||||||||||||||||||||||||||||||||
| 198 | }; | ||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if( $tens == 0 ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 201 | 0 | return( $numbers->{$units} ); | |||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||
| 203 | ▶ | elsif( ($tens == 1) || ($units == 0) ) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$tens == 1 or $units == 0
MC/DC0%0/2
$tens == 1 or $units == 0
$tens == 1
$units == 0
Truth table0%0/3
A or B
A= $tens == 1B= $units == 0
| |||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $temp = $tens . $units; | |||||||||||||||||||||||||||||||||||
| 205 | 0 | return( $numbers->{$temp} ); | |||||||||||||||||||||||||||||||||||
| 206 | }; | ||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $temp = $tens . 0; | |||||||||||||||||||||||||||||||||||
| 209 | 0 | return( $numbers->{$units} . $en . $numbers->{$temp} ); | |||||||||||||||||||||||||||||||||||
| 210 | }; | ||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||
| 213 | sub _formatLarge | ||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||
|
Subroutine
_formatLarge: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||
| 216 | 0 | my $digit = shift; | |||||||||||||||||||||||||||||||||||
| 217 | 0 | my $word = shift; | |||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $ret = "$numbers->{$digit}$word"; | |||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||
| 221 | 0 | return( $ret ); | |||||||||||||||||||||||||||||||||||
| 222 | }; | ||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||
| 227 | 1 | 1; | |||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||
| 229 | =pod | ||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||
| 231 | =head1 NAME | ||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||
| 233 | Lingua::NL::Numbers - Perl module for converting numeric values into their Dutch equivalents | ||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||
| 236 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||
| 238 | Initial release, documentation and updates will follow. | ||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||
| 240 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||
| 242 | use Lingua::NL::Numbers; | ||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||
| 244 | my $numbers = Lingua::NL::Numbers->new; | ||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||
| 246 | my $text = $numbers->parse( 123 ); | ||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||
| 248 | # prints 'een honderd, drie en twintig' | ||||||||||||||||||||||||||||||||||||
| 249 | print $text; | ||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||
| 252 | =head1 KNOWN BUGS | ||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||
| 254 | None, but that does not mean there are not any. | ||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||
| 256 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||
| 258 | Alistair Francis, http://search.cpan.org/~friffin/ | ||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||
| 260 | =cut | ||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||