File Coverage

blib/lib/Text/Phonetic/Soundex.pm
Criterion Covered Total %
statement 13 13 100.0
branch 4 4 100.0
condition n/a
subroutine 4 4 100.0
pod n/a
total 21 21 100.0


line stmt bran cond sub pod time code
1             # ============================================================================
2             package Text::Phonetic::Soundex;
3             # ============================================================================
4 3     3   4345 use utf8;
  3         4  
  3         11  
5              
6 3     3   67 use Moo;
  3         3  
  3         11  
7             extends qw(Text::Phonetic);
8              
9             has 'nara'=> (
10             is => 'rw',
11             documentation => q[Use the soundex variant maintained by the National Archives and Records Administration (NARA)],
12             default => 0,
13             );
14              
15             has 'nocode'=> (
16             is => 'rw',
17             documentation => q[Redefine the value that will be returned if the input string contains no identifiable sounds within it],
18             predicate => 'has_nocode',
19             );
20              
21             __PACKAGE__->meta->make_immutable;
22              
23             our $VERSION = $Text::Phonetic::VERSION;
24              
25             sub _predicates {
26 2     2   5 return 'Text::Soundex';
27             }
28              
29             sub _do_encode {
30 23     23   19 my ($self,$string) = @_;
31            
32 23 100       41 if ($self->has_nocode) {
33 1         2 $Text::Soundex::nocode = $self->nocode;
34             }
35            
36 23 100       28 if ($self->nara) {
37 1         3 return Text::Soundex::soundex_nara($string);
38             } else {
39 22         66 return Text::Soundex::soundex($string);
40             }
41             }
42              
43             1;
44              
45             =encoding utf8
46              
47             =pod
48              
49             =head1 NAME
50              
51             Text::Phonetic::Soundex - Soundex algorithm
52              
53             =head1 DESCRIPTION
54              
55             Soundex is a phonetic algorithm for indexing names by sound, as pronounced in
56             English. Soundex is the most widely known of all phonetic algorithms.
57             Improvements to Soundex are the basis for many modern phonetic algorithms.
58             (Wikipedia, 2007)
59              
60             If the parameter C is set to a true value, a variant of the soundex
61             algorithm maintained by the National Archives and Records Administration
62             (NARA) will be used.
63              
64             If the parameter C redefines the value that will be returned if the
65             input string contains no identifiable sounds within it.
66              
67             This module is a thin wrapper around L.
68              
69             =head1 AUTHOR
70              
71             Maroš Kollár
72             CPAN ID: MAROS
73             maros [at] k-1.com
74             http://www.k-1.com
75              
76             =head1 COPYRIGHT
77              
78             Text::Phonetic::Soundex is Copyright (c) 2006,2007 Maroš. Kollár.
79             All rights reserved.
80              
81             This program is free software; you can redistribute
82             it and/or modify it under the same terms as Perl itself.
83              
84             The full text of the license can be found in the
85             LICENSE file included with this module.
86              
87             =head1 SEE ALSO
88              
89             Description of the algorithm can be found at
90             L
91              
92             L
93              
94             =cut