line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# For Emacs: -*- mode:cperl; mode:folding; coding:utf-8; -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Lingua::CES::Word2Num; |
4
|
|
|
|
|
|
|
# ABSTRACT: Word 2 number conversion in CES. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# {{{ use block |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
35018
|
use 5.10.1; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
51
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
11
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
44
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
992
|
use Encode qw(decode_utf8); |
|
1
|
|
|
|
|
11168
|
|
|
1
|
|
|
|
|
83
|
|
14
|
1
|
|
|
1
|
|
9315
|
use Parse::RecDescent; |
|
1
|
|
|
|
|
49492
|
|
|
1
|
|
|
|
|
7
|
|
15
|
1
|
|
|
1
|
|
850
|
use Perl6::Export::Attrs; |
|
1
|
|
|
|
|
10052
|
|
|
1
|
|
|
|
|
10
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# }}} |
18
|
|
|
|
|
|
|
# {{{ variables |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = 0.0682; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $parser = ces_numerals(); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# }}} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# {{{ w2n convert number to text |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub w2n :Export { |
29
|
6
|
|
100
|
6
|
1
|
489558
|
my $input = shift // return; |
30
|
|
|
|
|
|
|
|
31
|
5
|
|
|
|
|
57
|
return $parser->numeral($input); |
32
|
1
|
|
|
1
|
|
140
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# }}} |
35
|
|
|
|
|
|
|
# {{{ ces_numerals create parser for numerals |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub ces_numerals { |
38
|
1
|
|
|
1
|
1
|
4
|
return Parse::RecDescent->new(decode_utf8(q{ |
39
|
|
|
|
|
|
|
numeral: |
40
|
|
|
|
|
|
|
numeral: million |
41
|
|
|
|
|
|
|
{ return $item[1]; } |
42
|
|
|
|
|
|
|
| thousand |
43
|
|
|
|
|
|
|
{ return $item[1]; } |
44
|
|
|
|
|
|
|
| century |
45
|
|
|
|
|
|
|
{ return $item[1]; } |
46
|
|
|
|
|
|
|
| decade |
47
|
|
|
|
|
|
|
{ return $item[1]; } |
48
|
|
|
|
|
|
|
| { return undef; } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
number: 'dvanáct' { $return = 12; } |
51
|
|
|
|
|
|
|
| 'třináct' { $return = 13; } |
52
|
|
|
|
|
|
|
| 'čtrnáct' { $return = 14; } |
53
|
|
|
|
|
|
|
| 'patnáct' { $return = 15; } |
54
|
|
|
|
|
|
|
| 'šestnáct' { $return = 16; } |
55
|
|
|
|
|
|
|
| 'sedmnáct' { $return = 17; } |
56
|
|
|
|
|
|
|
| 'osmnáct' { $return = 18; } |
57
|
|
|
|
|
|
|
| 'devatenáct' { $return = 19; } |
58
|
|
|
|
|
|
|
| 'nula' { $return = 0; } |
59
|
|
|
|
|
|
|
| 'jedna' { $return = 1; } |
60
|
|
|
|
|
|
|
| 'dva' { $return = 2; } |
61
|
|
|
|
|
|
|
| 'tři' { $return = 3; } |
62
|
|
|
|
|
|
|
| 'čtyři' { $return = 4; } |
63
|
|
|
|
|
|
|
| 'pět' { $return = 5; } |
64
|
|
|
|
|
|
|
| 'šest' { $return = 6; } |
65
|
|
|
|
|
|
|
| 'sedm' { $return = 7; } |
66
|
|
|
|
|
|
|
| 'osm' { $return = 8; } |
67
|
|
|
|
|
|
|
| 'devět' { $return = 9; } |
68
|
|
|
|
|
|
|
| 'deset' { $return = 10; } |
69
|
|
|
|
|
|
|
| 'jedenáct' { $return = 11; } |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
tens: 'dvacet' { $return = 20; } |
72
|
|
|
|
|
|
|
| 'třicet' { $return = 30; } |
73
|
|
|
|
|
|
|
| 'čtyřicet' { $return = 40; } |
74
|
|
|
|
|
|
|
| 'padesát' { $return = 50; } |
75
|
|
|
|
|
|
|
| 'šedesát' { $return = 60; } |
76
|
|
|
|
|
|
|
| 'sedmdesát' { $return = 70; } |
77
|
|
|
|
|
|
|
| 'osmdesát' { $return = 80; } |
78
|
|
|
|
|
|
|
| 'devadesát' { $return = 90; } |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
decade: tens number |
81
|
|
|
|
|
|
|
{ $return = $item[1] + $item[2]; } |
82
|
|
|
|
|
|
|
| tens |
83
|
|
|
|
|
|
|
{ $return = $item[1]; } |
84
|
|
|
|
|
|
|
| number |
85
|
|
|
|
|
|
|
{ $return = $item[1]; } |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
century: number 'sta' decade |
88
|
|
|
|
|
|
|
{ $return = $item[1] * 100 + $item[3]; } |
89
|
|
|
|
|
|
|
| number 'sta' |
90
|
|
|
|
|
|
|
{ $return = $item[1] * 100 } |
91
|
|
|
|
|
|
|
| number 'set' decade |
92
|
|
|
|
|
|
|
{ $return = $item[1] * 100 + $item[3]; } |
93
|
|
|
|
|
|
|
| number 'set' |
94
|
|
|
|
|
|
|
{ $return = $item[1] * 100 } |
95
|
|
|
|
|
|
|
| 'dvě' 'stě' decade |
96
|
|
|
|
|
|
|
{ $return = 2 * 100 + $item[3]; } |
97
|
|
|
|
|
|
|
| 'dvě' 'stě' |
98
|
|
|
|
|
|
|
{ $return = 2 * 100; } |
99
|
|
|
|
|
|
|
| 'sto' decade |
100
|
|
|
|
|
|
|
{ $return = 100 + $item[2]; } |
101
|
|
|
|
|
|
|
| 'sto' |
102
|
|
|
|
|
|
|
{ $return = 100; } |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
thousand: century thousands century |
105
|
|
|
|
|
|
|
{ $return = $item[1] * 1000 + $item[3]; } |
106
|
|
|
|
|
|
|
| century thousands decade |
107
|
|
|
|
|
|
|
{ $return = $item[1] * 1000 + $item[3]; } |
108
|
|
|
|
|
|
|
| century thousands |
109
|
|
|
|
|
|
|
{ $return = $item[1] * 1000; } |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
| decade thousands century |
112
|
|
|
|
|
|
|
{ $return = $item[1] * 1000 + $item[3]; } |
113
|
|
|
|
|
|
|
| decade thousands decade |
114
|
|
|
|
|
|
|
{ $return = $item[1] * 1000 + $item[3]; } |
115
|
|
|
|
|
|
|
| decade thousands |
116
|
|
|
|
|
|
|
{ $return = $item[1] * 1000; } |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
| number thousands century |
119
|
|
|
|
|
|
|
{ $return = $item[1] * 1000 + $item[3]; } |
120
|
|
|
|
|
|
|
| number thousands decade |
121
|
|
|
|
|
|
|
{ $return = $item[1] * 1000 + $item[3]; } |
122
|
|
|
|
|
|
|
| number thousands |
123
|
|
|
|
|
|
|
{ $return = $item[1] * 1000; } |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
| 'tisíc' century |
126
|
|
|
|
|
|
|
{ $return = 1000 + $item[2]; } |
127
|
|
|
|
|
|
|
| 'tisíc' decade |
128
|
|
|
|
|
|
|
{ $return = 1000 + $item[2]; } |
129
|
|
|
|
|
|
|
| 'tisíc' |
130
|
|
|
|
|
|
|
{ $return = 1000; } |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
| century 'jeden' 'tisíc' century |
133
|
|
|
|
|
|
|
{ $return = ($item[1] + 1) * 1000 + $item[4]; } |
134
|
|
|
|
|
|
|
| century 'jeden' 'tisíc' decade |
135
|
|
|
|
|
|
|
{ $return = ($item[1] + 1) * 1000 + $item[4]; } |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
| decade 'jeden' 'tisíc' century |
138
|
|
|
|
|
|
|
{ $return = ($item[1] + 1) * 1000 + $item[4]; } |
139
|
|
|
|
|
|
|
| decade 'jeden' 'tisíc' decade |
140
|
|
|
|
|
|
|
{ $return = ($item[1] + 1) * 1000 + $item[4]; } |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
| century 'jeden' 'tisíc' |
143
|
|
|
|
|
|
|
{ $return = ($item[1] + 1) * 1000; } |
144
|
|
|
|
|
|
|
| decade 'jeden' 'tisíc' |
145
|
|
|
|
|
|
|
{ $return = ($item[1] + 1) * 1000; } |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
thousands: 'tisíce' |
148
|
|
|
|
|
|
|
| 'tisíc' |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
million: century millions thousand |
151
|
|
|
|
|
|
|
{ $return = $item[1] * 1_000_000 + $item[3]; } |
152
|
|
|
|
|
|
|
| century millions century |
153
|
|
|
|
|
|
|
{ $return = $item[1] * 1_000_000 + $item[3]; } |
154
|
|
|
|
|
|
|
| century millions decade |
155
|
|
|
|
|
|
|
{ $return = $item[1] * 1_000_000 + $item[3]; } |
156
|
|
|
|
|
|
|
| century millions |
157
|
|
|
|
|
|
|
{ $return = $item[1] * 1_000_000; } |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
| decade millions thousand |
160
|
|
|
|
|
|
|
{ $return = $item[1] * 1_000_000 + $item[3]; } |
161
|
|
|
|
|
|
|
| decade millions century |
162
|
|
|
|
|
|
|
{ $return = $item[1] * 1_000_000 + $item[3]; } |
163
|
|
|
|
|
|
|
| decade millions decade |
164
|
|
|
|
|
|
|
{ $return = $item[1] * 1_000_000 + $item[3]; } |
165
|
|
|
|
|
|
|
| decade millions |
166
|
|
|
|
|
|
|
{ $return = $item[1] * 1_000_000; } |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
| 'milion' thousand |
169
|
|
|
|
|
|
|
{ $return = 1_000_000 + $item[2]; } |
170
|
|
|
|
|
|
|
| 'milion' century |
171
|
|
|
|
|
|
|
{ $return = 1_000_000 + $item[2]; } |
172
|
|
|
|
|
|
|
| 'milion' decade |
173
|
|
|
|
|
|
|
{ $return = 1_000_000 + $item[2]; } |
174
|
|
|
|
|
|
|
| 'milion' |
175
|
|
|
|
|
|
|
{ $return = 1_000_000; } |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
| century 'jeden' 'milion' thousand |
178
|
|
|
|
|
|
|
{ $return = ($item[1] + 1) * 1_000_000 + $item[4]; } |
179
|
|
|
|
|
|
|
| century 'jeden' 'milion' century |
180
|
|
|
|
|
|
|
{ $return = ($item[1] + 1) * 1_000_000 + $item[4]; } |
181
|
|
|
|
|
|
|
| century 'jeden' 'milion' decade |
182
|
|
|
|
|
|
|
{ $return = ($item[1] + 1) * 1_000_000 + $item[4]; } |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
| decade 'jeden' 'milion' thousand |
185
|
|
|
|
|
|
|
{ $return = ($item[1] + 1) * 1_000_000 + $item[4]; } |
186
|
|
|
|
|
|
|
| decade 'jeden' 'milion' century |
187
|
|
|
|
|
|
|
{ $return = ($item[1] + 1) * 1_000_000 + $item[4]; } |
188
|
|
|
|
|
|
|
| decade 'jeden' 'milion' decade |
189
|
|
|
|
|
|
|
{ $return = ($item[1] + 1) * 1_000_000 + $item[4]; } |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
millions: 'miliony' |
192
|
|
|
|
|
|
|
| 'milionů' |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
})); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# }}} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
1; |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
__END__ |