line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::ID::Number::Format::MixWithWords; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2015-09-03'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.06'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
846
|
use 5.010001; |
|
2
|
|
|
|
|
7
|
|
7
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
42
|
|
8
|
2
|
|
|
2
|
|
44
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1947
|
use Lingua::Base::Number::Format::MixWithWords; |
|
2
|
|
|
|
|
52452
|
|
|
2
|
|
|
|
|
75
|
|
11
|
2
|
|
|
2
|
|
1673
|
use parent qw(Lingua::Base::Number::Format::MixWithWords); |
|
2
|
|
|
|
|
565
|
|
|
2
|
|
|
|
|
46
|
|
12
|
|
|
|
|
|
|
require Lingua::EN::Number::Format::MixWithWords; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
1680
|
use Exporter::Lite; |
|
2
|
|
|
|
|
1308
|
|
|
2
|
|
|
|
|
11
|
|
15
|
2
|
|
|
2
|
|
102
|
use Math::Round qw(nearest); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
94
|
|
16
|
2
|
|
|
2
|
|
11
|
use Number::Format; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
64
|
|
17
|
2
|
|
|
2
|
|
10
|
use POSIX qw(floor log10); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
21
|
|
18
|
2
|
|
|
2
|
|
1798
|
use Perinci::Sub::Util qw(gen_modified_sub); |
|
2
|
|
|
|
|
4166
|
|
|
2
|
|
|
|
|
586
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @EXPORT_OK = qw(format_number_mix); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our %SPEC; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
gen_modified_sub( |
25
|
|
|
|
|
|
|
output_name => 'format_number_mix', |
26
|
|
|
|
|
|
|
summary => 'Format number to a mixture of numbers and words (e.g. "12,3 juta")', |
27
|
|
|
|
|
|
|
base_name => 'Lingua::EN::Number::Format::MixWithWords::format_number_mix', |
28
|
|
|
|
|
|
|
remove_args => ['scale'], |
29
|
|
|
|
|
|
|
output_code => sub { |
30
|
16
|
|
|
16
|
|
29511
|
my %args = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $f = __PACKAGE__->new( |
33
|
|
|
|
|
|
|
num_decimal => $args{num_decimal}, |
34
|
|
|
|
|
|
|
min_format => $args{min_format}, |
35
|
|
|
|
|
|
|
min_fraction => $args{min_fraction}, |
36
|
16
|
|
|
|
|
105
|
); |
37
|
16
|
|
|
|
|
81
|
$f->_format($args{num}); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $id_names = { |
42
|
|
|
|
|
|
|
#2 => 'ratus', |
43
|
|
|
|
|
|
|
3 => 'ribu', |
44
|
|
|
|
|
|
|
6 => 'juta', |
45
|
|
|
|
|
|
|
9 => 'miliar', |
46
|
|
|
|
|
|
|
12 => 'triliun', |
47
|
|
|
|
|
|
|
15 => 'kuadriliun', |
48
|
|
|
|
|
|
|
18 => 'kuintiliun', |
49
|
|
|
|
|
|
|
21 => 'sekstiliun', |
50
|
|
|
|
|
|
|
24 => 'septiliun', |
51
|
|
|
|
|
|
|
27 => 'oktiliun', |
52
|
|
|
|
|
|
|
30 => 'noniliun', |
53
|
|
|
|
|
|
|
33 => 'desiliun', |
54
|
|
|
|
|
|
|
36 => 'undesiliun', |
55
|
|
|
|
|
|
|
39 => 'duodesiliun', |
56
|
|
|
|
|
|
|
42 => 'tredesiliun', |
57
|
|
|
|
|
|
|
45 => 'kuatuordesiliun', |
58
|
|
|
|
|
|
|
48 => 'kuindesiliun', |
59
|
|
|
|
|
|
|
51 => 'seksdesiliun', |
60
|
|
|
|
|
|
|
54 => 'septendesiliun', |
61
|
|
|
|
|
|
|
57 => 'oktodesiliun', |
62
|
|
|
|
|
|
|
60 => 'novemdesiliun', |
63
|
|
|
|
|
|
|
63 => 'vigintiliun', |
64
|
|
|
|
|
|
|
100 => 'googol', |
65
|
|
|
|
|
|
|
303 => 'sentiliun', |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub new { |
69
|
16
|
|
|
16
|
0
|
70
|
my ($class, %args) = @_; |
70
|
16
|
|
50
|
|
|
79
|
$args{decimal_point} //= ","; |
71
|
16
|
|
50
|
|
|
58
|
$args{thousands_sep} //= "."; |
72
|
16
|
|
33
|
|
|
67
|
$args{names} //= $id_names; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# XXX should use "SUPER" |
75
|
16
|
|
|
|
|
87
|
my $self = Lingua::Base::Number::Format::MixWithWords->new(%args); |
76
|
16
|
|
|
|
|
5970
|
bless $self, $class; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
# ABSTRACT: Format number to a mixture of numbers and words (e.g. "12,3 juta") |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |