blib/lib/Lingua/TUR/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 package Lingua::TUR::Word2Num;
3 # ABSTRACT: Word to number conversion in Turkish
4  
5 1 ▶use 5.16.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # {{{ use block
10  
11 1 ▶use Export::Attrs;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Parse::RecDescent;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # }}}
15 # {{{ var block
16 1 our $VERSION = '0.2603270';
17 1 my $parser = tur_numerals();
18  
19 # }}}
20  
21 # {{{ w2n convert text to number
22  
23 sub w2n :Export {
24 2 ▶ my $input = shift // return;
Subroutine w2n: called CC=2 SCAR=6.9
Pod documented
Condition100%2/2
shift() // (return)
l!l
11
MC/DC100%1/1
shift() // (return)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
25  
26 1 return $parser->numeral($input);
27 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 # }}}
30 # {{{ tur_numerals create parser for turkish numerals
31  
32 sub tur_numerals {
33 1 ▶ return Parse::RecDescent->new(q{
Subroutine tur_numerals: called CC=1 SCAR=0.0
Pod documented
34 <autoaction: { $item[1] } >
35  
36 numeral: mega
37 | kOhOd
38 | { }
39  
40 number: 'sıfır' { 0 }
41 | 'bir' { 1 }
42 | 'iki' { 2 }
43 | 'üç' { 3 }
44 | 'dört' { 4 }
45 | 'beş' { 5 }
46 | 'altı' { 6 }
47 | 'yedi' { 7 }
48 | 'sekiz' { 8 }
49 | 'dokuz' { 9 }
50  
51 tens: 'on' { 10 }
52 | 'yirmi' { 20 }
53 | 'otuz' { 30 }
54 | 'kırk' { 40 }
55 | 'elli' { 50 }
56 | 'altmış' { 60 }
57 | 'yetmiş' { 70 }
58 | 'seksen' { 80 }
59 | 'doksan' { 90 }
60  
61 deca: tens number { $item[1] + $item[2] }
62 | tens
63 | number
64  
65 hecto: number 'yüz' deca { $item[1] * 100 + $item[3] }
66 | number 'yüz' { $item[1] * 100 }
67 | 'yüz' deca { 100 + $item[2] }
68 | 'yüz' { 100 }
69  
70 hOd: hecto
71 | deca
72  
73 kilo: hOd 'bin' hOd { $item[1] * 1000 + $item[3] }
74 | hOd 'bin' { $item[1] * 1000 }
75 | 'bin' hOd { 1000 + $item[2] }
76 | 'bin' { 1000 }
77  
78 kOhOd: kilo
79 | hOd
80  
81 mega: hOd 'milyon' kOhOd { $item[1] * 1_000_000 + $item[3] }
82 | hOd 'milyon' { $item[1] * 1_000_000 }
83 });
84 }
85  
86 # }}}
87  
88 1 1;
89  
90 __END__
↑ Summary