CAB/Analyzer/EqPho/JsonCDB.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 23 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
analyzePre
2.0
BEGIN
2.0
CRAP 2.0
1 ## -*- Mode: CPerl -*-
2 ##
3 ## File: DTA::CAB::Analyzer::EqPho::JsonCDB.pm
4 ## Author: Bryan Jurish <moocow@cpan.org>
5 ## Description: dictionary-based equivalence-class expander, phonetic variant
6  
7 package DTA::CAB::Analyzer::EqPho::JsonCDB;
8 use DTA::CAB::Analyzer ':child';
9 use DTA::CAB::Analyzer::Dict::JsonCDB;
10 use strict;
11  
12 ##==============================================================================
13 ## Globals
14 ##==============================================================================
15  
16 our @ISA = qw(DTA::CAB::Analyzer::Dict::JsonCDB);
17  
18 ##==============================================================================
19 ## Constructors etc.
20 ##==============================================================================
21  
22 ## $obj = CLASS_OR_OBJ->new(%args)
23 ## + object structure: see DTA::CAB::Analyzer::Dict::JsonCDB
24 sub new {
25 my $that = shift;
26 return $that->SUPER::new(
27 ##-- options
28 label => 'eqpho',
29 eqIdWeight => 0,
30 #allowRegex => '(?:^[[:alpha:]\-\x{ac}]*[[:alpha:]]+$)|(?:^[[:alpha:]]+[[:alpha:]\-\x{ac}]+$)',
31 allowRegex => '(?:[[:alpha:]])',
32 ##
33 analyzeCode => join("\n",
34 'return if (defined($_->{$lab})); ##-- avoid re-analysis',
35 'if (!defined($val=$tied->FETCH('._am_lts.'))) {',
36 ' $_->{$lab} = ['._am_id_fst('$_','$dic->{eqIdWeight}').'];',
37 ' return;',
38 '}',
39 '$tmp = undef; ##-- avoid bleed-over from _am_fst_uniq',
40 '$val = $jxs->decode($val);',
41 '@$val = '._am_fst_usort((_am_id_fst('$_','$dic->{eqIdWeight}').',@$val'),'$tmp').';',
42 '$_->{$lab} = $val;',
43 ),
44  
45 ##-- user args
46 @_
47 );
48 }
49  
50 ## $prefix = $dict->analyzePre()
51 sub analyzePre {
52 my $dic = shift;
53 return $dic->SUPER::analyzePre(@_)."\n".'my $tied=tied(%$dhash);'."\n".'my ($tmp);';
54 }
55  
56 1; ##-- be happy
57  
58 __END__