| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# For Emacs: -*- mode:cperl; eval: (folding-mode 1); coding:utf-8 -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Lingua::YID::Num2Word; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Number to word conversion in Yiddish |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
127969
|
use 5.16.0; |
|
|
1
|
|
|
|
|
3
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
11
|
|
|
8
|
1
|
|
|
1
|
|
20
|
use warnings; |
|
|
1
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
67
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# {{{ use block |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
14
|
|
|
|
1
|
|
|
|
|
62
|
|
|
13
|
1
|
|
|
1
|
|
544
|
use Export::Attrs; |
|
|
1
|
|
|
|
|
9853
|
|
|
|
1
|
|
|
|
|
5
|
|
|
14
|
1
|
|
|
1
|
|
748
|
use Readonly; |
|
|
1
|
|
|
|
|
3572
|
|
|
|
1
|
|
|
|
|
503
|
|
|
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
|
|
|
|
|
|
|
# {{{ num2yid_cardinal convert number to text |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub num2yid_cardinal :Export { |
|
27
|
14
|
|
|
14
|
1
|
173248
|
my $positive = shift; |
|
28
|
|
|
|
|
|
|
|
|
29
|
14
|
100
|
66
|
|
|
154
|
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
|
12
|
|
|
|
|
41
|
my @tokens1 = qw(נול אײנס צװײ דרײַ פֿיר פֿינף זעקס זיבן אכט נײַן צען עלף צוועלף); |
|
36
|
12
|
|
|
|
|
26
|
my @tokens2 = qw(צוואַנציק דרײַסיק פערציק פופציק זעכציק זיבעציק אַכציק נײַנציק הונדערט); |
|
37
|
|
|
|
|
|
|
|
|
38
|
12
|
100
|
66
|
|
|
47
|
return $tokens1[$positive] if ($positive >= 0 && $positive < 13); # 0 .. 12 |
|
39
|
7
|
50
|
|
|
|
34
|
return 'פערצן' if ($positive == 14); # YIVO: fertsn |
|
40
|
7
|
50
|
|
|
|
12
|
return 'פופצן' if ($positive == 15); # YIVO: fuftsn |
|
41
|
7
|
50
|
|
|
|
11
|
return 'זעכצן' if ($positive == 16); # YIVO: zekhtsn |
|
42
|
7
|
100
|
|
|
|
13
|
return 'זיבעצן' if ($positive == 17); # YIVO: zibetsn |
|
43
|
6
|
50
|
|
|
|
9
|
return 'אַכצן' if ($positive == 18); # YIVO: akhtsn |
|
44
|
6
|
50
|
|
|
|
9
|
return 'נײַנצן' if ($positive == 19); # YIVO: nayntsn |
|
45
|
6
|
50
|
|
|
|
11
|
return $tokens1[$positive-10] . 'צן' if ($positive == 13); # draytsn |
|
46
|
|
|
|
|
|
|
|
|
47
|
6
|
|
|
|
|
11
|
my $out; # string for return value construction |
|
48
|
|
|
|
|
|
|
my $one_idx; # index for tokens1 array |
|
49
|
6
|
|
|
|
|
0
|
my $remain; # remainder |
|
50
|
|
|
|
|
|
|
|
|
51
|
6
|
100
|
66
|
|
|
52
|
if ($positive > 19 && $positive < 101) { # 20 .. 100 |
|
|
|
100
|
66
|
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
52
|
3
|
|
|
|
|
7
|
$one_idx = int ($positive / 10); |
|
53
|
3
|
|
|
|
|
7
|
$remain = $positive % 10; |
|
54
|
|
|
|
|
|
|
|
|
55
|
3
|
100
|
|
|
|
8
|
$out = "$tokens1[$remain] און " if ($remain); |
|
56
|
3
|
|
|
|
|
8
|
$out .= $tokens2[$one_idx - 2]; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
elsif ($positive > 100 && $positive < 1000) { # 101 .. 999 |
|
59
|
1
|
|
|
|
|
3
|
$one_idx = int ($positive / 100); |
|
60
|
1
|
|
|
|
|
2
|
$remain = $positive % 100; |
|
61
|
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
2
|
$out = "$tokens1[$one_idx] הונדערט"; |
|
63
|
1
|
50
|
|
|
|
7
|
$out .= $remain ? ' ' . num2yid_cardinal($remain) : ''; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
elsif ($positive > 999 && $positive < 1_000_000) { # 1000 .. 999_999 |
|
66
|
2
|
|
|
|
|
5
|
$one_idx = int ($positive / 1000); |
|
67
|
2
|
|
|
|
|
3
|
$remain = $positive % 1000; |
|
68
|
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
4
|
$out = num2yid_cardinal($one_idx) . ' טויזנט'; |
|
70
|
2
|
50
|
|
|
|
6
|
$out .= $remain ? ' ' . num2yid_cardinal($remain) : ''; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
elsif ( $positive > 999_999 |
|
73
|
|
|
|
|
|
|
&& $positive < 1_000_000_000) { # 1_000_000 .. 999_999_999 |
|
74
|
0
|
|
|
|
|
0
|
$one_idx = int ($positive / 1000000); |
|
75
|
0
|
|
|
|
|
0
|
$remain = $positive % 1000000; |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
$out = num2yid_cardinal($one_idx) . ' מיליאָן'; |
|
78
|
0
|
0
|
|
|
|
0
|
$out .= $remain ? ' ' . num2yid_cardinal($remain) : ''; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
6
|
|
|
|
|
19
|
return $out; |
|
82
|
1
|
|
|
1
|
|
10
|
} |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
8
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# }}} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# {{{ num2yid_ordinal convert number to ordinal text |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub num2yid_ordinal :Export { |
|
89
|
0
|
|
|
0
|
1
|
|
my $number = shift; |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
0
|
0
|
|
|
|
croak 'You should specify a number from interval [1, 999_999_999]' |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
92
|
|
|
|
|
|
|
if !defined $number |
|
93
|
|
|
|
|
|
|
|| $number !~ m{\A\d+\z}xms |
|
94
|
|
|
|
|
|
|
|| $number < 1 |
|
95
|
|
|
|
|
|
|
|| $number > 999_999_999; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Fully irregular forms (masculine nominative with -er suffix) |
|
98
|
0
|
0
|
|
|
|
|
return 'ערשטער' if $number == 1; # ershter |
|
99
|
0
|
0
|
|
|
|
|
return 'צווייטער' if $number == 2; # tsveyter |
|
100
|
0
|
0
|
|
|
|
|
return 'דריטער' if $number == 3; # driter |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# Stem irregulars |
|
103
|
0
|
0
|
|
|
|
|
return 'זיבעטער' if $number == 7; # zibeter |
|
104
|
0
|
0
|
|
|
|
|
return 'אַכטער' if $number == 8; # akhter |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
my $cardinal = num2yid_cardinal($number); |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# Numbers 4-19 get suffix "טער", 20+ get "סטער" |
|
109
|
0
|
0
|
|
|
|
|
my $suffix = $number < 20 ? 'טער' : 'סטער'; |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
return $cardinal . $suffix; |
|
112
|
1
|
|
|
1
|
|
475
|
} |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
7
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# }}} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# {{{ capabilities declare supported features |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub capabilities { |
|
119
|
|
|
|
|
|
|
return { |
|
120
|
0
|
|
|
0
|
1
|
|
cardinal => 1, |
|
121
|
|
|
|
|
|
|
ordinal => 1, |
|
122
|
|
|
|
|
|
|
}; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# }}} |
|
126
|
|
|
|
|
|
|
1; |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__ |