line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::JBO::Numbers; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
24418
|
use 5.008_001; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
98
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
71
|
|
5
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
65
|
|
6
|
2
|
|
|
2
|
|
933
|
use Readonly; |
|
2
|
|
|
|
|
7066
|
|
|
2
|
|
|
|
|
150
|
|
7
|
2
|
|
|
2
|
|
1071
|
use Regexp::Common qw( number ); |
|
2
|
|
|
|
|
6492
|
|
|
2
|
|
|
|
|
18
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
4208
|
use base qw( Exporter ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1466
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw( num2jbo num2jbo_ordinal ); |
11
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => \@EXPORT_OK ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly my $EMPTY_STR => q{}; |
16
|
|
|
|
|
|
|
Readonly my $ORDINAL_SUFFIX => q{moi}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Readonly my @NAMES => qw< no pa re ci vo mu xa ze bi so >; |
19
|
|
|
|
|
|
|
Readonly my %WORDS => ( |
20
|
|
|
|
|
|
|
'.' => "pi", |
21
|
|
|
|
|
|
|
',' => "ki'o", |
22
|
|
|
|
|
|
|
'-' => "ni'u", |
23
|
|
|
|
|
|
|
'+' => "ma'u", |
24
|
|
|
|
|
|
|
inf => "ci'i", |
25
|
|
|
|
|
|
|
NaN => "na namcu", |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub num2jbo { |
29
|
89
|
|
|
89
|
1
|
27512
|
my ($number) = @_; |
30
|
89
|
|
|
|
|
129
|
my @names; |
31
|
|
|
|
|
|
|
|
32
|
89
|
100
|
|
|
|
227
|
return unless defined $number; |
33
|
88
|
100
|
|
|
|
265
|
return $WORDS{NaN} if $number eq 'NaN'; |
34
|
|
|
|
|
|
|
|
35
|
87
|
100
|
|
|
|
718
|
if ($number =~ m/^ ( [-+] )? inf $/ix) { |
|
|
100
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# infinity |
37
|
3
|
100
|
|
|
|
22
|
push @names, $1 ? $WORDS{$1} : (), $WORDS{inf}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif ($number =~ m/^ $RE{num}{real}{-keep} $/x) { |
40
|
77
|
|
|
|
|
14254
|
my ($sign, $int, $frac) = ($2, $4, $6); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# sign and integer |
43
|
207
|
|
|
|
|
2773
|
push @names, ( |
44
|
|
|
|
|
|
|
$WORDS{$sign} || (), |
45
|
77
|
50
|
66
|
|
|
359
|
map { $NAMES[$_] } split $EMPTY_STR, defined $int ? $int : $EMPTY_STR, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# fraction |
49
|
77
|
100
|
100
|
|
|
840
|
if (defined $frac && $frac ne $EMPTY_STR) { |
50
|
20
|
|
|
|
|
202
|
push @names, ( |
51
|
|
|
|
|
|
|
$WORDS{'.'}, |
52
|
14
|
|
|
|
|
121
|
map { $NAMES[$_] } split $EMPTY_STR, $frac, |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
7
|
|
|
|
|
1036
|
return; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
80
|
|
|
|
|
934
|
return join $EMPTY_STR, @names; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub num2jbo_ordinal { |
64
|
25
|
|
|
25
|
1
|
18585
|
my ($number) = @_; |
65
|
25
|
|
|
|
|
60
|
my $name = num2jbo($number); |
66
|
|
|
|
|
|
|
|
67
|
25
|
50
|
|
|
|
210
|
return unless defined $name; |
68
|
25
|
|
|
|
|
78
|
return $name . $ORDINAL_SUFFIX; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |