line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::TokiPona::Numbers; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
29160
|
use 5.008_001; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
105
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
58
|
|
5
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
6
|
2
|
|
|
2
|
|
864
|
use Readonly; |
|
2
|
|
|
|
|
3583
|
|
|
2
|
|
|
|
|
122
|
|
7
|
2
|
|
|
2
|
|
14
|
use Scalar::Util qw( looks_like_number ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
246
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
11
|
use base qw( Exporter ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
896
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw( num2tokipona num2tokipona_ordinal ); |
11
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => \@EXPORT_OK ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly my $EMPTY_STR => q{}; |
16
|
|
|
|
|
|
|
Readonly my $SPACE => q{ }; |
17
|
|
|
|
|
|
|
Readonly my $MINUS => q{-}; |
18
|
|
|
|
|
|
|
Readonly my $ORDINAL_PARTICLE => q{nanpa}; |
19
|
|
|
|
|
|
|
Readonly my @NAMES => qw< ala wan tu mute ale >; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub num2tokipona { |
22
|
62
|
|
|
62
|
1
|
41404
|
my ($number) = @_; |
23
|
|
|
|
|
|
|
|
24
|
62
|
100
|
|
|
|
343
|
return unless looks_like_number $number; |
25
|
54
|
100
|
|
|
|
167
|
return $NAMES[0] if $number eq 'NaN'; |
26
|
|
|
|
|
|
|
|
27
|
53
|
|
|
|
|
140
|
$number =~ s{^ ( [+-] ) }{}x; |
28
|
53
|
|
66
|
|
|
345
|
my $sign = $1 || $EMPTY_STR; |
29
|
|
|
|
|
|
|
|
30
|
53
|
100
|
|
|
|
480
|
return do { |
31
|
53
|
100
|
|
|
|
240
|
if ($number eq 'inf') { $NAMES[4] } |
|
3
|
100
|
|
|
|
12
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
32
|
6
|
|
|
|
|
19
|
elsif ($number == 0 ) { $NAMES[0] } |
33
|
15
|
|
|
|
|
54
|
elsif ($number <= 1 ) { $NAMES[1] } |
34
|
4
|
|
|
|
|
15
|
elsif ($number <= 2 ) { $NAMES[2] } |
35
|
25
|
|
|
|
|
100
|
else { $NAMES[3] } |
36
|
|
|
|
|
|
|
} . ($sign eq $MINUS ? $SPACE . $NAMES[0] : $EMPTY_STR); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub num2tokipona_ordinal { |
40
|
10
|
|
|
10
|
1
|
5855
|
my ($number) = @_; |
41
|
10
|
|
|
|
|
26
|
my $name = num2tokipona($number); |
42
|
|
|
|
|
|
|
|
43
|
10
|
50
|
|
|
|
222
|
return unless $name; |
44
|
10
|
|
|
|
|
25
|
return "$ORDINAL_PARTICLE $name"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |