| 1 | # For Emacs: -*- mode:cperl; mode:folding -*- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Lingua::AFR::Numbers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Converts numeric values into their Afrikaans equivalents. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # {{{ use block | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use 5.10.1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Perl6::Export::Attrs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # }}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # {{{ variables declaration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | our $VERSION = 0.1106; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | my $numbers = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 => 'nul', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 => 'een', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 => 'twee', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 => 'drie', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 4 => 'vier', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 => 'vyf', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 6 => 'ses', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 7 => 'sewe', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 8 => 'agt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 9 => 'nege', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 10 => 'tien', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 11 => 'elf', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 12 => 'twaalf', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 13 => 'dertien', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 14 => 'viertien', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 15 => 'vyftien', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 16 => 'sestien', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 17 => 'sewentien', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 18 => 'agtien', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 19 => 'negentien', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 20 => 'twintig', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 30 => 'dertig', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 40 => 'viertig', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 50 => 'vyftig', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 60 => 'sestig', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 70 => 'sewentig', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 80 => 'tagtig', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 90 => 'negentig', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # }}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # {{{ new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | my $number = shift || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | ▶ | if ($number =~ /\d+/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return( $self->parse($number) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # }}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # {{{ parse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | sub parse :Export { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | my $self = shift // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=29 SCAR=50.4
Pod
documented
Condition50%1/2
shift() // (return)
MC/DC0%0/1
shift() // (return)
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 4 | my $number = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 4 | my $digits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | my $ret = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | ▶ | croak 'You should specify a number from interval [0, 99_999_999_999]' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
not defined $number && $number =~ /\A\d+\z/msx or $number < 0 or $number > '99999999999'
not defined $number && $number =~ /\A\d+\z/msx or $number < 0
defined $number && $number =~ /\A\d+\z/msx
MC/DC50%2/4
not defined $number && $number =~ /\A\d+\z/msx or $number < 0 or $number > '99999999999'
defined $number
$number =~ /\A\d+\z/msx
$number < 0
$number > '99999999999'
Truth table60%3/5
not(A && B) or C or D
A= defined $numberB= $number =~ /\A\d+\z/msxC= $number < 0D= $number > '99999999999'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | if !defined $number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | || $number !~ m{\A\d+\z}xms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | || $number < 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | || $number > 99_999_999_999; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | ▶ | if( defined($numbers->{$number}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $ret = $numbers->{$number}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | my $ret_array = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | @{$digits} = reverse( split('', $number) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # tens of billions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | if( defined($digits->[10]) && ($digits->[10] != 0) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/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 table33%1/3
A and B
A= defined $digits->[10]B= $digits->[10] != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $temp = $self->_formatTens( $digits->[9], $digits->[10] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | unshift @{$ret_array}, "$temp biljoen"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ▶ | elsif( defined($digits->[9]) && ($digits->[9] != 0) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/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 table33%1/3
A and B
A= defined $digits->[9]B= $digits->[9] != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[9], 'biljoen' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # hundreds of millions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | ▶ | if( defined($digits->[8]) && ($digits->[8] != 0) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/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 table33%1/3
A and B
A= defined $digits->[8]B= $digits->[8] != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[8], 'honderd miljoen' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[8], 'honderd' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # tens of millions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | ▶ | if( defined($digits->[7]) && ($digits->[7] != 0) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/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 table33%1/3
A and B
A= defined $digits->[7]B= $digits->[7] != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $temp = $self->_formatTens( $digits->[6], $digits->[7] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | unshift @{$ret_array}, "$temp miljoen"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ▶ | elsif( defined($digits->[6]) && ($digits->[6] != 0) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/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 table33%1/3
A and B
A= defined $digits->[6]B= $digits->[6] != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[6], 'miljoen' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # hundreds of thousands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | ▶ | if( defined($digits->[5]) && ($digits->[5] != 0) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/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 table33%1/3
A and B
A= defined $digits->[5]B= $digits->[5] != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[5], 'honderd duisend' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[5], 'honderd' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # tens of thousands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | ▶ | if( defined($digits->[4]) && ($digits->[4] != 0) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $digits->[4] and $digits->[4] != 0
MC/DC50%1/2
defined $digits->[4] and $digits->[4] != 0
defined $digits->[4]
$digits->[4] != 0
Truth table66%2/3
A and B
A= defined $digits->[4]B= $digits->[4] != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | my $temp = $self->_formatTens( $digits->[3], $digits->[4] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | unshift @{$ret_array}, "$temp duisend"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ▶ | elsif( defined($digits->[3]) && ($digits->[3] != 0) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/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 table33%1/3
A and B
A= defined $digits->[3]B= $digits->[3] != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | unshift @{$ret_array}, $self->_formatLarge( $digits->[3], 'duisend' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # hundreds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | ▶ | if( defined($digits->[2]) && ($digits->[2] != 0) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/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 table33%1/3
A and B
A= defined $digits->[2]B= $digits->[2] != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | unshift @{$ret_array}, $self->_formatLarge( $digits->[2], 'honderd' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # tens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | unshift @{$ret_array}, $self->_formatTens( $digits->[0], $digits->[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | $ret = $self->_sortReturn( $ret_array, $digits ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | return( $ret ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # }}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # {{{ _sortReturn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | sub _sortReturn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sortReturn: called CC=12 SCAR=29.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | my $ret_array = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | my $digits = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | my $large_nums = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | my $ret = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | my $size = @{$ret_array}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | ▶ | if( $size == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | return( $ret_array->[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | elsif( $size > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | $large_nums = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | ▶ | for( my $i = $size; $i > 0; $i-- ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 5 | ▶ | if( defined($ret_array->[$i]) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | ▶ | if( $ret_array->[$i] =~ /(miljoen|duisend)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | $ret .= $ret_array->[$i] .', '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | $ret .= $ret_array->[$i] .' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | ▶ | if( ($digits->[0] == 0) && ($digits->[1] == 0) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/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 table33%1/3
A and B
A= $digits->[0] == 0B= $digits->[1] == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $ret .= ' ' . $ret_array->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if( $large_nums ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $ret .= ' en '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $ret .= $ret_array->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | $ret .= ' ' . $ret_array->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | $ret =~ s/(^ |\s{2,}| $)/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 2 | return( $ret ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # }}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # {{{ _formatTens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | sub _formatTens { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_formatTens: called CC=6 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 3 | my $units = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 3 | my $tens = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # Both digits are zero | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 3 | ▶ | unless( $units || $tens ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$units or $tens
MC/DC0%0/2
$units or $tens
$units
$tens
Truth table33%1/3
A or B
A= $unitsB= $tens
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 3 | ▶ | if( $tens == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | return( $numbers->{$units} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | ▶ | elsif( ($tens == 1) || ($units == 0) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$tens == 1 or $units == 0
MC/DC50%1/2
$tens == 1 or $units == 0
$tens == 1
$units == 0
Truth table66%2/3
A or B
A= $tens == 1B= $units == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | my $temp = $tens . $units; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | return( $numbers->{$temp} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 2 | my $temp = $tens . 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | 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::AFR::Numbers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | version 0.1106 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | Converts numeric values into their Afrikaans equivalents. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | This is PetaMem release. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | use Lingua::AFR::Numbers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | my $numbers = Lingua::AFR::Numbers->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | my $text = $numbers->parse( 123 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # prints 'een honderd, drie en twintig' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | print $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | =item new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | constructor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | =item parse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | Convert number to string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | Only numbers from interval [0, 99 999 999 999] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | will be converted. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | =head1 KNOWN BUGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | None, but that does not mean there are not any. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | Alistair Francis, <cpan@alizta.com> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | Maintenance: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | PetaMem s.r.o., <info@petamem.com> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | Perl 5 license. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | This module was originally released without any known license. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | PetaMem added standard Perl 5 license as default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||