blib/lib/Lingua/OCI/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::OCI::Word2Num;
4 # ABSTRACT: Word to number conversion in Occitan
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 = oci_numerals();
19  
20 # }}}
21  
22 # {{{ w2n convert text to number
23  
24 sub w2n :Export {
25 36 ▶ my $input = shift // return;
Subroutine w2n: called CC=2 SCAR=6.9
Pod documented
Condition100%2/2
shift() // (return)
l!l
351
MC/DC100%1/1
shift() // (return)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
26  
27 35 $input = lc $input;
28 35 $input =~ s/\s+/ /g;
29 35 $input =~ s/^\s+|\s+$//g;
30  
31 35 return $parser->numeral($input);
32 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
33 # }}}
34 # {{{ oci_numerals create parser for numerals
35  
36 sub oci_numerals {
37 1 ▶ return Parse::RecDescent->new(q{
Subroutine oci_numerals: called CC=1 SCAR=0.0
Pod documented
38 <autoaction: { $item[1] } >
39 <nocheck>
40  
41 numeral: mega
42 | kOhOd
43 | /z(?:e|è)ro/ { 0 }
44 | { }
45  
46 number: 'un' { 1 }
47 | 'dos' { 2 }
48 | 'tres' { 3 }
49 | 'quatre' { 4 }
50 | 'cinc' { 5 }
51 | /si(?:e|è)is/ { 6 }
52 | /u(?:e|è)ch/ { 8 }
53 | /n(?:o|ò)u/ { 9 }
54 | /d(?:e|è)tz-e-s(?:e|è)t/ { 17 }
55 | /d(?:e|è)tz-e-u(?:e|è)ch/ { 18 }
56 | /d(?:e|è)tz-e-n(?:o|ò)u/ { 19 }
57 | /d(?:e|è)tz/ { 10 }
58 | 'onze' { 11 }
59 | 'dotze' { 12 }
60 | 'tretze' { 13 }
61 | /cat(?:o|ò)rze/ { 14 }
62 | 'quinze' { 15 }
63 | 'setze' { 16 }
64 | /s(?:e|è)t/ { 7 }
65 | 'vint-e-un' { 21 }
66 | 'vint-e-dos' { 22 }
67 | 'vint-e-tres' { 23 }
68 | 'vint-e-quatre' { 24 }
69 | 'vint-e-cinc' { 25 }
70 | /vint-e-si(?:e|è)is/ { 26 }
71 | /vint-e-s(?:e|è)t/ { 27 }
72 | /vint-e-u(?:e|è)ch/ { 28 }
73 | /vint-e-n(?:o|ò)u/ { 29 }
74 | 'vint' { 20 }
75  
76 tens: 'trenta' { 30 }
77 | 'quaranta' { 40 }
78 | 'cinquanta' { 50 }
79 | 'seissanta' { 60 }
80 | 'setanta' { 70 }
81 | 'ochanta' { 80 }
82 | 'nonanta' { 90 }
83  
84 hundreds: number /\-?\s?cents?/ { $item[1] * 100 }
85 | /cents?/ { 100 }
86  
87 deca: tens /-e-/ number { $item[1] + $item[3] }
88 | tens
89 | number
90  
91 hecto: hundreds deca { $item[1] + $item[2] }
92 | hundreds
93  
94 hOd: hecto
95 | deca
96  
97 kilo: hOd milnotmeg hOd { $item[1] * 1000 + $item[3] }
98 | hOd milnotmeg { $item[1] * 1000 }
99 | milnotmeg hOd { 1000 + $item[2] }
100 | milnotmeg { 1000 }
101  
102 milnotmeg: ...!'milion' 'mila'
103  
104 kOhOd: kilo
105 | hOd
106  
107 mega: hOd /milions?/ kOhOd { $item[1] * 1_000_000 + $item[3] }
108 | hOd /milions?/ { $item[1] * 1_000_000 }
109 });
110 }
111  
112 # }}}
113  
114 1 1;
115  
116 __END__
↑ Summary