| 1 | ## -*- Mode: CPerl -*- | ||
| 2 | ## | ||
| 3 | ## File: DTA::CAB::Analyzer::EqRW::CDB.pm | ||
| 4 | ## Author: Bryan Jurish <moocow@cpan.org> | ||
| 5 | ## Description: DB dictionary-based equivalence-class expander, rewrite variant | ||
| 6 | |||
| 7 | package DTA::CAB::Analyzer::EqRW::CDB; | ||
| 8 | use DTA::CAB::Analyzer ':child'; | ||
| 9 | use DTA::CAB::Analyzer::Dict; | ||
| 10 | use DTA::CAB::Analyzer::Dict::CDB; | ||
| 11 | use strict; | ||
| 12 | #no strict ('subs'); | ||
| 13 | |||
| 14 | ##============================================================================== | ||
| 15 | ## Globals | ||
| 16 | ##============================================================================== | ||
| 17 | |||
| 18 | our @ISA = qw(DTA::CAB::Analyzer::Dict::CDB); | ||
| 19 | |||
| 20 | ##============================================================================== | ||
| 21 | ## Constructors etc. | ||
| 22 | ##============================================================================== | ||
| 23 | |||
| 24 | ## $obj = CLASS_OR_OBJ->new(%args) | ||
| 25 | ## + object structure: see DTA::CAB::Analyzer::Dict::CDB | ||
| 26 | sub new { | ||
| 27 | my $that = shift; | ||
| 28 | return $that->SUPER::new( | ||
| 29 | ##-- options | ||
| 30 | label => 'eqrw', | ||
| 31 | eqIdWeight => 0, | ||
| 32 | allowRegex => '(?:^[[:alpha:]\-\x{ac}]*[[:alpha:]]+$)|(?:^[[:alpha:]]+[[:alpha:]\-\x{ac}]+$)', | ||
| 33 | ## | ||
| 34 | analyzeCode => join("\n", | ||
| 35 | 'return if (defined($_->{$lab})); ##-- avoid re-analysis', | ||
| 36 | '$val=undef; ##-- re-initialize temporary used by _am_fst_uniq', | ||
| 37 | '$_->{$lab}=['._am_fst_usort( | ||
| 38 | _am_id_fst('$_', '$dic->{eqIdWeight}') | ||
| 39 | .', map {defined($_) ? '._am_tt_fst_list('$_').' : qw()}' | ||
| 40 | .' @$dhash{'._am_xtext.','._am_xlit.','._am_rw.'}' | ||
| 41 | ).'];', | ||
| 42 | ), | ||
| 43 | |||
| 44 | |||
| 45 | ##-- user args | ||
| 46 | @_ | ||
| 47 | ); | ||
| 48 | } | ||
| 49 | |||
| 50 | |||
| 51 | 1; ##-- be happy | ||
| 52 | |||
| 53 | __END__ |