| 1 | package String::Normal::Config::BusinessStop; | ||||||||||||||
| 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 | 3 | ▶ | sub _data { | ||||||||||||
|
Subroutine
_data: called CC=7 SCAR=19.5
| |||||||||||||||
| 8 | 3 | my %params = @_; | |||||||||||||
| 9 | |||||||||||||||
| 10 | 3 | my $fh; | |||||||||||||
| 11 | 3 | ▶ | if ($params{business_stop}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 12 | 1 | ▶ | open $fh, $params{business_stop} or die "Can't read '$params{business_stop}' $!\n"; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 13 | } else { | ||||||||||||||
| 14 | 2 | $fh = *DATA; | |||||||||||||
| 15 | } | ||||||||||||||
| 16 | |||||||||||||||
| 17 | 3 | my %stop; | |||||||||||||
| 18 | 3 | for (String::Normal::Config::_slurp( $fh )) { | |||||||||||||
| 19 | 92 | my ($word,$count) = split ',', $_; | |||||||||||||
| 20 | 92 | ▶ | $count ||= 1; | ||||||||||||
|
Condition100%2/2
$count ||= 1
MC/DC100%1/1
$count ||= 1
$count
Truth table100%2/2
A
A= $count
| |||||||||||||||
| 21 | |||||||||||||||
| 22 | 92 | ▶ | if (substr( $word, 0, 1 ) eq '^') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 23 | 4 | substr( $word, 0, 1 ) = ''; | |||||||||||||
| 24 | 4 | $stop{first}->{$word} = $count; | |||||||||||||
| 25 | } elsif (substr( $word, -1, 1 ) eq '$') { | ||||||||||||||
| 26 | 22 | substr( $word, -1, 1 ) = ''; | |||||||||||||
| 27 | 22 | $stop{last}->{$word} = $count; | |||||||||||||
| 28 | } else { | ||||||||||||||
| 29 | 66 | $stop{middle}->{$word} = $count; | |||||||||||||
| 30 | } | ||||||||||||||
| 31 | } | ||||||||||||||
| 32 | |||||||||||||||
| 33 | 3 | return \%stop; | |||||||||||||
| 34 | } | ||||||||||||||
| 35 | |||||||||||||||
| 36 | 9 | 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 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<mr> at the beginning of the token list will be | ||||||||||||||
| 55 | removed, and only those occurances of <lane> 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<the> but not C<and>. 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<the> 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<< <jeffa at cpan.org> >> | ||||||||||||||
| 80 | |||||||||||||||
| 81 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||
| 82 | |||||||||||||||
| 83 | Copyright 2024 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<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||
| 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__ | ||||||||||||||