line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::PT::Ords2Nums; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
76791
|
use 5.006; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
124
|
|
4
|
3
|
|
|
3
|
|
27
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
122
|
|
5
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
132
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1330
|
use Lingua::PT::Words2Nums qw/word2num/; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
14
|
|
|
|
|
|
|
ord2num |
15
|
|
|
|
|
|
|
) ] ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @EXPORT = qw( |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my %values; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Lingua::PT::Ords2Nums - Converts Portuguese ordinals to numbers |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SYNOPSIS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Lingua::PT::Ords2Nums qw/ord2num/; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$num = word2num('décimo primeiro') # 11 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Converts Portuguese ordinals to numbers. Works up to 999.999.999.999 |
39
|
|
|
|
|
|
|
('novecentos e noventa e nove bilionésimos novecentos e noventa e nove |
40
|
|
|
|
|
|
|
milionésimos novecentos e noventa e nove milésimos nongentésimo nonagésimo |
41
|
|
|
|
|
|
|
nono'). |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
BEGIN { |
46
|
|
|
|
|
|
|
%values = ( |
47
|
|
|
|
|
|
|
'bilionésimo' => 1000000000, |
48
|
|
|
|
|
|
|
'milionésimo' => 1000000, |
49
|
|
|
|
|
|
|
'milésimo' => 1000, |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
'nongentésimo' => 900, |
52
|
|
|
|
|
|
|
'octigentésimo' => 800, |
53
|
|
|
|
|
|
|
'septigentésimo' => 700, |
54
|
|
|
|
|
|
|
'seiscentésimo' => 600, |
55
|
|
|
|
|
|
|
'quingentésimo' => 500, |
56
|
|
|
|
|
|
|
'quadrigentésimo' => 400, |
57
|
|
|
|
|
|
|
'tricentésimo' => 300, |
58
|
|
|
|
|
|
|
'ducentésimo' => 200, |
59
|
|
|
|
|
|
|
'centésimo' => 100, |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
'nonagésimo' => 90, |
62
|
|
|
|
|
|
|
'octogésimo' => 80, |
63
|
|
|
|
|
|
|
'septuagésimo' => 70, |
64
|
|
|
|
|
|
|
'sexagésimo' => 60, |
65
|
|
|
|
|
|
|
'quinquagésimo' => 50, |
66
|
|
|
|
|
|
|
'quadragésimo' => 40, |
67
|
|
|
|
|
|
|
'trigésimo' => 30, |
68
|
|
|
|
|
|
|
'vigésimo' => 20, |
69
|
|
|
|
|
|
|
'décimo' => 10, |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
nono => 9, |
72
|
|
|
|
|
|
|
oitavo => 8, |
73
|
|
|
|
|
|
|
'sétimo' => 7, |
74
|
|
|
|
|
|
|
sexto => 6, |
75
|
|
|
|
|
|
|
quinto => 5, |
76
|
|
|
|
|
|
|
quarto => 4, |
77
|
|
|
|
|
|
|
terceiro => 3, |
78
|
|
|
|
|
|
|
segundo => 2, |
79
|
|
|
|
|
|
|
primeiro => 1, |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 ord2num |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Turns an ordinal number into a regular number (decimal). |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$num = word2num('segundo') |
89
|
|
|
|
|
|
|
# $num now holds 2 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub ord2num { |
94
|
|
|
|
|
|
|
$_ = shift || return undef; |
95
|
|
|
|
|
|
|
my $result = 0; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
s/(.*)bilionésimos/$result += (word2num($1) * 1000000000)/e; |
98
|
|
|
|
|
|
|
s/(.*)milionésimos/$result += (word2num($1) * 1000000)/e; |
99
|
|
|
|
|
|
|
s/(.*)milésimos/$result += (word2num($1) * 1000)/e; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
for my $value (keys %values) { |
102
|
|
|
|
|
|
|
s/$value/$result += $values{$value}/e; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$result; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
__END__ |