Phonetic/Metaphone.pm

filter: Statementstmt 100% 14 / 14 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 95.2% 20 / 21 CC 2 SCAR 3.2
CC
2
Cov
94%
__ANON__
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Phonetic/Soundex.pm ↑ Summary Phonetic/DoubleMetaphone.pm »
1 # ============================================================================
2 package Text::Phonetic::Metaphone;
3 # ============================================================================
4 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 extends qw(Text::Phonetic);
8  
9 has 'max_length'=> (
10 is => 'rw',
11 4 ▶ isa => sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
12 4 ▶ die 'max_length must be an int' unless shift =~ /\d/
Branch: 1 branch
BranchTrueFalseTotal
unless (shift()) =~ /\d/ 0 4 4
13 },
14 3 documentation => q[Limit the length of the encoded string],
15 default => 0,
16 );
17  
18 3 our $VERSION = $Text::Phonetic::VERSION;
19  
20 2 ▶sub _predicates {
Subroutine _predicates: called CC=1 SCAR=0.0
21 2 return 'Text::Metaphone';
22 }
23  
24 9 ▶sub _do_encode {
Subroutine _do_encode: called CC=1 SCAR=0.0
25 9 my ($self,$string) = @_;
26  
27 9 return Text::Metaphone::Metaphone($string,$self->max_length);
28 }
29  
30 3 1;
31  
32 =encoding utf8
33  
34 =pod
35  
36 =head1 NAME
37  
38 Text::Phonetic::Metaphone - Metaphone algorithm
39  
40 =head1 DESCRIPTION
41  
42 Metaphone was developed by Lawrence Philips as a response to deficiencies in
43 the Soundex algorithm. It is more accurate than Soundex because it uses a
44 larger set of rules for English pronunciation. (Wikipedia, 2007)
45  
46 This module is a thin wrapper around L<Text::Metaphone>.
47  
48 The parameter C<max_length> can be set to limit the length of the encoded
49 string.
50  
51 =head1 AUTHOR
52  
53 Maroš Kollár
54 CPAN ID: MAROS
55 maros [at] k-1.com
56 http://www.k-1.com
57  
58 =head1 COPYRIGHT
59  
60 Text::Phonetic::Metaphone is Copyright (c) 2006,2007 Maroš. Kollár.
61 All rights reserved.
62  
63 This program is free software; you can redistribute
64 it and/or modify it under the same terms as Perl itself.
65  
66 The full text of the license can be found in the
67 LICENSE file included with this module.
68  
69 =head1 SEE ALSO
70  
71 Description of the algorithm can be found at
72 L<http://en.wikipedia.org/wiki/Metaphone>
73  
74 L<Text::Metaphone>
75  
76 =cut
« Phonetic/Soundex.pm ↑ Summary Phonetic/DoubleMetaphone.pm »