| 1 | package String::Normal::Config::BusinessCompress; | ||||||||||
| 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=4 SCAR=13.9
| |||||||||||
| 8 | 3 | my %params = @_; | |||||||||
| 9 | |||||||||||
| 10 | 3 | my $fh; | |||||||||
| 11 | 3 | ▶ | if ($params{business_compress}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 1 | ▶ | open $fh, $params{business_compress} or die "Can't read '$params{business_compress}' $!\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | } else { | ||||||||||
| 14 | 2 | $fh = *DATA; | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | 3 | my %compress; | |||||||||
| 18 | 3 | for (String::Normal::Config::_expand_ranges( String::Normal::Config::_slurp( $fh ) )) { | |||||||||
| 19 | 1101 | String::Normal::Config::_attach( \%compress, split '-', $_ ); | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 3 | return \%compress; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 9 | 1; | |||||||||
| 26 | |||||||||||
| 27 | =head1 NAME | ||||||||||
| 28 | |||||||||||
| 29 | String::Normal::Config::BusinessCompress; | ||||||||||
| 30 | |||||||||||
| 31 | =head1 DESCRIPTION | ||||||||||
| 32 | |||||||||||
| 33 | This package defines compressions to be performed on Business types. | ||||||||||
| 34 | |||||||||||
| 35 | =head1 STRUCTURE | ||||||||||
| 36 | |||||||||||
| 37 | One entry per line, each entry contains the multi word term joined by dashes (C<->): | ||||||||||
| 38 | |||||||||||
| 39 | foo-bar-baz | ||||||||||
| 40 | |||||||||||
| 41 | Would compress C<foo> C<bar> and C<baz> so long as they are found in that order | ||||||||||
| 42 | in the token list. Consider the many different varations of the word "barbecue" and | ||||||||||
| 43 | you might see where this kind of transformation is valuable in detecting potential | ||||||||||
| 44 | duplicates. | ||||||||||
| 45 | |||||||||||
| 46 | You can provide your own data by creating a text file containing your | ||||||||||
| 47 | values and provide the path to that file via the constructor: | ||||||||||
| 48 | |||||||||||
| 49 | my $normalizer = String::Normal->new( business_compress => '/path/to/values.txt' ); | ||||||||||
| 50 | |||||||||||
| 51 | =head1 AUTHOR | ||||||||||
| 52 | |||||||||||
| 53 | Jeff Anderson, C<< <jeffa at cpan.org> >> | ||||||||||
| 54 | |||||||||||
| 55 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 56 | |||||||||||
| 57 | Copyright 2024 Jeff Anderson. | ||||||||||
| 58 | |||||||||||
| 59 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 60 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||
| 61 | copy of the full license at: | ||||||||||
| 62 | |||||||||||
| 63 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||
| 64 | |||||||||||
| 65 | Any use, modification, and distribution of the Standard or Modified | ||||||||||
| 66 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||
| 67 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||
| 68 | or distribute the Package, if you do not accept this license. | ||||||||||
| 69 | |||||||||||
| 70 | If your Modified Version has been derived from a Modified Version made | ||||||||||
| 71 | by someone other than you, you are nevertheless required to ensure that | ||||||||||
| 72 | your Modified Version complies with the requirements of this license. | ||||||||||
| 73 | |||||||||||
| 74 | This license does not grant you the right to use any trademark, service | ||||||||||
| 75 | mark, tradename, or logo of the Copyright Holder. | ||||||||||
| 76 | |||||||||||
| 77 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||
| 78 | patent license to make, have made, use, offer to sell, sell, import and | ||||||||||
| 79 | otherwise transfer the Package with respect to any patent claims | ||||||||||
| 80 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||
| 81 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||
| 82 | counterclaim) against any party alleging that the Package constitutes | ||||||||||
| 83 | direct or contributory patent infringement, then this Artistic License | ||||||||||
| 84 | to you shall terminate on the date that such litigation is filed. | ||||||||||
| 85 | |||||||||||
| 86 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||
| 87 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||
| 88 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||
| 89 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||
| 90 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||
| 91 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||
| 92 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||
| 93 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||
| 94 | |||||||||||
| 95 | =cut | ||||||||||
| 96 | |||||||||||
| 97 | __DATA__ | ||||||||||