| 1 | # For Emacs: -*- mode:cperl; mode:folding -*- | ||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||
| 3 | package Lingua::NLD::Numbers; | ||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Numbers 2 word conversion in NLD. | ||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||
| 6 | # {{{ use block | ||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use 5.10.1; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Perl6::Export::Attrs; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||
| 15 | # }}} | ||||||||||||||||||||||||||||||||||||
| 16 | # {{{ variables declaration | ||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||
| 18 | 1 | our $VERSION = 0.0682; | |||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||
| 20 | 1 | my $numbers = { | |||||||||||||||||||||||||||||||||||
| 21 | 0 => 'nul', | ||||||||||||||||||||||||||||||||||||
| 22 | 1 => 'een', | ||||||||||||||||||||||||||||||||||||
| 23 | 2 => 'twee', | ||||||||||||||||||||||||||||||||||||
| 24 | 3 => 'drie', | ||||||||||||||||||||||||||||||||||||
| 25 | 4 => 'vier', | ||||||||||||||||||||||||||||||||||||
| 26 | 5 => 'vijf', | ||||||||||||||||||||||||||||||||||||
| 27 | 6 => 'zes', | ||||||||||||||||||||||||||||||||||||
| 28 | 7 => 'zeven', | ||||||||||||||||||||||||||||||||||||
| 29 | 8 => 'acht', | ||||||||||||||||||||||||||||||||||||
| 30 | 9 => 'negen', | ||||||||||||||||||||||||||||||||||||
| 31 | 10 => 'tien', | ||||||||||||||||||||||||||||||||||||
| 32 | 11 => 'elf', | ||||||||||||||||||||||||||||||||||||
| 33 | 12 => 'twaalf', | ||||||||||||||||||||||||||||||||||||
| 34 | 13 => 'dertien', | ||||||||||||||||||||||||||||||||||||
| 35 | 14 => 'veertien', | ||||||||||||||||||||||||||||||||||||
| 36 | 15 => 'vijftien', | ||||||||||||||||||||||||||||||||||||
| 37 | 16 => 'zestien', | ||||||||||||||||||||||||||||||||||||
| 38 | 17 => 'zeventien', | ||||||||||||||||||||||||||||||||||||
| 39 | 18 => 'achtien', | ||||||||||||||||||||||||||||||||||||
| 40 | 19 => 'negentien', | ||||||||||||||||||||||||||||||||||||
| 41 | 20 => 'twintig', | ||||||||||||||||||||||||||||||||||||
| 42 | 30 => 'dertig', | ||||||||||||||||||||||||||||||||||||
| 43 | 40 => 'veertig', | ||||||||||||||||||||||||||||||||||||
| 44 | 50 => 'vijftig', | ||||||||||||||||||||||||||||||||||||
| 45 | 60 => 'zestig', | ||||||||||||||||||||||||||||||||||||
| 46 | 70 => 'zeventig', | ||||||||||||||||||||||||||||||||||||
| 47 | 80 => 'tachtig', | ||||||||||||||||||||||||||||||||||||
| 48 | 90 => 'negentig', | ||||||||||||||||||||||||||||||||||||
| 49 | }; | ||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||
| 51 | # }}} | ||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||
| 53 | # {{{ new | ||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||
| 55 | sub new { | ||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | my $number = shift || ''; | ||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||
| 59 | 1 | my $self = {}; | |||||||||||||||||||||||||||||||||||
| 60 | 1 | bless $self, $class; | |||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | if( $number =~ /\d+/ ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 63 | 0 | return( $self->parse($number) ); | |||||||||||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||
| 66 | 1 | return( $self ); | |||||||||||||||||||||||||||||||||||
| 67 | }; | ||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||
| 69 | # }}} | ||||||||||||||||||||||||||||||||||||
| 70 | # {{{ parse | ||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||
| 72 | sub parse :Export { | ||||||||||||||||||||||||||||||||||||
| 73 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=30 SCAR=44.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | my $number = shift // return ''; | ||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() // (return "")
MC/DC100%1/1
shift() // (return "")
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||
| 76 | 3 | my $digits; | |||||||||||||||||||||||||||||||||||
| 77 | 3 | my $ret = ''; | |||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||
| 79 | 3 | ▶ | if( defined($numbers->{$number}) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 80 | 0 | $ret = $numbers->{$number}; | |||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||
| 82 | else { | ||||||||||||||||||||||||||||||||||||
| 83 | 3 | my $ret_array = []; | |||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||
| 85 | 3 | @{$digits} = reverse( split('', $number) ); | |||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||
| 87 | # tens of billions | ||||||||||||||||||||||||||||||||||||
| 88 | 3 | ▶ | if( defined($digits->[10]) && ($digits->[10] != 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/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 table66%2/3
A and B
A= defined $digits->[10]B= $digits->[10] != 0
| |||||||||||||||||||||||||||||||||||||
| 89 | 0 | my $temp = $self->_formatTens( $digits->[9], $digits->[10] ); | |||||||||||||||||||||||||||||||||||
| 90 | 0 | unshift @{$ret_array}, "$temp biljoen"; | |||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||
| 92 | ▶ | elsif( defined($digits->[9]) && ($digits->[9] != 0) ) { | |||||||||||||||||||||||||||||||||||
|
Condition66%2/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 table66%2/3
A and B
A= defined $digits->[9]B= $digits->[9] != 0
| |||||||||||||||||||||||||||||||||||||
| 93 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[9], ' biljoen' ); | |||||||||||||||||||||||||||||||||||
| 94 | }; | ||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||
| 96 | # hundreds of millions | ||||||||||||||||||||||||||||||||||||
| 97 | 3 | ▶ | if( defined($digits->[8]) && ($digits->[8] != 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/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 table66%2/3
A and B
A= defined $digits->[8]B= $digits->[8] != 0
| |||||||||||||||||||||||||||||||||||||
| 98 | 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
| |||||||||||||||||||||||||||||||||||||
| 99 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[8], ' honderd miljard' ); | |||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||
| 101 | else { | ||||||||||||||||||||||||||||||||||||
| 102 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[8], ' honderd' ); | |||||||||||||||||||||||||||||||||||
| 103 | }; | ||||||||||||||||||||||||||||||||||||
| 104 | }; | ||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||
| 106 | # tens of millions | ||||||||||||||||||||||||||||||||||||
| 107 | 3 | ▶ | if( defined($digits->[7]) && ($digits->[7] != 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/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 table66%2/3
A and B
A= defined $digits->[7]B= $digits->[7] != 0
| |||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $temp = $self->_formatTens( $digits->[6], $digits->[7] ); | |||||||||||||||||||||||||||||||||||
| 109 | 0 | unshift @{$ret_array}, "$temp miljard"; | |||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||
| 111 | ▶ | elsif( defined($digits->[6]) && ($digits->[6] != 0) ) { | |||||||||||||||||||||||||||||||||||
|
Condition66%2/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 table66%2/3
A and B
A= defined $digits->[6]B= $digits->[6] != 0
| |||||||||||||||||||||||||||||||||||||
| 112 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[6], ' miljard' ); | |||||||||||||||||||||||||||||||||||
| 113 | }; | ||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||
| 115 | # hundreds of thousands | ||||||||||||||||||||||||||||||||||||
| 116 | 3 | ▶ | if( defined($digits->[5]) && ($digits->[5] != 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $digits->[5] and $digits->[5] != 0
MC/DC100%2/2
defined $digits->[5] and $digits->[5] != 0
defined $digits->[5]
$digits->[5] != 0
Truth table100%3/3
A and B
A= defined $digits->[5]B= $digits->[5] != 0
| |||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | if( ($digits->[4] == 0) && ($digits->[3] == 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/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 table33%1/3
A and B
A= $digits->[4] == 0B= $digits->[3] == 0
| |||||||||||||||||||||||||||||||||||||
| 118 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[5], ' honderd duizend' ); | |||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||
| 120 | else { | ||||||||||||||||||||||||||||||||||||
| 121 | 1 | unshift @{$ret_array}, $self->_formatLarge( $digits->[5], ' honderd' ); | |||||||||||||||||||||||||||||||||||
| 122 | }; | ||||||||||||||||||||||||||||||||||||
| 123 | }; | ||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||
| 125 | # tens of thousands | ||||||||||||||||||||||||||||||||||||
| 126 | 3 | ▶ | if( defined($digits->[4]) && ($digits->[4] != 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
defined $digits->[4] and $digits->[4] != 0
MC/DC100%2/2
defined $digits->[4] and $digits->[4] != 0
defined $digits->[4]
$digits->[4] != 0
Truth table100%3/3
A and B
A= defined $digits->[4]B= $digits->[4] != 0
| |||||||||||||||||||||||||||||||||||||
| 127 | 1 | my $temp = $self->_formatTens( $digits->[3], $digits->[4] ); | |||||||||||||||||||||||||||||||||||
| 128 | 1 | unshift @{$ret_array}, "$temp duizend"; | |||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||
| 130 | ▶ | elsif( defined($digits->[3]) && ($digits->[3] == 1) && $number<2000) { # VSM - BUG | |||||||||||||||||||||||||||||||||||
|
Condition50%3/6
defined $digits->[3] and $digits->[3] == 1 and $number < 2000
defined $digits->[3] and $digits->[3] == 1
MC/DC0%0/3
defined $digits->[3] and $digits->[3] == 1 and $number < 2000
defined $digits->[3]
$digits->[3] == 1
$number < 2000
Truth table50%2/4
A and B and C
A= defined $digits->[3]B= $digits->[3] == 1C= $number < 2000
| |||||||||||||||||||||||||||||||||||||
| 131 | 0 | unshift @{$ret_array}, ' duizend'; | |||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||
| 133 | ▶ | elsif( defined($digits->[3]) && ($digits->[3] != 0) ) { | |||||||||||||||||||||||||||||||||||
|
Condition66%2/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 table66%2/3
A and B
A= defined $digits->[3]B= $digits->[3] != 0
| |||||||||||||||||||||||||||||||||||||
| 134 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[3], ' duizend' ); | |||||||||||||||||||||||||||||||||||
| 135 | }; | ||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||
| 137 | # hundreds | ||||||||||||||||||||||||||||||||||||
| 138 | 3 | ▶ | if( defined($digits->[2]) && ($digits->[2] == 1) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $digits->[2] and $digits->[2] == 1
MC/DC50%1/2
defined $digits->[2] and $digits->[2] == 1
defined $digits->[2]
$digits->[2] == 1
Truth table66%2/3
A and B
A= defined $digits->[2]B= $digits->[2] == 1
| |||||||||||||||||||||||||||||||||||||
| 139 | 1 | unshift @{$ret_array}, 'honderd'; | |||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||
| 141 | ▶ | elsif( defined($digits->[2]) && ($digits->[2] != 0) ) { | |||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $digits->[2] and $digits->[2] != 0
MC/DC50%1/2
defined $digits->[2] and $digits->[2] != 0
defined $digits->[2]
$digits->[2] != 0
Truth table66%2/3
A and B
A= defined $digits->[2]B= $digits->[2] != 0
| |||||||||||||||||||||||||||||||||||||
| 142 | 1 | unshift @{$ret_array}, $self->_formatLarge( $digits->[2], 'honderd' ); | |||||||||||||||||||||||||||||||||||
| 143 | }; | ||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||
| 145 | # tens | ||||||||||||||||||||||||||||||||||||
| 146 | 3 | unshift @{$ret_array}, $self->_formatTens( $digits->[0], $digits->[1], 'en' ); | |||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||
| 148 | 3 | $ret = $self->_sortReturn( $ret_array, $digits ); | |||||||||||||||||||||||||||||||||||
| 149 | }; | ||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||
| 151 | 3 | return( $ret ); | |||||||||||||||||||||||||||||||||||
| 152 | 1 | ▶ | }; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||
| 154 | # }}} | ||||||||||||||||||||||||||||||||||||
| 155 | # {{{ _sortReturn | ||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||
| 157 | sub _sortReturn { | ||||||||||||||||||||||||||||||||||||
| 158 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_sortReturn: called CC=12 SCAR=27.1
| |||||||||||||||||||||||||||||||||||||
| 159 | 3 | my $ret_array = shift; | |||||||||||||||||||||||||||||||||||
| 160 | 3 | my $digits = shift; | |||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||
| 162 | 3 | my $large_nums = 0; | |||||||||||||||||||||||||||||||||||
| 163 | 3 | my $ret = ''; | |||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||
| 165 | 3 | my $size = @{$ret_array}; | |||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||
| 167 | 3 | ▶ | if( $size == 1 ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 168 | 0 | return( $ret_array->[0] ); | |||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||
| 170 | elsif( $size > 1 ) { | ||||||||||||||||||||||||||||||||||||
| 171 | 2 | $large_nums = 1; | |||||||||||||||||||||||||||||||||||
| 172 | }; | ||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||
| 174 | 3 | ▶ | for( my $i = $size; $i > 0; $i-- ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||
| 176 | 6 | ▶ | if( defined($ret_array->[$i]) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 177 | 4 | ▶ | if( $ret_array->[$i] =~ /(miljard|duizend)/ ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 178 | 1 | $ret .= $ret_array->[$i] .', '; | |||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||
| 180 | else { | ||||||||||||||||||||||||||||||||||||
| 181 | 3 | $ret .= $ret_array->[$i] .' '; | |||||||||||||||||||||||||||||||||||
| 182 | }; | ||||||||||||||||||||||||||||||||||||
| 183 | }; | ||||||||||||||||||||||||||||||||||||
| 184 | }; | ||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||
| 186 | 3 | ▶ | if( ($digits->[0] == 0) && ($digits->[1] == 0) ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$digits->[0] == 0 and $digits->[1] == 0
MC/DC50%1/2
$digits->[0] == 0 and $digits->[1] == 0
$digits->[0] == 0
$digits->[1] == 0
Truth table66%2/3
A and B
A= $digits->[0] == 0B= $digits->[1] == 0
| |||||||||||||||||||||||||||||||||||||
| 187 | # do nothing | ||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||
| 189 | ▶ | elsif( ($digits->[0] == 0) || ($digits->[1] == 0) || ($digits->[1] == 1) ) { | |||||||||||||||||||||||||||||||||||
|
Condition33%2/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 table25%1/4
A or B or C
A= $digits->[0] == 0B= $digits->[1] == 0C= $digits->[1] == 1
| |||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if( $large_nums ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 191 | 0 | $ret .= ' en '; | |||||||||||||||||||||||||||||||||||
| 192 | }; | ||||||||||||||||||||||||||||||||||||
| 193 | 0 | $ret .= $ret_array->[0]; | |||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||
| 195 | else { | ||||||||||||||||||||||||||||||||||||
| 196 | 2 | $ret .= ' '. $ret_array->[0]; | |||||||||||||||||||||||||||||||||||
| 197 | }; | ||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||
| 199 | 3 | $ret =~ s/(^ |\s{2,}| $)/ /g; | |||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||
| 201 | 3 | return( $ret ); | |||||||||||||||||||||||||||||||||||
| 202 | }; | ||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||
| 204 | # }}} | ||||||||||||||||||||||||||||||||||||
| 205 | # {{{ _formatTens | ||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||
| 207 | sub _formatTens { | ||||||||||||||||||||||||||||||||||||
| 208 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_formatTens: called CC=7 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||
| 209 | 4 | my $units = shift; | |||||||||||||||||||||||||||||||||||
| 210 | 4 | my $tens = shift; | |||||||||||||||||||||||||||||||||||
| 211 | 4 | ▶ | my $en = shift || ' en '; | ||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || ' en '
MC/DC100%1/1
shift() || ' en '
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||
| 213 | # Both digits are zero | ||||||||||||||||||||||||||||||||||||
| 214 | 4 | ▶ | unless( $units || $tens ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$units or $tens
MC/DC50%1/2
$units or $tens
$units
$tens
Truth table66%2/3
A or B
A= $unitsB= $tens
| |||||||||||||||||||||||||||||||||||||
| 215 | 1 | return; | |||||||||||||||||||||||||||||||||||
| 216 | }; | ||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||
| 218 | 3 | ▶ | if( $tens == 0 ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 219 | 0 | return( $numbers->{$units} ); | |||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||
| 221 | ▶ | elsif( ($tens == 1) || ($units == 0) ) { | |||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$tens == 1 or $units == 0
MC/DC0%0/2
$tens == 1 or $units == 0
$tens == 1
$units == 0
Truth table33%1/3
A or B
A= $tens == 1B= $units == 0
| |||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $temp = $tens . $units; | |||||||||||||||||||||||||||||||||||
| 223 | 0 | return( $numbers->{$temp} ); | |||||||||||||||||||||||||||||||||||
| 224 | }; | ||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||
| 226 | 3 | my $temp = $tens . 0; | |||||||||||||||||||||||||||||||||||
| 227 | 3 | return( $numbers->{$units} . $en . $numbers->{$temp} ); | |||||||||||||||||||||||||||||||||||
| 228 | }; | ||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||
| 230 | # }}} | ||||||||||||||||||||||||||||||||||||
| 231 | # {{{ _formatLarge | ||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||
| 233 | sub _formatLarge { | ||||||||||||||||||||||||||||||||||||
| 234 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||
|
Subroutine
_formatLarge: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 235 | 2 | my $digit = shift; | |||||||||||||||||||||||||||||||||||
| 236 | 2 | my $word = shift; | |||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||
| 238 | 2 | my $ret = "$numbers->{$digit}$word"; | |||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||
| 240 | 2 | return( $ret ); | |||||||||||||||||||||||||||||||||||
| 241 | }; | ||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||
| 243 | # }}} | ||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||
| 245 | 1 | 1; | |||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||
| 247 | =pod | ||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||
| 249 | =head1 NAME | ||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||
| 251 | Lingua::NLD::Numbers | ||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||
| 253 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||
| 255 | version 0.0682 | ||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||
| 257 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||
| 259 | Numbers 2 word conversion in NLD. | ||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||
| 261 | This is PetaMem release. Lingua::NLD::Numbers converts | ||||||||||||||||||||||||||||||||||||
| 262 | numeric values into their Dutch equivalents. | ||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||
| 264 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||
| 266 | use Lingua::NLD::Numbers; | ||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||
| 268 | my $numbers = Lingua::NLD::Numbers->new(); | ||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||
| 270 | my $text = $numbers->parse( 123 ); | ||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||
| 272 | # prints 'een honderd, drie en twintig' | ||||||||||||||||||||||||||||||||||||
| 273 | print $text; | ||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||
| 275 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||
| 277 | =over | ||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||
| 279 | =item new | ||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||
| 281 | =item parse | ||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||
| 283 | Private | ||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||
| 285 | =back | ||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||
| 287 | =head1 KNOWN BUGS | ||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||
| 289 | None, but that does not mean there are not any. | ||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||
| 291 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||
| 293 | Alistair Francis, <cpan@alizta.com> | ||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||
| 295 | Maintenance | ||||||||||||||||||||||||||||||||||||
| 296 | PetaMem s.r.o., <info@petamem.com> | ||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||
| 298 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||
| 300 | Perl 5 license. | ||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||
| 302 | Original license is not known. PetaMem added | ||||||||||||||||||||||||||||||||||||
| 303 | Perl 5 license as default. | ||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||
| 305 | =cut | ||||||||||||||||||||||||||||||||||||