File Coverage

blib/lib/String/Normal/Config/BusinessStop.pm
Criterion Covered Total %
statement 25 25 100.0
branch 7 8 87.5
condition 2 2 100.0
subroutine 4 4 100.0
pod n/a
total 38 39 97.4


line stmt bran cond sub pod time code
1             package String::Normal::Config::BusinessStop;
2 9     9   30 use strict;
  9         12  
  9         185  
3 9     9   23 use warnings;
  9         10  
  9         174  
4              
5 9     9   35 use String::Normal::Config;
  9         10  
  9         1719  
6              
7             sub _data {
8 3     3   8 my %params = @_;
9              
10 3         3 my $fh;
11 3 100       13 if ($params{business_stop}) {
12 1 50       24 open $fh, $params{business_stop} or die "Can't read '$params{business_stop}' $!\n";
13             } else {
14 2         7 $fh = *DATA;
15             }
16              
17 3         5 my %stop;
18 3         11 for (String::Normal::Config::_slurp( $fh )) {
19 92         124 my ($word,$count) = split ',', $_;
20 92   100     183 $count ||= 1;
21              
22 92 100       162 if (substr( $word, 0, 1 ) eq '^') {
    100          
23 4         3 substr( $word, 0, 1 ) = '';
24 4         10 $stop{first}->{$word} = $count;
25             } elsif (substr( $word, -1, 1 ) eq '$') {
26 22         17 substr( $word, -1, 1 ) = '';
27 22         40 $stop{last}->{$word} = $count;
28             } else {
29 66         98 $stop{middle}->{$word} = $count;
30             }
31             }
32              
33 3         17 return \%stop;
34             }
35              
36             1;
37              
38             =head1 NAME
39              
40             String::Normal::Config::BusinessStop;
41              
42             =head1 DESCRIPTION
43              
44             This package defines removals to be performed on the business types.
45              
46             =head1 STRUCTURE
47              
48             One entry per line. Each value will be removed. Special characters
49             C<^> and C<$> are used to anchor the first and last tokens respectively:
50              
51             ^mr
52             lane$
53              
54             Only those occurances of C at the beginning of the token list will be
55             removed, and only those occurances of at the end of the token list
56             will be removed.
57              
58             You can prepend C<#> to lines that you wish to skip. For example:
59              
60             the
61             #and
62              
63             Would remove all occurances of C but not C. Special character
64             C<,> is used to override removal if the final number of tokens if less
65             then the digit specified. For example:
66              
67             the,2
68              
69             Would remove all occurances of C in "The Generic Title" but would
70             not remove any occurances in "The The".
71              
72             You can provide your own data by creating a text file containing your
73             values and provide the path to that file via the constructor:
74              
75             my $normalizer = String::Normal->new( business_stop => '/path/to/values.txt' );
76              
77             =head1 AUTHOR
78              
79             Jeff Anderson, C<< >>
80              
81             =head1 LICENSE AND COPYRIGHT
82              
83             Copyright 2016 Jeff Anderson.
84              
85             This program is free software; you can redistribute it and/or modify it
86             under the terms of the the Artistic License (2.0). You may obtain a
87             copy of the full license at:
88              
89             L
90              
91             Any use, modification, and distribution of the Standard or Modified
92             Versions is governed by this Artistic License. By using, modifying or
93             distributing the Package, you accept this license. Do not use, modify,
94             or distribute the Package, if you do not accept this license.
95              
96             If your Modified Version has been derived from a Modified Version made
97             by someone other than you, you are nevertheless required to ensure that
98             your Modified Version complies with the requirements of this license.
99              
100             This license does not grant you the right to use any trademark, service
101             mark, tradename, or logo of the Copyright Holder.
102              
103             This license includes the non-exclusive, worldwide, free-of-charge
104             patent license to make, have made, use, offer to sell, sell, import and
105             otherwise transfer the Package with respect to any patent claims
106             licensable by the Copyright Holder that are necessarily infringed by the
107             Package. If you institute patent litigation (including a cross-claim or
108             counterclaim) against any party alleging that the Package constitutes
109             direct or contributory patent infringement, then this Artistic License
110             to you shall terminate on the date that such litigation is filed.
111              
112             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
113             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
114             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
115             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
116             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
117             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
118             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
119             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
120              
121             =cut
122              
123             __DATA__