| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# For Emacs: -*- mode:cperl; eval: (folding-mode 1); coding:utf-8 -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Lingua::SQI::Num2Word; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Number to word conversion in Albanian |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
145985
|
use 5.16.0; |
|
|
1
|
|
|
|
|
5
|
|
|
7
|
1
|
|
|
1
|
|
7
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
16
|
|
|
8
|
1
|
|
|
1
|
|
38
|
use warnings; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
80
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# {{{ use block |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
93
|
|
|
13
|
1
|
|
|
1
|
|
758
|
use Export::Attrs; |
|
|
1
|
|
|
|
|
13536
|
|
|
|
1
|
|
|
|
|
8
|
|
|
14
|
1
|
|
|
1
|
|
923
|
use Readonly; |
|
|
1
|
|
|
|
|
5822
|
|
|
|
1
|
|
|
|
|
665
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# }}} |
|
17
|
|
|
|
|
|
|
# {{{ variable declarations |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my Readonly::Scalar $COPY = 'Copyright (c) PetaMem, s.r.o. 2002-present'; |
|
20
|
|
|
|
|
|
|
our $VERSION = '0.2603300'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# }}} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# {{{ num2sqi_cardinal convert number to text |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub num2sqi_cardinal :Export { |
|
27
|
35
|
|
|
35
|
1
|
246166
|
my $positive = shift; |
|
28
|
|
|
|
|
|
|
|
|
29
|
35
|
100
|
66
|
|
|
475
|
croak 'You should specify a number from interval [0, 999_999_999]' |
|
|
|
|
66
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
30
|
|
|
|
|
|
|
if !defined $positive |
|
31
|
|
|
|
|
|
|
|| $positive !~ m{\A\d+\z}xms |
|
32
|
|
|
|
|
|
|
|| $positive < 0 |
|
33
|
|
|
|
|
|
|
|| $positive > 999_999_999; |
|
34
|
|
|
|
|
|
|
|
|
35
|
33
|
|
|
|
|
146
|
my @ones = qw(zero një dy tre katër pesë gjashtë shtatë tetë nëntë); |
|
36
|
33
|
|
|
|
|
109
|
my @teens = qw( |
|
37
|
|
|
|
|
|
|
dhjetë njëmbëdhjetë dymbëdhjetë trembëdhjetë katërmbëdhjetë |
|
38
|
|
|
|
|
|
|
pesëmbëdhjetë gjashtëmbëdhjetë shtatëmbëdhjetë tetëmbëdhjetë nëntëmbëdhjetë |
|
39
|
|
|
|
|
|
|
); |
|
40
|
33
|
|
|
|
|
101
|
my @tens = qw( |
|
41
|
|
|
|
|
|
|
_invalid _invalid njëzet tridhjetë dyzet pesëdhjetë |
|
42
|
|
|
|
|
|
|
gjashtëdhjetë shtatëdhjetë tetëdhjetë nëntëdhjetë |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
|
|
45
|
33
|
100
|
66
|
|
|
167
|
return $ones[$positive] if ($positive >= 0 && $positive < 10); |
|
46
|
24
|
100
|
66
|
|
|
110
|
return $teens[$positive - 10] if ($positive >= 10 && $positive < 20); |
|
47
|
|
|
|
|
|
|
|
|
48
|
21
|
|
|
|
|
44
|
my $out; |
|
49
|
|
|
|
|
|
|
my $remain; |
|
50
|
|
|
|
|
|
|
|
|
51
|
21
|
100
|
66
|
|
|
161
|
if ($positive >= 20 && $positive < 100) { # 20 .. 99 |
|
|
|
100
|
66
|
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
52
|
8
|
|
|
|
|
24
|
my $ten_idx = int($positive / 10); |
|
53
|
8
|
|
|
|
|
20
|
$remain = $positive % 10; |
|
54
|
|
|
|
|
|
|
|
|
55
|
8
|
|
|
|
|
17
|
$out = $tens[$ten_idx]; |
|
56
|
8
|
100
|
|
|
|
29
|
$out .= ' e ' . $ones[$remain] if ($remain); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
elsif ($positive >= 100 && $positive < 1000) { # 100 .. 999 |
|
59
|
6
|
|
|
|
|
18
|
my $hund_idx = int($positive / 100); |
|
60
|
6
|
|
|
|
|
11
|
$remain = $positive % 100; |
|
61
|
|
|
|
|
|
|
|
|
62
|
6
|
|
|
|
|
17
|
$out = $ones[$hund_idx] . 'qind'; |
|
63
|
6
|
100
|
|
|
|
37
|
$out .= ' e ' . num2sqi_cardinal($remain) if ($remain); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
elsif ($positive >= 1000 && $positive < 1_000_000) { # 1000 .. 999_999 |
|
66
|
4
|
|
|
|
|
27
|
my $kilo_idx = int($positive / 1000); |
|
67
|
4
|
|
|
|
|
10
|
$remain = $positive % 1000; |
|
68
|
|
|
|
|
|
|
|
|
69
|
4
|
|
|
|
|
10
|
$out = num2sqi_cardinal($kilo_idx) . ' mijë'; |
|
70
|
4
|
100
|
|
|
|
15
|
$out .= ' e ' . num2sqi_cardinal($remain) if ($remain); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
elsif ($positive >= 1_000_000 && $positive < 1_000_000_000) { # 1_000_000 .. 999_999_999 |
|
73
|
3
|
|
|
|
|
12
|
my $mega_idx = int($positive / 1_000_000); |
|
74
|
3
|
|
|
|
|
8
|
$remain = $positive % 1_000_000; |
|
75
|
|
|
|
|
|
|
|
|
76
|
3
|
|
|
|
|
7
|
$out = num2sqi_cardinal($mega_idx); |
|
77
|
3
|
100
|
|
|
|
11
|
$out .= $mega_idx == 1 ? ' milion' : ' milionë'; |
|
78
|
3
|
100
|
|
|
|
13
|
$out .= ' e ' . num2sqi_cardinal($remain) if ($remain); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
21
|
|
|
|
|
105
|
return $out; |
|
82
|
1
|
|
|
1
|
|
11
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
10
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# }}} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# {{{ capabilities declare supported features |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub capabilities { |
|
90
|
|
|
|
|
|
|
return { |
|
91
|
0
|
|
|
0
|
1
|
|
cardinal => 1, |
|
92
|
|
|
|
|
|
|
ordinal => 0, |
|
93
|
|
|
|
|
|
|
}; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# }}} |
|
97
|
|
|
|
|
|
|
1; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |