blib/lib/Lingua/FRA/Word2Num.pm

filter: Statementstmt 100% 23 / 23 Branchbran n/a Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 100% 36 / 36 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::FRA::Word2Num;
4 # ABSTRACT: Word to number conversion in French
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 Export::Attrs;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Parse::RecDescent;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # }}}
16 # {{{ var block
17 1 our $VERSION = '0.2603270';
18 1 my $parser = fra_numerals();
19  
20 # }}}
21  
22 # {{{ w2n convert text to number
23  
24 sub w2n :Export {
25 4 ▶ my $input = shift // return;
Subroutine w2n: called CC=2 SCAR=6.9
Pod documented
Condition100%2/2
shift() // (return)
l!l
31
MC/DC100%1/1
shift() // (return)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
26  
27 3 return $parser->numeral($input);
28 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 # }}}
31 # {{{ fra_numerals create parser for numerals
32  
33 sub fra_numerals {
34 1 ▶ return Parse::RecDescent->new(q{
Subroutine fra_numerals: called CC=1 SCAR=0.0
Pod documented
35 <autoaction: { $item[1] } >
36  
37 numeral: mega
38 | kOhOd
39 | 'zéro' { 0 }
40 | { }
41  
42 number: 'un' { 1 }
43 | 'deux' { 2 }
44 | 'trois' { 3 }
45 | 'quatre' { 4 }
46 | 'cinq' { 5 }
47 | 'six' { 6 }
48 | 'sept' { 7 }
49 | 'huit' { 8 }
50 | 'neuf' { 9 }
51 | 'dix-sept' { 17 }
52 | 'dix-huit' { 18 }
53 | 'dix-neuf' { 19 }
54 | 'dix' { 10 }
55 | 'onze' { 11 }
56 | 'douze' { 12 }
57 | 'treize' { 13 }
58 | 'quatorze' { 14 }
59 | 'quinze' { 15 }
60 | 'seize' { 16 }
61  
62 tens: 'vingt' { 20 }
63 | 'trente' { 30 }
64 | 'quarante' { 40 }
65 | 'cinquante' { 50 }
66 | 'soixante-dix' { 70 }
67 | 'soixante' { 60 }
68 | /quatre-vingts?/ { 80 }
69  
70 deca: tens /-?/ number { $item[1] + $item[3] }
71 | tens 'et' number { $item[1] + $item[3] }
72 | tens
73 | number
74  
75 hecto: number /cents?/ deca { $item[1] * 100 + $item[3] }
76 | number /cents?/ { $item[1] * 100 }
77 | /cents?/ deca { 100 + $item[2] }
78 | 'cent' { 100 }
79  
80 hOd: hecto
81 | deca
82  
83 kilo: hOd /milles?/ hOd { $item[1] * 1000 + $item[3] }
84 | hOd /milles?/ { $item[1] * 1000 }
85 | /milles?/ hOd { 1000 + $item[2] }
86 | 'mille' { 1000 }
87  
88 kOhOd: kilo
89 | hOd
90  
91 mega: kOhOd /millions?/ kOhOd { $item[1] * 1_000_000 + $item[3] }
92 });
93 }
94 # }}}
95  
96 1 1;
97  
98 __END__
↑ Summary