CAB/Analyzer/Morph/Extra/BDB.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 39 CC 2 SCAR 10.6
CC
2
Cov
0%
typeKeys
6.0
new
2.0
analyzePre
2.0
CRAP 2.9
1 ## -*- Mode: CPerl -*-
2 ##
3 ## File: DTA::CAB::Analyzer::Morph::Extra::DBD.pm
4 ## Author: Bryan Jurish <moocow@cpan.org>
5 ## Description: auxilliary full-form pseudo-morphology, dictionary-based: Berkeley DB
6  
7 ##==============================================================================
8 ## Package: Analyzer::Morph::Extra::OrtLexHessen
9 ##==============================================================================
10 package DTA::CAB::Analyzer::Morph::Extra::BDB;
11 use DTA::CAB::Analyzer ':child';
12 use DTA::CAB::Analyzer::Dict;
13 use DTA::CAB::Analyzer::Dict::BDB;
14 use Carp;
15 use strict;
16 our @ISA = qw(DTA::CAB::Analyzer::Dict::BDB);
17  
18 ## $obj = CLASS_OR_OBJ->new(%args)
19 ## + object structure: see DTA::CAB::Analyzer::Dict::BDB
20 sub new {
21 my $that = shift;
22 my $aut = $that->SUPER::new(
23 ##-- analysis selection
24 label => 'mextra', ##-- local 'morph' key (append)
25 checkLabel => 'mextra.bdb', ##-- local boolean key (avoid re-analysis)
26 morphLabel => 'morph', ##-- global 'morph' key (append)
27 ##
28 analyzeCode => join("\n",
29 'return if (defined($_->{$checkLab})); ##-- avoid re-analysis',
30 '$_->{$checkLab}=1;',
31 '@vals='._am_tt_fst_list('($dhash->{'._am_xlit.'}||"")').';',
32 'if (@vals) {', # && (!$_->{xlit} || $_->{xlit}{isLatinExt})
33 ' push(@{$_->{$morphLab}},@vals); push(@{$_->{$lab}},@vals);',
34 '}',
35 ),
36 ##-- user args
37 @_
38 );
39 return $aut;
40 }
41  
42 ## @keys = $anl->typeKeys(\%opts)
43 ## + returns list of type-wise keys to be expanded for this analyzer by expandTypes()
44 ## + override returns @{$anl->{typeKeys}} if defined, otherwise ($anl->{label},$anl->{morphLabel})
45 sub typeKeys {
46 return $_[0]{typeKeys} ? @{$_[0]{typeKeys}} : grep {defined($_)} @{$_[0]}{qw(label morphLabel)};
47 }
48  
49  
50 ##------------------------------------------------------------------------
51 ## Methods: Analysis: Utils
52  
53 ## $prefix = $dict->analyzePre()
54 sub analyzePre {
55 my $dic = shift;
56 return ($dic->SUPER::analyzePre(@_)
57 .'my ($checkLab,$morphLab) = @$anl{qw(checkLabel morphLabel)};'."\n");
58 }
59  
60 1; ##-- be happy
61  
62 __END__