| 1 | ## -*- Mode: CPerl -*- | ||||||||||||||||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 3 | ## File: DiaColloDB::Profile::MultiDiff.pm | ||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Author: Bryan Jurish <moocow@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Description: collocation db, co-frequency profile diffs, by date | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | package DiaColloDB::Profile::MultiDiff; | ||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use DiaColloDB::Profile::Multi; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use DiaColloDB::Profile::Diff; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use DiaColloDB::Utils qw(:html :list); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 15 | ## Globals & Constants | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | our @ISA = qw(DiaColloDB::Profile::Multi); | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 20 | ## Constructors etc. | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | ## $mpd = CLASS_OR_OBJECT->new(%args) | ||||||||||||||||||||||||||||||||||||||||||
| 23 | ## $mpd = CLASS_OR_OBJECT->new($mp1,$mp2,%args) | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ## + %args, object structure: | ||||||||||||||||||||||||||||||||||||||||||
| 25 | ## ( | ||||||||||||||||||||||||||||||||||||||||||
| 26 | ## profiles => \@profiles, ##-- ($profile, ...) : sub-diffs, with {label} key | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ## titles => \@titles, ##-- item group titles (default:undef: unknown) | ||||||||||||||||||||||||||||||||||||||||||
| 28 | ## qinfo => \%qinfo, ##-- query info (optional; keys prefixed with 'a' or 'b'): see DiaColloDB::Profile::Multi | ||||||||||||||||||||||||||||||||||||||||||
| 29 | ## ) | ||||||||||||||||||||||||||||||||||||||||||
| 30 | ## + additional %args: | ||||||||||||||||||||||||||||||||||||||||||
| 31 | ## ( | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ## populate => $bool, ##-- auto-populate() if $mp1 and $mp2 are specified? (default=1) | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ## diff => $diffop, ##-- low-level diff operation (see DiaColloDB::Profile::Diff) | ||||||||||||||||||||||||||||||||||||||||||
| 34 | ## ) | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $that = shift; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | my $mp1 = UNIVERSAL::isa(ref($_[0]),'DiaColloDB::Profile::Multi') ? shift : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $mp2 = UNIVERSAL::isa(ref($_[0]),'DiaColloDB::Profile::Multi') ? shift : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my %opts = @_; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | my $populate = $opts{populate}//1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"populate"} // 1
MC/DC0%0/1
$opts{"populate"} // 1
$opts{"populate"}
Truth table0%0/2
A
A= $opts{"populate"}
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | delete($opts{populate}); | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $mpd = $that->SUPER::new(%opts); | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | return $mpd->populate($mp1,$mp2) if ($populate && $mp1 && $mp2); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$populate and $mp1 and $mp2
$populate and $mp1
MC/DC0%0/3
$populate and $mp1 and $mp2
$populate
$mp1
$mp2
Truth table0%0/4
A and B and C
A= $populateB= $mp1C= $mp2
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | return $mpd; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | ## $mp2 = $mp->clone() | ||||||||||||||||||||||||||||||||||||||||||
| 49 | ## $mp2 = $mp->clone($keep_compiled) | ||||||||||||||||||||||||||||||||||||||||||
| 50 | ## + clones %$mp | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ## + if $keep_score is true, compiled data is cloned too | ||||||||||||||||||||||||||||||||||||||||||
| 52 | ## + INHERITED from DiaColloDB::Profile::Multi | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 55 | ## I/O | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | ##-------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 58 | ## I/O: JSON | ||||||||||||||||||||||||||||||||||||||||||
| 59 | ## + mostly INHERITED from DiaCollocDB::Persistent | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | ## $obj = $CLASS_OR_OBJECT->loadJsonData( $data,%opts) | ||||||||||||||||||||||||||||||||||||||||||
| 62 | ## + guts for loadJsonString(), loadJsonFile() | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub loadJsonData { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loadJsonData: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $that = shift; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $mp = $that->DiaColloDB::Persistent::loadJsonData(@_); | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | foreach (@{$mp->{profiles}//[]}) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$mp->{"profiles"} // []
MC/DC0%0/1
$mp->{"profiles"} // []
$mp->{"profiles"}
Truth table0%0/2
A
A= $mp->{"profiles"}
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | bless($_,'DiaColloDB::Profile::Diff'); | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | bless($_->{prf1}, 'DiaColloDB::Profile') if ($_->{prf1}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | bless($_->{prf2}, 'DiaColloDB::Profile') if ($_->{prf2}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | return $mp; | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | ##-------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 75 | ## I/O: Text | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | ## undef = $CLASS_OR_OBJECT->saveTextHeader($fh, hlabel=>$hlabel, titles=>\@titles) | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub saveTextHeader { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
saveTextHeader: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my ($that,$fh,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | DiaColloDB::Profile::Diff::saveTextHeader($that,$fh,hlabel=>'label',@_); | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | ## $bool = $obj->saveTextFile($filename_or_handle, %opts) | ||||||||||||||||||||||||||||||||||||||||||
| 84 | ## + wraps saveTextFh(); INHERITED from DiaCollocDB::Persistent | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | ## $bool = $mp->saveTextFh($fh,%opts) | ||||||||||||||||||||||||||||||||||||||||||
| 87 | ## + save text representation to a filehandle (guts) | ||||||||||||||||||||||||||||||||||||||||||
| 88 | ## + INHERITED from DiaCollocDB::Profile::Multi | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | ##-------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 91 | ## I/O: HTML | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | ## $bool = $mp->saveHtmlFile($filename_or_handle, %opts) | ||||||||||||||||||||||||||||||||||||||||||
| 94 | ## + %opts: | ||||||||||||||||||||||||||||||||||||||||||
| 95 | ## ( | ||||||||||||||||||||||||||||||||||||||||||
| 96 | ## table => $bool, ##-- include <table>..</table> ? (default=1) | ||||||||||||||||||||||||||||||||||||||||||
| 97 | ## body => $bool, ##-- include <html><body>..</html></body> ? (default=1) | ||||||||||||||||||||||||||||||||||||||||||
| 98 | ## verbose => $bool, ##-- include verbose output? (default=0) | ||||||||||||||||||||||||||||||||||||||||||
| 99 | ## qinfo => $varname, ##-- include <script> for qinfo data? (default='qinfo') | ||||||||||||||||||||||||||||||||||||||||||
| 100 | ## header => $bool, ##-- include header-row? (default=1) | ||||||||||||||||||||||||||||||||||||||||||
| 101 | ## format => $fmt, ##-- printf score formatting (default="%.4f") | ||||||||||||||||||||||||||||||||||||||||||
| 102 | ## ) | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub saveHtmlFile { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
saveHtmlFile: not called CC=21 SCAR=61.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my ($mp,$file,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | my $fh = ref($file) ? $file : IO::File->new(">$file"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | $mp->logconfess("saveHtmlFile(): failed to open '$file': $!") if (!ref($fh)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | $fh->print("<html><body>\n") if ($opts{body}//1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$opts{"body"} // 1
MC/DC0%0/1
$opts{"body"} // 1
$opts{"body"}
Truth table0%0/2
A
A= $opts{"body"}
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | $fh->print("<script type=\"text/javascript\">$opts{qinfo}=", DiaColloDB::Utils::saveJsonString($mp->{qinfo}, pretty=>0), ";</script>\n") | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ($mp->{qinfo} && ($opts{qinfo} //= 'qinfo')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$mp->{"qinfo"} and $opts{"qinfo"} //= "qinfo"
$opts{"qinfo"} //= "qinfo"
MC/DC0%0/2
$mp->{"qinfo"} and $opts{"qinfo"} //= "qinfo"
$mp->{"qinfo"}
$opts{"qinfo"}
Truth table0%0/3
A and B
A= $mp->{"qinfo"}B= $opts{"qinfo"}
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $fh->print("<table><tbody>\n") if ($opts{table}//1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$opts{"table"} // 1
MC/DC0%0/1
$opts{"table"} // 1
$opts{"table"}
Truth table0%0/2
A
A= $opts{"table"}
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | $fh->print("<tr>",( | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | map {"<th>".htmlesc($_)."</th>"} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ($opts{verbose} ? (map {("${_}a","${_}b")} qw(N f1 f2 f12)) : qw()), | |||||||||||||||||||||||||||||||||||||||||
| 114 | qw(ascore bscore diff label), | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | @{$mp->{titles}//[qw(item2)]}, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$mp->{"titles"} // ["item2"]
MC/DC0%0/1
$mp->{"titles"} // ["item2"]
$mp->{"titles"}
Truth table0%0/2
A
A= $mp->{"titles"}
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 117 | "</tr>\n" | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | ) if ($opts{header}//1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$opts{"header"} // 1
MC/DC0%0/1
$opts{"header"} // 1
$opts{"header"}
Truth table0%0/2
A
A= $opts{"header"}
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $ps = $mp->{profiles}; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | foreach (@$ps) { | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | $_->saveHtmlFile($file, %opts,table=>0,body=>0,header=>0) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | or $mp->logconfess("saveHtmlFile() saved for sub-profile with label '", $_->label, "': $!"); | ||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | $fh->print("</tbody><table>\n") if ($opts{table}//1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$opts{"table"} // 1
MC/DC0%0/1
$opts{"table"} // 1
$opts{"table"}
Truth table0%0/2
A
A= $opts{"table"}
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | $fh->print("</body></html>\n") if ($opts{body}//1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$opts{"body"} // 1
MC/DC0%0/1
$opts{"body"} // 1
$opts{"body"}
Truth table0%0/2
A
A= $opts{"body"}
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $fh->close() if (!ref($file)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return $mp; | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 131 | ## Compilation | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | ## @ppairs = $CLASS_OR_OBJECT->align($mp1,$mp2) | ||||||||||||||||||||||||||||||||||||||||||
| 134 | ## \@ppairs = $CLASS_OR_OBJECT->align($mp1,$mp2) | ||||||||||||||||||||||||||||||||||||||||||
| 135 | ## + aligns subprofile-pairs from $mp1 and $mp2 | ||||||||||||||||||||||||||||||||||||||||||
| 136 | ## + INHERITED from DiaColloDB::Profile::Multi | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | ## $mpd = $mpd->populate($mp1,$mp2,%opts) | ||||||||||||||||||||||||||||||||||||||||||
| 139 | ## + populates multi-diff by subtracting $mp2 sub-profile scores from $mp1 | ||||||||||||||||||||||||||||||||||||||||||
| 140 | ## + uses $mpd->align() to align sub-profiles | ||||||||||||||||||||||||||||||||||||||||||
| 141 | ## + %opts: clobbers %$mpd | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub populate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
populate: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my ($mpd,$mpa,$mpb,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | @$mpd{keys %opts} = values %opts; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | @{$mpd->{profiles}} = map { | |||||||||||||||||||||||||||||||||||||||||
| 146 | DiaColloDB::Profile::Diff->new($_->[0],$_->[1], diff=>$mpd->{diff}) | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | } @{$mpd->align($mpa,$mpb)}; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if ($mpa->{qinfo} || $mpb->{qinfo}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mpa->{"qinfo"} or $mpb->{"qinfo"}
MC/DC0%0/2
$mpa->{"qinfo"} or $mpb->{"qinfo"}
$mpa->{"qinfo"}
$mpb->{"qinfo"}
Truth table0%0/3
A or B
A= $mpa->{"qinfo"}B= $mpb->{"qinfo"}
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | $mpd->{qinfo} = { | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | (map {("a$_"=>$mpa->{qinfo}{$_})} keys %{$mpa->{qinfo}//{}}), | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$mpa->{"qinfo"} // {}
MC/DC0%0/1
$mpa->{"qinfo"} // {}
$mpa->{"qinfo"}
Truth table0%0/2
A
A= $mpa->{"qinfo"}
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | (map {("b$_"=>$mpb->{qinfo}{$_})} keys %{$mpb->{qinfo}//{}}), | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$mpb->{"qinfo"} // {}
MC/DC0%0/1
$mpb->{"qinfo"} // {}
$mpb->{"qinfo"}
Truth table0%0/2
A
A= $mpb->{"qinfo"}
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return $mpd; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | ## $mp_or_undef = $mp->compile($func,%opts) | ||||||||||||||||||||||||||||||||||||||||||
| 158 | ## + compile all sub-profiles for score-function $func; default='f' | ||||||||||||||||||||||||||||||||||||||||||
| 159 | ## + INHERITED from DiaColloDB::Profile::Multi | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | ## $mp = $mp->uncompile() | ||||||||||||||||||||||||||||||||||||||||||
| 162 | ## + un-compiles all scores for $mp | ||||||||||||||||||||||||||||||||||||||||||
| 163 | ## + INHERITED from DiaColloDB::Profile::Multi | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | ## $class = $CLASS_OR_OBJECT->pclass() | ||||||||||||||||||||||||||||||||||||||||||
| 166 | ## + class for psum() | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub pclass { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pclass: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | return 'DiaColloDB::Profile::Diff'; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | ## $prf = $mp->psum() | ||||||||||||||||||||||||||||||||||||||||||
| 172 | ## $prf = $CLASS_OR_OBJECT->psum(\@profiles) | ||||||||||||||||||||||||||||||||||||||||||
| 173 | ## + sum of sub-profiles, compiled as for $profiles[0] | ||||||||||||||||||||||||||||||||||||||||||
| 174 | ## + used for global trimming | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | ## $mp_or_undef = $mp->trim(%opts) | ||||||||||||||||||||||||||||||||||||||||||
| 177 | ## + calls $prf->trim(%opts) for each sub-profile $prf | ||||||||||||||||||||||||||||||||||||||||||
| 178 | ## + INHERITED from DiaColloDB::Profile::Multi | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | ## $mp_or_undef = $CLASS_OR_OBJECT->trimPairs(\@pairs, %opts) | ||||||||||||||||||||||||||||||||||||||||||
| 181 | ## + %opts: as for DiaColloDB::Profile::Multi::trim(), including 'global' and 'diff' options | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | sub trimPairs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trimPairs: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my ($that,$ppairs,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | ##-- defaults | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | $opts{kbest} //= -1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"kbest"} //= -1
MC/DC0%0/1
$opts{"kbest"} //= -1
$opts{"kbest"}
Truth table0%0/2
A
A= $opts{"kbest"}
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $opts{cutoff} //= ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"cutoff"} //= ""
MC/DC0%0/1
$opts{"cutoff"} //= ""
$opts{"cutoff"}
Truth table0%0/2
A
A= $opts{"cutoff"}
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | $opts{global} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"global"} //= 0
MC/DC0%0/1
$opts{"global"} //= 0
$opts{"global"}
Truth table0%0/2
A
A= $opts{"global"}
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | $opts{diff} //= 'adiff'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{"diff"} //= "adiff"
MC/DC0%0/1
$opts{"diff"} //= "adiff"
$opts{"diff"}
Truth table0%0/2
A
A= $opts{"diff"}
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if ($opts{global}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | ##-- (pre-)trim globally | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $gpa = DiaColloDB::Profile::Multi->sumover(luniq([map {$_->[0]} @$ppairs]), eps=>$opts{eps}); | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $gpb = DiaColloDB::Profile::Multi->sumover(luniq([map {$_->[1]} @$ppairs]), eps=>$opts{eps}); | |||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | DiaColloDB::Profile::Diff->pretrim($gpa,$gpb,%opts); | |||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $gdiff = DiaColloDB::Profile::Diff->new($gpa,$gpb, diff=>$opts{diff}); | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my %keep = map {($_=>undef)} @{$gdiff->which( DiaColloDB::Profile::Diff->diffkbest($opts{diff})=>$opts{kbest} )}; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $_->trim(keep=>\%keep) foreach (grep {$_} map {@$_} @$ppairs); | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | ##-- (pre-)trim locally | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | foreach (@$ppairs) { | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | DiaColloDB::Profile::Diff->pretrim(@$_[0,1],%opts); | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | return $ppairs; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | ## $mp = $mp->stringify( $obj) | ||||||||||||||||||||||||||||||||||||||||||
| 212 | ## $mp = $mp->stringify(\@key2str) | ||||||||||||||||||||||||||||||||||||||||||
| 213 | ## $mp = $mp->stringify(\&key2str) | ||||||||||||||||||||||||||||||||||||||||||
| 214 | ## $mp = $mp->stringify(\%key2str) | ||||||||||||||||||||||||||||||||||||||||||
| 215 | ## + stringifies multi-profile (destructive) via $obj->i2s($key2), $key2str->($i2) or $key2str->{$i2} | ||||||||||||||||||||||||||||||||||||||||||
| 216 | ## + INHERITED from DiaColloDB::Profile::Multi | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 219 | ## Binary operations | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | ## $mp = $mp->_add($mp2,%opts) | ||||||||||||||||||||||||||||||||||||||||||
| 222 | ## + adds $mp2 frequency data to $mp (destructive) | ||||||||||||||||||||||||||||||||||||||||||
| 223 | ## + implicitly un-compiles sub-profiles | ||||||||||||||||||||||||||||||||||||||||||
| 224 | ## + %opts: passed to Profile::_add() | ||||||||||||||||||||||||||||||||||||||||||
| 225 | ## + INHERITED but probably useless | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | ## $mp3 = $mp1->add($mp2,%opts) | ||||||||||||||||||||||||||||||||||||||||||
| 228 | ## + returns sum of $mp1 and $mp2 frequency data (destructive) | ||||||||||||||||||||||||||||||||||||||||||
| 229 | ## + %opts: passed to Profile::_add() | ||||||||||||||||||||||||||||||||||||||||||
| 230 | ## + INHERITED but probably useless | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | ## $diff = $mp1->diff($mp2) | ||||||||||||||||||||||||||||||||||||||||||
| 233 | ## + returns score-diff of $mp1 and $mp2 frequency data (destructive) | ||||||||||||||||||||||||||||||||||||||||||
| 234 | ## + INHERITED but probably useless | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 237 | ## Package DiaColloDB::Profile::Multi::Diff : alias | ||||||||||||||||||||||||||||||||||||||||||
| 238 | package DiaColloDB::Profile::Multi::Diff; | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | our @ISA = qw(DiaColloDB::Profile::MultiDiff); | |||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 242 | ## Package DiaColloDB::Profile::Diff::Multi : alias | ||||||||||||||||||||||||||||||||||||||||||
| 243 | package DiaColloDB::Profile::Diff::Multi; | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | our @ISA = qw(DiaColloDB::Profile::MultiDiff); | |||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 248 | ## Footer | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | __END__ | ||||||||||||||||||||||||||||||||||||||||||