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