blib/lib/Lingua/SRD/Word2Num.pm

filter: Statementstmt 100% 26 / 26 Branchbran n/a Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 39 / 39 CC 2 SCAR 2.0
CC
2
Cov
100%
w2n
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 # For Emacs: -*- mode:cperl; eval: (folding-mode 1); coding:utf-8 -*-
2  
3 package Lingua::SRD::Word2Num;
4 # ABSTRACT: Word to number conversion in Sardinian (Logudorese)
5  
6 1 ▶use 5.16.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # {{{ use block
11  
12 1 ▶use Parse::RecDescent;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Export::Attrs;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # }}}
16 # {{{ var block
17 1 our $VERSION = '0.2603270';
18 1 my $parser = srd_numerals();
19  
20 # }}}
21  
22 # {{{ w2n convert text to number
23  
24 sub w2n :Export {
25 21 ▶ my $input = shift // return;
Subroutine w2n: called CC=2 SCAR=6.9
Pod documented
Condition100%2/2
shift() // (return)
l!l
201
MC/DC100%1/1
shift() // (return)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
26  
27 20 $input = lc $input;
28 20 $input =~ s/\s+/ /g;
29 20 $input =~ s/^\s+|\s+$//g;
30  
31 20 return $parser->numeral($input);
32 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
33 # }}}
34 # {{{ srd_numerals create parser for numerals
35  
36 sub srd_numerals {
37 1 ▶ return Parse::RecDescent->new(q{
Subroutine srd_numerals: called CC=1 SCAR=0.0
Pod documented
38 <autoaction: { $item[1] } >
39 <nocheck>
40  
41 numeral: mega
42 | kOhOd
43 | 'zeru' { 0 }
44 | { }
45  
46 number: 'deghesete' { 17 }
47 | 'degheoto' { 18 }
48 | 'deghenoe' { 19 }
49 | 'undighi' { 11 }
50 | 'doighi' { 12 }
51 | 'treighi' { 13 }
52 | 'batordighi' { 14 }
53 | 'bindighi' { 15 }
54 | 'seighi' { 16 }
55 | 'deghe' { 10 }
56 | 'bintunu' { 21 }
57 | 'bintiduos' { 22 }
58 | 'bintitres' { 23 }
59 | 'bintibàtoro' { 24 }
60 | 'bintichimbe' { 25 }
61 | 'bintises' { 26 }
62 | 'bintisete' { 27 }
63 | 'bintioto' { 28 }
64 | 'bintinoe' { 29 }
65 | 'binti' { 20 }
66 | 'trintunu' { 31 }
67 | 'trintatres' { 33 }
68 | 'barantunu' { 41 }
69 | 'barantaduos' { 42 }
70 | 'chinbantunu' { 51 }
71 | 'sessantunu' { 61 }
72 | 'setantunu' { 71 }
73 | 'otantunu' { 81 }
74 | 'nonantunu' { 91 }
75 | 'chimbe' { 5 }
76 | 'sete' { 7 }
77 | 'ses' { 6 }
78 | 'oto' { 8 }
79 | 'noe' { 9 }
80 | 'unu' { 1 }
81 | 'duos' { 2 }
82 | 'tres' { 3 }
83 | 'bàtoro' { 4 }
84  
85 tens: 'trinta' { 30 }
86 | 'baranta' { 40 }
87 | 'chinbanta' { 50 }
88 | 'sessanta' { 60 }
89 | 'setanta' { 70 }
90 | 'otanta' { 80 }
91 | 'nonanta' { 90 }
92  
93 hundreds: 'nobi' /chentos?/ { 900 }
94 | 'oto' /chentos?/ { 800 }
95 | 'sete' /chentos?/ { 700 }
96 | 'ses' /chentos?/ { 600 }
97 | 'chinbi' /chentos?/ { 500 }
98 | 'bator' /chentos?/ { 400 }
99 | 'tre' /chentos?/ { 300 }
100 | 'du' /chentos?/ { 200 }
101 | /chentu/ { 100 }
102  
103 deca: tens number { $item[1] + $item[2] }
104 | tens
105 | number
106  
107 hecto: hundreds deca { $item[1] + $item[2] }
108 | hundreds
109  
110 hOd: hecto
111 | deca
112  
113 kilo: 'duamiza' hOd { 2000 + $item[2] }
114 | 'duamiza' { 2000 }
115 | hOd 'miza' hOd { $item[1] * 1000 + $item[3] }
116 | hOd 'miza' { $item[1] * 1000 }
117 | hOd milnotmeg hOd { $item[1] * 1000 + $item[3] }
118 | hOd milnotmeg { $item[1] * 1000 }
119 | milnotmeg hOd { 1000 + $item[2] }
120 | milnotmeg { 1000 }
121  
122 milnotmeg: ...!'milione' ...!'miliones' 'milli'
123  
124 kOhOd: kilo
125 | hOd
126  
127 mega: hOd 'miliones' kOhOd { $item[1] * 1_000_000 + $item[3] }
128 | hOd 'miliones' { $item[1] * 1_000_000 }
129 | number 'milione' kOhOd { $item[1] * 1_000_000 + $item[3] }
130 | number 'milione' { $item[1] * 1_000_000 }
131 });
132 }
133  
134 # }}}
135  
136 1 1;
137  
138 __END__
↑ Summary