| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# For Emacs: -*- mode:cperl; eval: (folding-mode 1); coding:utf-8 -*- |
|
2
|
|
|
|
|
|
|
package Lingua::LTZ::Word2Num; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Word to number conversion in Luxembourgish |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
132404
|
use 5.16.0; |
|
|
1
|
|
|
|
|
4
|
|
|
6
|
1
|
|
|
1
|
|
8
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
16
|
|
|
7
|
1
|
|
|
1
|
|
39
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
86
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# {{{ use block |
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
714
|
use Export::Attrs; |
|
|
1
|
|
|
|
|
12377
|
|
|
|
1
|
|
|
|
|
5
|
|
|
12
|
1
|
|
|
1
|
|
1199
|
use Parse::RecDescent; |
|
|
1
|
|
|
|
|
42897
|
|
|
|
1
|
|
|
|
|
7
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# }}} |
|
15
|
|
|
|
|
|
|
# {{{ var block |
|
16
|
|
|
|
|
|
|
our $VERSION = '0.2603300'; |
|
17
|
|
|
|
|
|
|
my $parser = ltz_numerals(); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# }}} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# {{{ w2n convert text to number |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub w2n :Export { |
|
24
|
26
|
|
100
|
26
|
1
|
897810
|
my $input = shift // return; |
|
25
|
|
|
|
|
|
|
|
|
26
|
25
|
|
|
|
|
269
|
return $parser->numeral($input); |
|
27
|
1
|
|
|
1
|
|
108
|
} |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
7
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# }}} |
|
30
|
|
|
|
|
|
|
# {{{ ltz_numerals create parser for Luxembourgish numerals |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub ltz_numerals { |
|
33
|
1
|
|
|
1
|
1
|
6
|
return Parse::RecDescent->new(q{ |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
numeral: mega |
|
37
|
|
|
|
|
|
|
| kOhOd |
|
38
|
|
|
|
|
|
|
| { } |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
number: 'dräizéng' { 13 } |
|
41
|
|
|
|
|
|
|
| 'véierzéng' { 14 } |
|
42
|
|
|
|
|
|
|
| 'fofzéng' { 15 } |
|
43
|
|
|
|
|
|
|
| 'siechzéng' { 16 } |
|
44
|
|
|
|
|
|
|
| 'siwwenzéng' { 17 } |
|
45
|
|
|
|
|
|
|
| 'uechtzéng' { 18 } |
|
46
|
|
|
|
|
|
|
| 'nonzéng' { 19 } |
|
47
|
|
|
|
|
|
|
| 'null' { 0 } |
|
48
|
|
|
|
|
|
|
| /eent?/ { 1 } |
|
49
|
|
|
|
|
|
|
| /eng/ { 1 } |
|
50
|
|
|
|
|
|
|
| 'zwee' { 2 } |
|
51
|
|
|
|
|
|
|
| 'dräi' { 3 } |
|
52
|
|
|
|
|
|
|
| 'véier' { 4 } |
|
53
|
|
|
|
|
|
|
| /fënnef/ { 5 } |
|
54
|
|
|
|
|
|
|
| 'sechs' { 6 } |
|
55
|
|
|
|
|
|
|
| 'siwen' { 7 } |
|
56
|
|
|
|
|
|
|
| 'aacht' { 8 } |
|
57
|
|
|
|
|
|
|
| 'néng' { 9 } |
|
58
|
|
|
|
|
|
|
| 'zéng' { 10 } |
|
59
|
|
|
|
|
|
|
| 'eelef' { 11 } |
|
60
|
|
|
|
|
|
|
| 'zwielef' { 12 } |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
tens: 'zwanzeg' { 20 } |
|
63
|
|
|
|
|
|
|
| 'drësseg' { 30 } |
|
64
|
|
|
|
|
|
|
| 'véierzeg' { 40 } |
|
65
|
|
|
|
|
|
|
| 'fofzeg' { 50 } |
|
66
|
|
|
|
|
|
|
| 'sechzeg' { 60 } |
|
67
|
|
|
|
|
|
|
| 'siwwenzeg' { 70 } |
|
68
|
|
|
|
|
|
|
| 'achtzeg' { 80 } |
|
69
|
|
|
|
|
|
|
| 'nonzeg' { 90 } |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# connector: 'an' or 'a' (n-rule / Eifel rule) |
|
72
|
|
|
|
|
|
|
connector: 'an' |
|
73
|
|
|
|
|
|
|
| 'a' |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
deca: connector deca { $item[2] } |
|
76
|
|
|
|
|
|
|
| number connector tens { $item[1] + $item[3] } |
|
77
|
|
|
|
|
|
|
| tens |
|
78
|
|
|
|
|
|
|
| number |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
hecto: number 'honnert' deca { $item[1] * 100 + $item[3] } |
|
81
|
|
|
|
|
|
|
| number 'honnert' { $item[1] * 100 } |
|
82
|
|
|
|
|
|
|
| 'honnert' deca { 100 + $item[2] } |
|
83
|
|
|
|
|
|
|
| 'honnert' { 100 } |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
hOd: hecto |
|
86
|
|
|
|
|
|
|
| deca |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
kilo: hOd 'dausend' hOd { $item[1] * 1000 + $item[3] } |
|
89
|
|
|
|
|
|
|
| hOd 'dausend' { $item[1] * 1000 } |
|
90
|
|
|
|
|
|
|
| 'dausend' hOd { 1000 + $item[2] } |
|
91
|
|
|
|
|
|
|
| 'dausend' { 1000 } |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
kOhOd: kilo |
|
94
|
|
|
|
|
|
|
| hOd |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
mega: hOd /Millioun(en)?/ kOhOd { $item[1] * 1_000_000 + $item[3] } |
|
97
|
|
|
|
|
|
|
| hOd /Millioun(en)?/ { $item[1] * 1_000_000 } |
|
98
|
|
|
|
|
|
|
}); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# }}} |
|
102
|
|
|
|
|
|
|
# {{{ ordinal2cardinal convert ordinal text to cardinal text |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub ordinal2cardinal :Export { |
|
105
|
0
|
|
0
|
0
|
1
|
|
my $input = shift // return; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# Inverse of Luxembourgish ordinal morphology: restore cardinal from ordinal text. |
|
108
|
|
|
|
|
|
|
# Irregulars (standalone or as final element of compound) |
|
109
|
0
|
0
|
|
|
|
|
$input =~ s{éischt\z}{eent}xms and return $input; |
|
110
|
0
|
0
|
|
|
|
|
$input =~ s{zweet\z}{zwee}xms and return $input; |
|
111
|
0
|
0
|
|
|
|
|
$input =~ s{drëtt\z}{dräi}xms and return $input; |
|
112
|
0
|
0
|
|
|
|
|
$input =~ s{sechst\z}{sechs}xms and return $input; # 6th: stem 's' consumed by suffix |
|
113
|
0
|
0
|
|
|
|
|
$input =~ s{siiwent\z}{siwen}xms and return $input; |
|
114
|
0
|
0
|
|
|
|
|
$input =~ s{aacht\z}{aacht}xms and return $input; # 8th = cardinal (no change) |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# Regular: strip -st (20+ and compounds ending in tens/honnert/dausend) |
|
117
|
0
|
0
|
|
|
|
|
$input =~ s{st\z}{}xms and return $input; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Regular: strip -t (4-19) |
|
120
|
0
|
0
|
|
|
|
|
$input =~ s{t\z}{}xms and return $input; |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return; # not an ordinal |
|
123
|
1
|
|
|
1
|
|
597
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# }}} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
__END__ |