| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# For Emacs: -*- mode:cperl; eval: (folding-mode 1); coding:utf-8 -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Lingua::UIG::Num2Word; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Number to word conversion in Uyghur |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
95804
|
use 5.16.0; |
|
|
1
|
|
|
|
|
3
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
11
|
|
|
8
|
1
|
|
|
1
|
|
20
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
52
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# {{{ use block |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
79
|
|
|
13
|
1
|
|
|
1
|
|
570
|
use Export::Attrs; |
|
|
1
|
|
|
|
|
9457
|
|
|
|
1
|
|
|
|
|
5
|
|
|
14
|
1
|
|
|
1
|
|
582
|
use Readonly; |
|
|
1
|
|
|
|
|
3157
|
|
|
|
1
|
|
|
|
|
378
|
|
|
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
|
|
|
|
|
|
|
# {{{ num2uig_cardinal convert number to text |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub num2uig_cardinal :Export { |
|
27
|
2
|
|
|
2
|
1
|
132472
|
my $positive = shift; |
|
28
|
|
|
|
|
|
|
|
|
29
|
2
|
50
|
33
|
|
|
25
|
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
|
|
|
|
|
|
|
# Uyghur numerals in Arabic script |
|
36
|
2
|
|
|
|
|
9
|
my @ones = ('نۆل', 'بىر', 'ئىككى', 'ئۈچ', 'تۆت', 'بەش', |
|
37
|
|
|
|
|
|
|
'ئالتە', 'يەتتە', 'سەككىز', 'توققۇز'); |
|
38
|
2
|
|
|
|
|
6
|
my @tens = ('ئون', 'يىگىرمە', 'ئوتتۇز', 'قىرىق', 'ئەللىك', |
|
39
|
|
|
|
|
|
|
'ئاتمىش', 'يەتمىش', 'سەكسەن', 'توقسان'); |
|
40
|
|
|
|
|
|
|
|
|
41
|
2
|
50
|
33
|
|
|
13
|
return $ones[$positive] if ($positive >= 0 && $positive < 10); # 0 .. 9 |
|
42
|
0
|
0
|
0
|
|
|
|
return $tens[$positive / 10 - 1] if ($positive >= 10 && $positive < 100 && $positive % 10 == 0); # 10,20,..,90 |
|
|
|
|
0
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $out; |
|
45
|
|
|
|
|
|
|
my $remain; |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
0
|
0
|
|
|
|
if ($positive > 9 && $positive < 100) { # 11 .. 99 |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $ten_idx = int($positive / 10); |
|
49
|
0
|
|
|
|
|
|
$remain = $positive % 10; |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$out = $tens[$ten_idx - 1] . ' ' . $ones[$remain]; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
elsif ($positive == 100) { # 100 |
|
54
|
0
|
|
|
|
|
|
$out = 'يۈز'; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
elsif ($positive > 100 && $positive < 1000) { # 101 .. 999 |
|
57
|
0
|
|
|
|
|
|
my $hun_idx = int($positive / 100); |
|
58
|
0
|
|
|
|
|
|
$remain = $positive % 100; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
$out = $hun_idx == 1 ? 'يۈز' : $ones[$hun_idx] . ' يۈز'; |
|
61
|
0
|
0
|
|
|
|
|
$out .= $remain ? ' ' . num2uig_cardinal($remain) : ''; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
elsif ($positive >= 1000 && $positive < 1_000_000) { # 1000 .. 999_999 |
|
64
|
0
|
|
|
|
|
|
my $tho_idx = int($positive / 1000); |
|
65
|
0
|
|
|
|
|
|
$remain = $positive % 1000; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
$out = $tho_idx == 1 ? 'مىڭ' : num2uig_cardinal($tho_idx) . ' مىڭ'; |
|
68
|
0
|
0
|
|
|
|
|
$out .= $remain ? ' ' . num2uig_cardinal($remain) : ''; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
elsif ($positive >= 1_000_000 && $positive < 1_000_000_000) { # 1_000_000 .. 999_999_999 |
|
71
|
0
|
|
|
|
|
|
my $mil_idx = int($positive / 1_000_000); |
|
72
|
0
|
|
|
|
|
|
$remain = $positive % 1_000_000; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$out = num2uig_cardinal($mil_idx) . ' مىليون'; |
|
75
|
0
|
0
|
|
|
|
|
$out .= $remain ? ' ' . num2uig_cardinal($remain) : ''; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return $out; |
|
79
|
1
|
|
|
1
|
|
7
|
} |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
6
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# }}} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# {{{ capabilities declare supported features |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub capabilities { |
|
87
|
|
|
|
|
|
|
return { |
|
88
|
0
|
|
|
0
|
1
|
|
cardinal => 1, |
|
89
|
|
|
|
|
|
|
ordinal => 0, |
|
90
|
|
|
|
|
|
|
}; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# }}} |
|
94
|
|
|
|
|
|
|
1; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |