line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# For Emacs: -*- mode:cperl; mode:folding; coding:utf-8 -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Lingua::DEU::Word2Num; |
4
|
|
|
|
|
|
|
# ABSTRACT: Word 2 Number conversion in DEU. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# {{{ use block |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
25877
|
use 5.10.1; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
127
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
11
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
66
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
1007
|
use Encode qw(decode_utf8); |
|
1
|
|
|
|
|
19405
|
|
|
1
|
|
|
|
|
107
|
|
14
|
1
|
|
|
1
|
|
1809
|
use Parse::RecDescent; |
|
1
|
|
|
|
|
57461
|
|
|
1
|
|
|
|
|
10
|
|
15
|
1
|
|
|
1
|
|
1619
|
use Perl6::Export::Attrs; |
|
1
|
|
|
|
|
16788
|
|
|
1
|
|
|
|
|
13
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# }}} |
18
|
|
|
|
|
|
|
# {{{ variables |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = 0.1106; |
21
|
|
|
|
|
|
|
my $parser = deu_numerals(); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# }}} |
24
|
|
|
|
|
|
|
# {{{ w2n convert number to text |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub w2n :Export { |
27
|
4
|
|
100
|
4
|
1
|
155737
|
my $input = shift // return; |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
37
|
return $parser->numeral($input); |
30
|
1
|
|
|
1
|
|
201
|
} |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# }}} |
33
|
|
|
|
|
|
|
# {{{ deu_numerals create parser for german numerals |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub deu_numerals { |
36
|
1
|
|
|
1
|
1
|
8
|
return Parse::RecDescent->new(decode_utf8(q{ |
37
|
|
|
|
|
|
|
numeral: |
38
|
|
|
|
|
|
|
numeral: scrap |
39
|
|
|
|
|
|
|
{ return undef; } |
40
|
|
|
|
|
|
|
| millenium |
41
|
|
|
|
|
|
|
{ return $item[1]; } |
42
|
|
|
|
|
|
|
| century |
43
|
|
|
|
|
|
|
{ return $item[1]; } |
44
|
|
|
|
|
|
|
| decade |
45
|
|
|
|
|
|
|
{ return $item[1]; } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
number: 'dreizehn' { $return = 13; } |
48
|
|
|
|
|
|
|
| 'vierzehn' { $return = 14; } |
49
|
|
|
|
|
|
|
| 'fünfzehn' { $return = 15; } |
50
|
|
|
|
|
|
|
| 'sechzehn' { $return = 16; } |
51
|
|
|
|
|
|
|
| 'siebzehn' { $return = 17; } |
52
|
|
|
|
|
|
|
| 'achtzehn' { $return = 18; } |
53
|
|
|
|
|
|
|
| 'neunzehn' { $return = 19; } |
54
|
|
|
|
|
|
|
| 'null' { $return = 0; } |
55
|
|
|
|
|
|
|
| 'ein' { $return = 1; } |
56
|
|
|
|
|
|
|
| 'zwei' { $return = 2; } |
57
|
|
|
|
|
|
|
| 'drei' { $return = 3; } |
58
|
|
|
|
|
|
|
| 'vier' { $return = 4; } |
59
|
|
|
|
|
|
|
| 'fünf' { $return = 5; } |
60
|
|
|
|
|
|
|
| 'sechs' { $return = 6; } |
61
|
|
|
|
|
|
|
| 'sieben' { $return = 7; } |
62
|
|
|
|
|
|
|
| 'acht' { $return = 8; } |
63
|
|
|
|
|
|
|
| 'neun' { $return = 9; } |
64
|
|
|
|
|
|
|
| 'zehn' { $return = 10; } |
65
|
|
|
|
|
|
|
| 'elf' { $return = 11; } |
66
|
|
|
|
|
|
|
| 'zwölf' { $return = 12; } |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
tens: 'zwanzig' { $return = 20; } |
69
|
|
|
|
|
|
|
| 'dreissig' { $return = 30; } |
70
|
|
|
|
|
|
|
| 'vierzig' { $return = 40; } |
71
|
|
|
|
|
|
|
| 'fünfzig' { $return = 50; } |
72
|
|
|
|
|
|
|
| 'sechzig' { $return = 60; } |
73
|
|
|
|
|
|
|
| 'siebzig' { $return = 70; } |
74
|
|
|
|
|
|
|
| 'achtzig' { $return = 80; } |
75
|
|
|
|
|
|
|
| 'neunzig' { $return = 90; } |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
decade: 'und' decade |
78
|
|
|
|
|
|
|
{ $return = $item[2]; } |
79
|
|
|
|
|
|
|
| number 'und' tens |
80
|
|
|
|
|
|
|
{ $return = $item[1] + $item[3]; } |
81
|
|
|
|
|
|
|
| tens |
82
|
|
|
|
|
|
|
{ $return = $item[1]; } |
83
|
|
|
|
|
|
|
| number |
84
|
|
|
|
|
|
|
{ $return = $item[1]; } |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
century: number 'hundert' decade |
87
|
|
|
|
|
|
|
{ $return = $item[1] * 100 + $item[3]; } |
88
|
|
|
|
|
|
|
| number 'hundert' |
89
|
|
|
|
|
|
|
{ $return = $item[1] * 100; } |
90
|
|
|
|
|
|
|
| 'hundert' |
91
|
|
|
|
|
|
|
{ $return = 100; } |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
millenium: century 'tausend' century |
94
|
|
|
|
|
|
|
{ $return = $item[1] * 1000 + $item[3]; } |
95
|
|
|
|
|
|
|
| century 'tausend' decade |
96
|
|
|
|
|
|
|
{ $return = $item[1] * 1000 + $item[3]; } |
97
|
|
|
|
|
|
|
| decade 'tausend' century |
98
|
|
|
|
|
|
|
{ $return = $item[1] * 1000 + $item[3]; } |
99
|
|
|
|
|
|
|
| decade 'tausend' decade |
100
|
|
|
|
|
|
|
{ $return = $item[1] * 1000 + $item[3]; } |
101
|
|
|
|
|
|
|
| decade 'tausend' |
102
|
|
|
|
|
|
|
{ $return = $item[1] * 1000; } |
103
|
|
|
|
|
|
|
| century 'tausend' |
104
|
|
|
|
|
|
|
{ $return = $item[1] * 1000; } |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
scrap: millenium(?) century(?) decade(?) |
107
|
|
|
|
|
|
|
/(.+)/ |
108
|
|
|
|
|
|
|
millenium(?) century(?) decade(?) |
109
|
|
|
|
|
|
|
{ |
110
|
|
|
|
|
|
|
carp("unknown numeral '$1' !\n"); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
})); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# }}} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |