Normal/Config/TitleStop.pm

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