| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# For Emacs: -*- mode:cperl; eval: (folding-mode 1); coding:utf-8 -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Lingua::SOM::Num2Word; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Number to word conversion in Somali |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
109584
|
use 5.16.0; |
|
|
1
|
|
|
|
|
3
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use utf8; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
10
|
|
|
8
|
1
|
|
|
1
|
|
21
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
54
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# {{{ use block |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
62
|
|
|
13
|
1
|
|
|
1
|
|
507
|
use Export::Attrs; |
|
|
1
|
|
|
|
|
8241
|
|
|
|
1
|
|
|
|
|
5
|
|
|
14
|
1
|
|
|
1
|
|
630
|
use Readonly; |
|
|
1
|
|
|
|
|
3217
|
|
|
|
1
|
|
|
|
|
381
|
|
|
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
|
|
|
|
|
|
|
# {{{ num2som_cardinal convert number to text |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub num2som_cardinal :Export { |
|
27
|
2
|
|
|
2
|
1
|
135512
|
my $positive = shift; |
|
28
|
|
|
|
|
|
|
|
|
29
|
2
|
50
|
33
|
|
|
24
|
croak 'You should specify a number from interval [0, 999_999_999]' |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
30
|
|
|
|
|
|
|
if !defined $positive |
|
31
|
|
|
|
|
|
|
|| $positive !~ m{\A\d+\z}xms |
|
32
|
|
|
|
|
|
|
|| $positive < 0 |
|
33
|
|
|
|
|
|
|
|| $positive > 999_999_999; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Somali numerals: unit iyo ten (ones stated before tens) |
|
36
|
|
|
|
|
|
|
# Zero is not standard in Somali; we use "eber" (nothing). |
|
37
|
2
|
|
|
|
|
9
|
my @ones = qw(eber ków lába sáddex áfar shán líx toddobá siddéed sagaal); |
|
38
|
2
|
|
|
|
|
7
|
my @ones_iyo = qw(eber koób lába sáddex áfar shán líx toddobá siddéed sagaál); |
|
39
|
2
|
|
|
|
|
7
|
my @tens = qw(toban labaátan sóddon afártan kónton líxdan toddobaátan siddeétan sagaáshan); |
|
40
|
|
|
|
|
|
|
|
|
41
|
2
|
50
|
33
|
|
|
12
|
return $ones[$positive] if ($positive >= 0 && $positive < 10); # 0 .. 9 |
|
42
|
0
|
0
|
|
|
|
|
return 'toban' if ($positive == 10); # 10 |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $out; |
|
45
|
|
|
|
|
|
|
my $remain; |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
0
|
0
|
|
|
|
if ($positive > 10 && $positive < 20) { # 11 .. 19 |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$out = $ones_iyo[$positive - 10] . ' iyo toban'; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
elsif ($positive >= 20 && $positive < 100) { # 20 .. 99 |
|
51
|
0
|
|
|
|
|
|
my $ten_idx = int($positive / 10) - 1; # tens[0]=toban, tens[1]=labaátan |
|
52
|
0
|
|
|
|
|
|
$remain = $positive % 10; |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
if ($remain) { |
|
55
|
0
|
|
|
|
|
|
$out = $ones_iyo[$remain] . ' iyo ' . $tens[$ten_idx]; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
else { |
|
58
|
0
|
|
|
|
|
|
$out = $tens[$ten_idx]; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
elsif ($positive >= 100 && $positive < 1000) { # 100 .. 999 |
|
62
|
0
|
|
|
|
|
|
my $hun = int($positive / 100); |
|
63
|
0
|
|
|
|
|
|
$remain = $positive % 100; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
$out = $hun == 1 ? 'boqól' : $ones[$hun] . ' boqól'; |
|
66
|
0
|
0
|
|
|
|
|
$out .= ' iyo ' . num2som_cardinal($remain) if ($remain); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
elsif ($positive >= 1000 && $positive < 1_000_000) { # 1000 .. 999_999 |
|
69
|
0
|
|
|
|
|
|
my $thou = int($positive / 1000); |
|
70
|
0
|
|
|
|
|
|
$remain = $positive % 1000; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
$out = $thou == 1 ? 'kún' : num2som_cardinal($thou) . ' kún'; |
|
73
|
0
|
0
|
|
|
|
|
$out .= ' iyo ' . num2som_cardinal($remain) if ($remain); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
elsif ($positive >= 1_000_000 && $positive < 1_000_000_000) { # 1_000_000 .. 999_999_999 |
|
76
|
0
|
|
|
|
|
|
my $mil = int($positive / 1_000_000); |
|
77
|
0
|
|
|
|
|
|
$remain = $positive % 1_000_000; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
$out = $mil == 1 ? 'malyúun' : num2som_cardinal($mil) . ' malyúun'; |
|
80
|
0
|
0
|
|
|
|
|
$out .= ' iyo ' . num2som_cardinal($remain) if ($remain); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
return $out; |
|
84
|
1
|
|
|
1
|
|
6
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# }}} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# {{{ capabilities declare supported features |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub capabilities { |
|
92
|
|
|
|
|
|
|
return { |
|
93
|
0
|
|
|
0
|
1
|
|
cardinal => 1, |
|
94
|
|
|
|
|
|
|
ordinal => 0, |
|
95
|
|
|
|
|
|
|
}; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# }}} |
|
99
|
|
|
|
|
|
|
1; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |