Normal/Config/AddressStop.pm

filter: Statementstmt 95.4% 21 / 22 Branchbran 50.0% 3 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 82.8% 29 / 35 CC 6 SCAR 15.5
CC
6
Cov
83%
_data
6.6
BEGIN
1.0
BEGIN
1.0
CRAP 4.7
« Normal/Type/Title.pm ↑ Summary Normal/Config/TitleStop.pm »
1 package String::Normal::Config::AddressStop;
2 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 9 ▶use String::Normal::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub _data {
Subroutine _data: called CC=6 SCAR=18.8
8 1 my %params = @_;
9  
10 1 my $fh;
11 1 ▶ if ($params{addres_stop}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params{'addres_stop'}) { } 0 1 1
12 0 ▶ open $fh, $params{addres_stop} or die "Can't read '$params{addres_stop}' $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, $params{"addres_stop"} or die qq[Can't read '$params{"addres_stop"}' $!\n] 0 0 0
13 } else {
14 1 $fh = *DATA;
15 }
16  
17 1 my %stop;
18 1 for (String::Normal::Config::_slurp( $fh )) {
19 34 ▶ next if /^#/;
Branch: 1 branch
BranchTrueFalseTotal
if /^#/ 8 26 34
20 26 my ($word,$count) = split ',', $_;
21 26 ▶ $count ||= 1;
Condition50%1/2
$count ||= 1
l!l
026
MC/DC0%0/1
$count ||= 1
$count
Truth table50%1/2
A
A= $count
Aresult
11
00
22 26 $stop{middle}->{$word} = $count;
23 }
24  
25 1 return \%stop;
26 }
27  
28 9 1;
29  
30 =head1 NAME
31  
32 String::Normal::Config::AddressStop;
33  
34 =head1 DESCRIPTION
35  
36 This package defines removals to be performed on Address types.
37  
38 =head1 STRUCTURE
39  
40 One entry per line. Each value will be removed. Special characters
41 C<^> and C<$> are NOT used. You can prepend C<#> to lines that you
42 wish to skip. For example:
43  
44 the
45 #and
46  
47 Would remove all occurances of C<the> but not C<and>. Special character
48 C<,> is used to override removal if the final number of tokens if less
49 then the digit specified. For example:
50  
51 the,2
52  
53 Would remove all occurances of C<the> in "The Generic Title" but would
54 not remove any occurances in "The The".
55  
56 You can provide your own data by creating a text file containing your
57 values and provide the path to that file via the constructor:
58  
59 my $normalizer = String::Normal->new( address_stop => '/path/to/values.txt' );
60  
61 =head1 AUTHOR
62  
63 Jeff Anderson, C<< <jeffa at cpan.org> >>
64  
65 =head1 LICENSE AND COPYRIGHT
66  
67 Copyright 2024 Jeff Anderson.
68  
69 This program is free software; you can redistribute it and/or modify it
70 under the terms of the the Artistic License (2.0). You may obtain a
71 copy of the full license at:
72  
73 L<http://www.perlfoundation.org/artistic_license_2_0>
74  
75 Any use, modification, and distribution of the Standard or Modified
76 Versions is governed by this Artistic License. By using, modifying or
77 distributing the Package, you accept this license. Do not use, modify,
78 or distribute the Package, if you do not accept this license.
79  
80 If your Modified Version has been derived from a Modified Version made
81 by someone other than you, you are nevertheless required to ensure that
82 your Modified Version complies with the requirements of this license.
83  
84 This license does not grant you the right to use any trademark, service
85 mark, tradename, or logo of the Copyright Holder.
86  
87 This license includes the non-exclusive, worldwide, free-of-charge
88 patent license to make, have made, use, offer to sell, sell, import and
89 otherwise transfer the Package with respect to any patent claims
90 licensable by the Copyright Holder that are necessarily infringed by the
91 Package. If you institute patent litigation (including a cross-claim or
92 counterclaim) against any party alleging that the Package constitutes
93 direct or contributory patent infringement, then this Artistic License
94 to you shall terminate on the date that such litigation is filed.
95  
96 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
97 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
98 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
99 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
100 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
101 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
102 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
103 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
104  
105 =cut
106  
107 __DATA__
« Normal/Type/Title.pm ↑ Summary Normal/Config/TitleStop.pm »