blib/lib/Lingua/AFR/Word2Num.pm

filter: Statementstmt 100% 28 / 28 Branchbran n/a Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 95.2% 40 / 42 CC 2 SCAR 1.9
CC
2
Cov
97%
w2n
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 # For Emacs: -*- mode:cperl; eval: (folding-mode 1) -*-
2  
3 package Lingua::AFR::Word2Num;
4 # ABSTRACT: Word to number conversion in Afrikaans
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 Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Export::Attrs;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Parse::RecDescent;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 # }}}
18 # {{{ variable declarations
19 1 our $VERSION = '0.2603270';
20  
21 1 my $parser = afr_numerals();
22  
23 # }}}
24  
25 # {{{ w2n convert text to number
26  
27 sub w2n :Export {
28 3 ▶ my $input = shift // return;
Subroutine w2n: called CC=2 SCAR=7.0
Pod documented
Condition50%1/2
shift() // (return)
l!l
30
MC/DC0%0/1
shift() // (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
29  
30 3 $input =~ s/,//g;
31 3 $input =~ s/ //g;
32  
33 3 return $parser->numeral($input);
34 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
35 # }}}
36 # {{{ afr_numerals create parser for numerals
37  
38 sub afr_numerals {
39 1 ▶ return Parse::RecDescent->new(q{
Subroutine afr_numerals: called CC=1 SCAR=0.0
Pod documented
40 <autoaction: { $item[1] } >
41  
42 numeral: mega
43 | kOhOd
44 | 'nul' { 0 }
45 | { }
46  
47 number: 'viertien' { 14 }
48 | 'vyftien' { 15 }
49 | 'sestien' { 16 }
50 | 'sewentien' { 17 }
51 | 'agtien' { 18 }
52 | 'negentien' { 19 }
53 | 'een' { 1 }
54 | 'twee' { 2 }
55 | 'drie' { 3 }
56 | 'vier' { 4 }
57 | 'vyf' { 5 }
58 | 'ses' { 6 }
59 | 'sewe' { 7 }
60 | 'agt' { 8 }
61 | 'nege' { 9 }
62 | 'tien' { 10 }
63 | 'elf' { 11 }
64 | 'twaalf' { 12 }
65 | 'dertien' { 13 }
66  
67 tens: 'twintig' { 20 }
68 | 'dertig' { 30 }
69 | 'viertig' { 40 }
70 | 'vyftig' { 50 }
71 | 'sestig' { 60 }
72 | 'sewentig' { 70 }
73 | 'tagtig' { 80 }
74 | 'negentig' { 90 }
75  
76 deca:
77 number 'en' tens { $item[1] + $item[3] }
78 | tens
79 | number
80  
81 hecto: number 'honderd' /(en)?/ deca { $item[1] * 100 + $item[4] }
82 | number 'honderd' { $item[1] * 100 }
83  
84 hOd: hecto
85 | deca
86  
87 kilo: hOd 'duisend' /(en)?/ hOd { $item[1] * 1000 + $item[4] }
88 | hOd 'duisend' { $item[1] * 1000 }
89  
90 kOhOd: kilo
91 | hOd
92  
93 mega: hOd 'miljoen' /(en)?/ kOhOd { $item[1] * 1_000_000 + $item[4] }
94 | hOd 'miljoen' { $item[1] * 1_000_000 }
95 });
96 }
97  
98 # }}}
99  
100 1 1;
101  
102 __END__
↑ Summary