| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# For Emacs: -*- mode:cperl; eval: (folding-mode 1); coding:utf-8 -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Lingua::SRD::Num2Word; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Number to word conversion in Sardinian (Logudorese) |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
133082
|
use 5.16.0; |
|
|
1
|
|
|
|
|
4
|
|
|
7
|
1
|
|
|
1
|
|
7
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
18
|
|
|
8
|
1
|
|
|
1
|
|
35
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
78
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# {{{ use block |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
123
|
|
|
13
|
1
|
|
|
1
|
|
688
|
use Export::Attrs; |
|
|
1
|
|
|
|
|
13240
|
|
|
|
1
|
|
|
|
|
8
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# }}} |
|
16
|
|
|
|
|
|
|
# {{{ variable declarations |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.2603300'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my @ONES = qw(zeru unu duos tres bàtoro chimbe ses sete oto noe); |
|
21
|
|
|
|
|
|
|
my @TEENS = qw(deghe undighi doighi treighi batordighi bindighi seighi |
|
22
|
|
|
|
|
|
|
deghesete degheoto deghenoe); |
|
23
|
|
|
|
|
|
|
my @TENS = qw(_ _ binti trinta baranta chinbanta sessanta setanta otanta nonanta); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Hundreds multiplier prefixes: 2-9 |
|
26
|
|
|
|
|
|
|
my @HUN_PREFIX = qw(_ _ du tre bator chinbi ses sete oto nobi); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# }}} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# {{{ num2srd_cardinal convert number to text |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub num2srd_cardinal :Export { |
|
33
|
66
|
|
|
66
|
1
|
265182
|
my $positive = shift; |
|
34
|
|
|
|
|
|
|
|
|
35
|
66
|
50
|
33
|
|
|
798
|
croak 'You should specify a number from interval [0, 999_999_999]' |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
36
|
|
|
|
|
|
|
if !defined $positive |
|
37
|
|
|
|
|
|
|
|| $positive !~ m{\A\d+\z}xms |
|
38
|
|
|
|
|
|
|
|| $positive < 0 |
|
39
|
|
|
|
|
|
|
|| $positive > 999_999_999; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# 0–9 |
|
42
|
66
|
100
|
|
|
|
192
|
return $ONES[$positive] if $positive <= 9; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# 10–19 |
|
45
|
53
|
100
|
66
|
|
|
186
|
return $TEENS[$positive - 10] if $positive >= 10 && $positive <= 19; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# 20–99 |
|
48
|
42
|
100
|
66
|
|
|
99
|
if ($positive >= 20 && $positive <= 99) { |
|
49
|
25
|
|
|
|
|
50
|
my $ten_idx = int($positive / 10); |
|
50
|
25
|
|
|
|
|
33
|
my $unit = $positive % 10; |
|
51
|
|
|
|
|
|
|
|
|
52
|
25
|
100
|
|
|
|
62
|
return $TENS[$ten_idx] if $unit == 0; |
|
53
|
|
|
|
|
|
|
|
|
54
|
17
|
|
|
|
|
54
|
my $ten_word = $TENS[$ten_idx]; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Apocope: tens drop final vowel before "unu" |
|
57
|
17
|
100
|
|
|
|
46
|
if ($unit == 1) { |
|
58
|
8
|
|
|
|
|
42
|
$ten_word =~ s/[aeiou]$//; |
|
59
|
8
|
|
|
|
|
46
|
return $ten_word . $ONES[$unit]; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
9
|
|
|
|
|
53
|
return $ten_word . $ONES[$unit]; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# 100–999 |
|
66
|
17
|
100
|
66
|
|
|
44
|
if ($positive >= 100 && $positive <= 999) { |
|
67
|
13
|
|
|
|
|
28
|
my $hun_idx = int($positive / 100); |
|
68
|
13
|
|
|
|
|
17
|
my $remain = $positive % 100; |
|
69
|
13
|
|
|
|
|
13
|
my $out; |
|
70
|
|
|
|
|
|
|
|
|
71
|
13
|
100
|
|
|
|
25
|
if ($hun_idx == 1) { |
|
72
|
3
|
|
|
|
|
6
|
$out = 'chentu'; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
else { |
|
75
|
10
|
|
|
|
|
16
|
$out = $HUN_PREFIX[$hun_idx] . 'chentos'; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
13
|
100
|
|
|
|
30
|
$out .= num2srd_cardinal($remain) if $remain; |
|
79
|
13
|
|
|
|
|
56
|
return $out; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# 1_000–999_999 |
|
83
|
4
|
50
|
33
|
|
|
14
|
if ($positive >= 1_000 && $positive <= 999_999) { |
|
84
|
4
|
|
|
|
|
10
|
my $tho_idx = int($positive / 1000); |
|
85
|
4
|
|
|
|
|
4
|
my $remain = $positive % 1000; |
|
86
|
4
|
|
|
|
|
6
|
my $out; |
|
87
|
|
|
|
|
|
|
|
|
88
|
4
|
100
|
|
|
|
10
|
if ($tho_idx == 1) { |
|
|
|
100
|
|
|
|
|
|
|
89
|
2
|
|
|
|
|
3
|
$out = 'milli'; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
elsif ($tho_idx == 2) { |
|
92
|
1
|
|
|
|
|
3
|
$out = 'duamiza'; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
else { |
|
95
|
1
|
|
|
|
|
4
|
$out = num2srd_cardinal($tho_idx) . 'miza'; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
4
|
100
|
|
|
|
9
|
$out .= num2srd_cardinal($remain) if $remain; |
|
99
|
4
|
|
|
|
|
17
|
return $out; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# 1_000_000–999_999_999 |
|
103
|
0
|
0
|
0
|
|
|
0
|
if ($positive >= 1_000_000 && $positive <= 999_999_999) { |
|
104
|
0
|
|
|
|
|
0
|
my $mil_idx = int($positive / 1_000_000); |
|
105
|
0
|
|
|
|
|
0
|
my $remain = $positive % 1_000_000; |
|
106
|
0
|
|
|
|
|
0
|
my $out; |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
0
|
if ($mil_idx == 1) { |
|
109
|
0
|
|
|
|
|
0
|
$out = 'unu milione'; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
else { |
|
112
|
0
|
|
|
|
|
0
|
$out = num2srd_cardinal($mil_idx) . ' miliones'; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
0
|
|
|
|
0
|
$out .= ' ' . num2srd_cardinal($remain) if $remain; |
|
116
|
0
|
|
|
|
|
0
|
return $out; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
0
|
return; |
|
120
|
1
|
|
|
1
|
|
875
|
} |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
8
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# }}} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# {{{ capabilities declare supported features |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub capabilities { |
|
127
|
|
|
|
|
|
|
return { |
|
128
|
1
|
|
|
1
|
1
|
4
|
cardinal => 1, |
|
129
|
|
|
|
|
|
|
ordinal => 0, |
|
130
|
|
|
|
|
|
|
}; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# }}} |
|
134
|
|
|
|
|
|
|
1; |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
__END__ |