| 1 | ## -*- Mode: CPerl -*- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## File: DiaColloDB::Profile::Diff.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Author: Bryan Jurish <moocow@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Description: collocation db, profile diffs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | package DiaColloDB::Profile::Diff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use DiaColloDB::Utils qw(:math :html); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use DiaColloDB::Profile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ## Globals & Constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | our @ISA = qw(DiaColloDB::Profile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ## Constructors etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ## $dprf = CLASS_OR_OBJECT->new(%args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ## $dprf = CLASS_OR_OBJECT->new($prf1,$prf2,%args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ## + %args, object structure: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ## ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ## ##-- DiaColloDB::Profile::Diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ## prf1 => $prf1, ##-- 1st operand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ## prf2 => $prf2, ##-- 2nd operand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ## diff => $diff, ##-- low-level score-diff binary operation (default='abs-diff'); known values: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ## ## abs-diff # $score=$a-$b ; aliases=qw(absolute-difference abs-difference abs-diff adiff adifference a-) ; select=kbesta ; default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ## ## diff # $score=$a-$b ; aliases=qw(difference diff d minus -) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ## ## sum # $score=$a+$b ; aliases=qw(sum add plus +) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ## ## min # $score=min($a,$b) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ## ## max # $score=max($a,$b) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ## ## avg # $score=avg($a,$b) ; aliases=qw(average avg mean) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ## ## havg # $score=harmonic_avg($a,$b) ; aliases=qw(harmonic-average harmonic-mean havg hmean ha h) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ## ## gavg # $score=geometric_avg($a,$b) ; aliases=qw(geometric-average geometric-mean gavg gmean ga g) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ## ## lavg # $score=log_avg($a,$b) ; aliases=qw(logarithmic-average logarithmic-mean log-average log-mean lavg lmean la l) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ## ##-- DiaColloDB::Profile keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ## label => $label, ##-- string label (used by Multi; undef for none(default)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ## #N => $N, ##-- OVERRIDE:unused: total marginal relation frequency | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ## #f1 => $f1, ##-- OVERRIDE:unused: total marginal frequency of target word(s) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ## #f2 => \%f2, ##-- OVERRIDE:unused: total marginal frequency of collocates: ($i2=>$f2, ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ## #f12 => \%f12, ##-- OVERRIDE:unused: collocation frequencies, %f12 = ($i2=>$f12, ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ## # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ## eps => $eps, ##-- smoothing constant (default=undef: no smoothing) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ## score => $func, ##-- selected scoring function ('f12', 'mi', or 'ld') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ## mi => \%mi12, ##-- DIFFERENCE: score: mutual information * logFreq a la Wortprofil; requires compile_mi() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ## ld => \%ld12, ##-- DIFFERENCE: score: log-dice a la Wortprofil; requires compile_ld() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ## fm => \%fm12, ##-- DIFFERENCE: score: frequency per million; requires compile_fm() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ## ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $that = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $prf1 = !defined($_[0]) || UNIVERSAL::isa(ref($_[0]),'DiaColloDB::Profile') ? shift : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $_[0] or UNIVERSAL::isa(ref $_[0], "DiaColloDB::Profile")
MC/DC0%0/2
not defined $_[0] or UNIVERSAL::isa(ref $_[0], "DiaColloDB::Profile")
not defined $_[0]
UNIVERSAL::isa(ref $_[0], "DiaColloDB::Profile")
Truth table0%0/3
not(A) or B
A= not defined $_[0]B= UNIVERSAL::isa(ref $_[0], "DiaColloDB::Profile")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my $prf2 = !defined($_[0]) || UNIVERSAL::isa(ref($_[0]),'DiaColloDB::Profile') ? shift : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $_[0] or UNIVERSAL::isa(ref $_[0], "DiaColloDB::Profile")
MC/DC0%0/2
not defined $_[0] or UNIVERSAL::isa(ref $_[0], "DiaColloDB::Profile")
not defined $_[0]
UNIVERSAL::isa(ref $_[0], "DiaColloDB::Profile")
Truth table0%0/3
not(A) or B
A= not defined $_[0]B= UNIVERSAL::isa(ref $_[0], "DiaColloDB::Profile")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my %opts = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $dprf = $that->SUPER::new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | prf1=>$prf1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | prf2=>$prf2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | diff=>'adiff', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | %opts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | delete @$dprf{grep {!defined($opts{$_})} qw(N f1 f2 f12)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | return $dprf->populate() if ($dprf->{prf1} && $dprf->{prf2}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dprf->{"prf1"} and $dprf->{"prf2"}
MC/DC0%0/2
$dprf->{"prf1"} and $dprf->{"prf2"}
$dprf->{"prf1"}
$dprf->{"prf2"}
Truth table0%0/3
A and B
A= $dprf->{"prf1"}B= $dprf->{"prf2"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | return $dprf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ## $dprf2 = $dprf->clone() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ## $dprf2 = $dprf->clone($keep_compiled) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ## + clones %$dprf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ## + if $keep_score is true, compiled data is cloned too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my ($dprf,$force) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | return bless({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | label=>$dprf->{label}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | diff=>$dprf->{diff}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | (defined($dprf->{prf1}) ? $dprf->{prf1}->clone($force) : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | (defined($dprf->{prf2}) ? $dprf->{prf2}->clone($force) : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | }, ref($dprf)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ## Basic Access | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ## ($prf1,$prf2) = $dprf->operands(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub operands { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
operands: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return @{$_[0]}{qw(prf1 prf2)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ## $bool = $dprf->empty() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ## + returns true iff both operands are empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub empty { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
empty: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $dp = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | return (!$dp->{prf1} || $dp->{prf1}->empty) && (!$dp->{prf2} || $dp->{prf2}->empty); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
(!$dp->{'prf1'} || $dp->{'prf1'}->empty) && (!$dp->{'prf2'} || $dp->{'prf2'}->empty)
not $dp->{"prf1"} or $dp->{"prf1"}->empty
not $dp->{"prf2"} or $dp->{"prf2"}->empty
MC/DC0%0/4
(!$dp->{'prf1'} || $dp->{'prf1'}->empty) && (!$dp->{'prf2'} || $dp->{'prf2'}->empty)
not $dp->{"prf1"}
$dp->{"prf1"}->empty
not $dp->{"prf2"}
$dp->{"prf2"}->empty
Truth table0%0/7
not(A) or B && not(C) or D
A= not $dp->{"prf1"}B= $dp->{"prf1"}->emptyC= not $dp->{"prf2"}D= $dp->{"prf2"}->empty
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ## I/O | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ##-------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ## I/O: JSON | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | ## + mostly INHERITED from DiaCollocDB::Persistent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ## $obj = $CLASS_OR_OBJECT->loadJsonData( $data,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ## + guts for loadJsonString(), loadJsonFile() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub loadJsonData { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loadJsonData: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $that = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $dprf = $that->DiaColloDB::Persistent::loadJsonData(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | bless($_,'DiaColloDB::Profile') foreach (grep {defined($_)} @$dprf{qw(prf1 prf2)}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | return $dprf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ##-------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ## I/O: Text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ## undef = $CLASS_OR_OBJECT->saveTextHeader($fh, hlabel=>$hlabel, titles=>\@titles) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | sub saveTextHeader { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
saveTextHeader: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my ($that,$fh,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | my @fields = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | (map {("${_}a","${_}b")} qw(N f1 f2 f12 score)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | qw(diff), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | (defined($opts{hlabel}) ? $opts{hlabel} : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | @{$opts{titles} // (ref($that) ? $that->{titles} : undef) // [qw(item2)]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
($opts{"titles"} // (ref $that ? $that->{"titles"} : undef)) // ["item2"]
$opts{"titles"} // (ref $that ? $that->{"titles"} : undef)
MC/DC0%0/2
($opts{"titles"} // (ref $that ? $that->{"titles"} : undef)) // ["item2"]
$opts{"titles"}
(ref $that ? $that->{"titles"} : undef)
Truth table0%0/3
A // B
A= $opts{"titles"}B= (ref $that ? $that->{"titles"} : undef)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $fh->print(join("\t", map {"#".($_+1).":$fields[$_]"} (0..$#fields)), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ## $bool = $prf->saveTextFh($fh, %opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ## + %opts: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ## ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ## label => $label, ##-- override $prf->{label} (used by Profile::Multi), no tab-separators required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | ## format => $fmt, ##-- printf score formatting (default="%.4f") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ## header => $bool, ##-- include header-row? (default=1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | ## hlabel => $hlabel, ##-- prefix header item-cells with $hlabel (used by Profile::Multi) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ## ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ## + format (flat, TAB-separated): Na Nb F1a F1b F2a F2b F12a F12b SCOREa SCOREb SCOREdiff LABEL ITEM2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub saveTextFh { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
saveTextFh: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my ($dprf,$fh,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | binmode($fh,':utf8'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my ($pa,$pb,$fscore) = @$dprf{qw(prf1 prf2 score)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $fscore //= 'f12'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$fscore //= "f12"
MC/DC0%0/1
$fscore //= "f12"
$fscore
Truth table0%0/2
A
A= $fscore
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my ($Na,$f1a,$f2a,$f12a,$scorea) = @$pa{qw(N f1 f2 f12),$fscore}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my ($Nb,$f1b,$f2b,$f12b,$scoreb) = @$pb{qw(N f1 f2 f12),$fscore}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $scored = $dprf->{$fscore}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my $label = exists($opts{label}) ? $opts{label} : $dprf->{label}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | my $fmt = $opts{fmt} || '%f'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'fmt'} || '%f'
MC/DC0%0/1
$opts{'fmt'} || '%f'
$opts{'fmt'}
Truth table0%0/2
A
A= $opts{'fmt'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | $dprf->saveTextHeader($fh,%opts) 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | foreach (sort {$scored->{$b} <=> $scored->{$a}} keys %$scored) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | $fh->print(join("\t", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | map {$_//0} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
$_ // 0
$scorea->{$_} // "nan"
$scoreb->{$_} // "nan"
$scored->{$_} // "nan"
MC/DC0%0/1
$_ // 0
$_
MC/DC0%0/1
$scorea->{$_} // "nan"
$scorea->{$_}
MC/DC0%0/1
$scoreb->{$_} // "nan"
$scoreb->{$_}
MC/DC0%0/1
$scored->{$_} // "nan"
$scored->{$_}
Truth table0%0/2
A
A= $_
Truth table0%0/2
A
A= $scorea->{$_}
Truth table0%0/2
A
A= $scoreb->{$_}
Truth table0%0/2
A
A= $scored->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | $Na, $Nb, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | $f1a,$f1b, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | $f2a->{$_}, $f2b->{$_}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | $f12a->{$_}, $f2b->{$_}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | sprintf($fmt,$scorea->{$_}//'nan'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | sprintf($fmt,$scoreb->{$_}//'nan'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | sprintf($fmt,$scored->{$_}//'nan'), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | (defined($label) ? $label : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | $_), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | return $dprf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ##-------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ## I/O: HTML | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ## $bool = $prf->saveHtmlFile($filename_or_handle, %opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ## + %opts: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ## ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ## table => $bool, ##-- include <table>..</table> ? (default=1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | ## body => $bool, ##-- include <html><body>..</html></body> ? (default=1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | ## header => $bool, ##-- include header-row? (default=1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ## verbose => $bool, ##-- include verbose output? (default=0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | ## hlabel => $hlabel, ##-- prefix header item-cells with $hlabel (used by Profile::Multi), no '<th>..</th>' required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ## label => $label, ##-- prefix item-cells with $label (used by Profile::Multi), no '<td>..</td>' required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | ## format => $fmt, ##-- printf score formatting (default="%.4f") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | ## ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | ## + saves rows of the format "SCOREa SCOREb DIFF PREFIX? ITEM2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | sub saveHtmlFile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
saveHtmlFile: not called CC=27 SCAR=66.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my ($dprf,$file,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | my $fh = ref($file) ? $file : IO::File->new(">$file"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | $dprf->logconfess("saveHtmlFile(): failed to open '$file': $!") if (!ref($fh)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | binmode($fh,':utf8'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | $fh->print("<tr>",( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | map {"<th>".htmlesc($_)."</th>"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | ($opts{verbose} ? (map {("${_}a","${_}b")} qw(N f1 f2 f12)) : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | qw(ascore bscore diff), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | (defined($opts{hlabel}) ? $opts{hlabel} : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | @{$dprf->{titles}//[qw(item2)]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$dprf->{"titles"} // ["item2"]
MC/DC0%0/1
$dprf->{"titles"} // ["item2"]
$dprf->{"titles"}
Truth table0%0/2
A
A= $dprf->{"titles"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | "</tr>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my ($pa,$pb,$fscore) = @$dprf{qw(prf1 prf2 score)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | $fscore //= 'f12'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$fscore //= "f12"
MC/DC0%0/1
$fscore //= "f12"
$fscore
Truth table0%0/2
A
A= $fscore
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $scorea = $pa->{$fscore}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $scoreb = $pb->{$fscore}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $scored = $dprf->{$fscore}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | my $fmt = $opts{format} || "%.4f"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'format'} || '%.4f'
MC/DC0%0/1
$opts{'format'} || '%.4f'
$opts{'format'}
Truth table0%0/2
A
A= $opts{'format'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | my $label = exists($opts{label}) ? $opts{label} : $dprf->{label}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | foreach (sort {$scored->{$b} <=> $scored->{$a}} keys %$scored) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | $fh->print("<tr>", (map {"<td>".htmlesc($_)."</td>"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | ($opts{verbose} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | ? (map {($_//0)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
$_ // 0
$scorea->{$_} // "nan"
$scoreb->{$_} // "nan"
$scored->{$_} // "nan"
MC/DC0%0/1
$_ // 0
$_
MC/DC0%0/1
$scorea->{$_} // "nan"
$scorea->{$_}
MC/DC0%0/1
$scoreb->{$_} // "nan"
$scoreb->{$_}
MC/DC0%0/1
$scored->{$_} // "nan"
$scored->{$_}
Truth table0%0/2
A
A= $_
Truth table0%0/2
A
A= $scorea->{$_}
Truth table0%0/2
A
A= $scoreb->{$_}
Truth table0%0/2
A
A= $scored->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | $pa->{N}, $pb->{N}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | $pa->{f1}, $pb->{f1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | $pa->{f2}{$_}, $pb->{f2}{$_}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | $pa->{f12}{$_}, $pb->{f12}{$_}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | sprintf($fmt,$scorea->{$_}//'nan'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | sprintf($fmt,$scoreb->{$_}//'nan'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | sprintf($fmt,$scored->{$_}//'nan'), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | (defined($label) ? $label : qw()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | split(/\t/,$_)), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | "</tr>\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | $fh->close() if (!ref($file)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | return $dprf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | ## Compilation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | ##---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | ## Compilation: diff-ops | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | ## %DIFFOPS : ($opAlias => $opName, ...) : canonical diff-operation names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | our %DIFFOPS = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 5 | (map {($_=>'diff')} qw(difference diff d minus -)), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 7 | (map {($_=>'adiff')} qw(absolute-difference abs-difference abs-diff adiff adifference a- DEFAULT)), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 4 | (map {($_=>'sum')} qw(add plus sum +)), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | (map {($_=>'min')} qw(minimum min)), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | (map {($_=>'max')} qw(maximum max)), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 3 | (map {($_=>'avg')} qw(average avg mean)), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 8 | (map {($_=>'havg')} qw(harmonic-average harmonic-avg harmonic harm haverage havg ha h)), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 9 | (map {($_=>'gavg')} qw(geometric-average geometric-mean geometric geom geo gavg gmean ga g)), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | (map {($_=>'lavg')} qw(logarithmic-average logarithmic-mean logarithmic log-average log-mean log lavg lmean la l)), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | ## $opname = $dprf->diffop() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | ## $opname = $CLASS_OR_OBJECT->diffop($opNameOrAlias) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | ## + returns canonical diff operation-name for $opNameOrAlias | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | sub diffop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffop: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my ($that,$op) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | $op //= $that->{diff} if (ref($that)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$op //= $that->{"diff"}
MC/DC0%0/2
$op //= $that->{"diff"}
$op
$that->{"diff"}
Truth table0%0/3
A //= B
A= $opB= $that->{"diff"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | return (defined($op) ? $DIFFOPS{$op} : undef) // $op // $DIFFOPS{DEFAULT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
((defined $op ? $DiaColloDB::Profile::Diff::DIFFOPS{$op} : undef) // $op) // $DiaColloDB::Profile::Diff::DIFFOPS{"DEFAULT"}
(defined $op ? $DiaColloDB::Profile::Diff::DIFFOPS{$op} : undef) // $op
MC/DC0%0/3
((defined $op ? $DiaColloDB::Profile::Diff::DIFFOPS{$op} : undef) // $op) // $DiaColloDB::Profile::Diff::DIFFOPS{"DEFAULT"}
(defined $op ? $DiaColloDB::Profile::Diff::DIFFOPS{$op} : undef)
$op
$DiaColloDB::Profile::Diff::DIFFOPS{"DEFAULT"}
Truth table0%0/4
A // B // C
A= (defined $op ? $DiaColloDB::Profile::Diff::DIFFOPS{$op} : undef)B= $opC= $DiaColloDB::Profile::Diff::DIFFOPS{"DEFAULT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | ## \&FUNC = $dprf->diffsub() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | ## \&FUNC = $CLASS_OR_OBJECT->diffsub($opNameOrAlias) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ## + gets low-level binary diff operation for diff-operation $opNameOrAlias (default=$dprf->{diff}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub diffsub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffsub: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | my ($that,$opname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | return $opname if (UNIVERSAL::isa($opname,'CODE')); ##-- code-ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $op = $that->diffop($opname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $sub = $that->can("diffop_$op"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | return $sub if (defined($sub)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $that->logwarn("unknown low-level diff operation '$op' defaults to '$DIFFOPS{DEFAULT}'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return \&diffop_diff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | ## $how = $dprf->diffpretrim() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | ## $how = $CLASS_OR_OBJECT->diffpretrim($opNameOrAlias) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | ## + returns if and how diff should pre-trim operand profiles: one of: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | ## 0 : don't pre-trim | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | ## 'restrict' : intersect defined collocates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | ## 'kbest' : union of k-best collocates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | sub diffpretrim { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffpretrim: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my ($that,$op) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $op = $that->diffop($op); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if ($op =~ /^min|avg/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | return 'restrict'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | elsif ($op =~ m/^a?diff|max/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | return 'kbest'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | ## $selector = $dprf->diffkbest() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | ## $selector = $CLASS_OR_OBJECT->diffkbest($opNameOrAlias) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | ## + returns 'kbest' selector appropriate for which() or trim() methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub diffkbest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffkbest: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my ($that,$op) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | return $that->diffop($op) eq 'adiff' ? 'kbesta' : 'kbest'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 1 | ▶ | BEGIN { *diffop_adiff = \&diffop_diff; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | sub diffop_diff { return $_[0]-$_[1]; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffop_diff: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | sub diffop_sum { return $_[0]+$_[1]; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffop_sum: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub diffop_min { return $_[0]<$_[1] ? $_[0] : $_[1]; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffop_min: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sub diffop_max { return $_[0]>$_[1] ? $_[0] : $_[1]; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffop_max: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | sub diffop_avg { return ($_[0]+$_[1])/2.0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffop_avg: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | #sub diffop_havg { return $_[0]<=0 || $_[1]<=0 ? 0 : 2.0/(1.0/$_[0] + 1.0/$_[1]); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | ##-- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | #our $havg_eps = 0.1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | #sub diffop_havg { return 2.0/(1.0/($_[0]+$havg_eps) + 1.0/($_[1]+$havg_eps)) - $havg_eps; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | ##-- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | sub diffop_havg0 { return $_[0]<=0 || $_[1]<=0 ? 0 : (2*$_[0]*$_[1])/($_[0]+$_[1]); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffop_havg0: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 1 branch
Condition0%0/3
$_[0] <= 0 or $_[1] <= 0
MC/DC0%0/2
$_[0] <= 0 or $_[1] <= 0
$_[0] <= 0
$_[1] <= 0
Truth table0%0/3
A or B
A= $_[0] <= 0B= $_[1] <= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub diffop_havg { return diffop_avg(diffop_havg0(@_),diffop_avg(@_)); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffop_havg: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub nthRoot { return ($_[0]<0 ? -1 : 1) * abs($_[0])**(1/$_[1]); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nthRoot: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | #sub diffop_gavg { return nthRoot($_[0]*$_[1], 2); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | ##-- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | sub diffop_gavg0 { return nthRoot($_[0]*$_[1], 2); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffop_gavg0: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | sub diffop_gavg { return diffop_avg(diffop_gavg0(@_),diffop_avg(@_)); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffop_gavg: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub diffop_lavg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diffop_lavg: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | my ($x,$y) = $_[0]<$_[1] ? @_[0,1] : @_[1,0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | my $delta = $x<=1 ? (1-$x) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | return exp( log(($x+$delta)*($y+$delta))/2.0 ) - $delta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | ##---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | ## Compilation: guts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | ## $dprf = $dprf->populate() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ## $dprf = $dprf->populate($prf1,$prf2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | ## + populates diff-profile by applying the selected diff-operation on aligned operand scores | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | sub populate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
populate: not called CC=20 SCAR=60.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my ($dprf,$pa,$pb) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | $pa //= $dprf->{prf1}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$pa //= $dprf->{"prf1"}
MC/DC0%0/2
$pa //= $dprf->{"prf1"}
$pa
$dprf->{"prf1"}
Truth table0%0/3
A //= B
A= $paB= $dprf->{"prf1"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | $pb //= $dprf->{prf2}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$pb //= $dprf->{"prf2"}
MC/DC0%0/2
$pb //= $dprf->{"prf2"}
$pb
$dprf->{"prf2"}
Truth table0%0/3
A //= B
A= $pbB= $dprf->{"prf2"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | $pa = $pb->shadow(1) if (!$pa && $pb); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $pa and $pb
MC/DC0%0/2
not $pa and $pb
not $pa
$pb
Truth table0%0/3
not(A) and B
A= not $paB= $pb
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | $pb = $pa->shadow(1) if ( $pa && !$pb); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pa and not $pb
MC/DC0%0/2
$pa and not $pb
$pa
not $pb
Truth table0%0/3
A and not(B)
A= $paB= not $pb
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | @$dprf{qw(prf1 prf2)} = ($pa,$pb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | $dprf->{label} //= $pa->label() ."-" . $pb->label(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$dprf->{"label"} //= $pa->label . '-' . $pb->label
MC/DC0%0/1
$dprf->{"label"} //= $pa->label . '-' . $pb->label
$dprf->{"label"}
Truth table0%0/2
A
A= $dprf->{"label"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | my $scoref = $dprf->{score} = $dprf->{score} // $pa->{score} // $pb->{score} // 'f12'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
(($dprf->{"score"} // $pa->{"score"}) // $pb->{"score"}) // "f12"
($dprf->{"score"} // $pa->{"score"}) // $pb->{"score"}
$dprf->{"score"} // $pa->{"score"}
MC/DC0%0/3
(($dprf->{"score"} // $pa->{"score"}) // $pb->{"score"}) // "f12"
$dprf->{"score"}
$pa->{"score"}
$pb->{"score"}
Truth table0%0/4
A // B // C
A= $dprf->{"score"}B= $pa->{"score"}C= $pb->{"score"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my ($af2,$af12,$ascore) = @$pa{qw(f2 f12),$scoref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my ($bf2,$bf12,$bscore) = @$pb{qw(f2 f12),$scoref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | my $dscore = $dprf->{$scoref} = ($dprf->{$scoref} // {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$dprf->{$scoref} // {}
MC/DC0%0/1
$dprf->{$scoref} // {}
$dprf->{$scoref}
Truth table0%0/2
A
A= $dprf->{$scoref}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my $diffsub = $dprf->diffsub(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | $dprf->logconfess("populate(): no {$scoref} key for \$pa") if (!$ascore); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | $dprf->logconfess("populate(): no {$scoref} key for \$pb") if (!$bscore); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | foreach (keys %$bscore) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | $af2->{$_} //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$af2->{$_} //= 0
MC/DC0%0/1
$af2->{$_} //= 0
$af2->{$_}
Truth table0%0/2
A
A= $af2->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | $af12->{$_} //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$af12->{$_} //= 0
MC/DC0%0/1
$af12->{$_} //= 0
$af12->{$_}
Truth table0%0/2
A
A= $af12->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | $ascore->{$_} //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ascore->{$_} //= 0
MC/DC0%0/1
$ascore->{$_} //= 0
$ascore->{$_}
Truth table0%0/2
A
A= $ascore->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | $dscore->{$_} = $diffsub->(($ascore->{$_}//0), ($bscore->{$_}//0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$ascore->{$_} // 0
$bscore->{$_} // 0
MC/DC0%0/1
$ascore->{$_} // 0
$ascore->{$_}
MC/DC0%0/1
$bscore->{$_} // 0
$bscore->{$_}
Truth table0%0/2
A
A= $ascore->{$_}
Truth table0%0/2
A
A= $bscore->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | return $dprf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | ## $dprf = $dprf->compile($func,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | ## + compile for score-function $func, one of qw(f fm mi ld); default='f' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | sub compile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compile: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my ($dprf,$func) = (shift,shift); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | $dprf->logconfess("compile(): cannot compile without operand profiles") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | if (!$dprf->{prf1} || !$dprf->{prf2}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dprf->{"prf1"} and $dprf->{"prf2"}
MC/DC0%0/2
$dprf->{"prf1"} and $dprf->{"prf2"}
$dprf->{"prf1"}
$dprf->{"prf2"}
Truth table0%0/3
A and B
A= $dprf->{"prf1"}B= $dprf->{"prf2"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | $dprf->{prf1}->compile($func,@_) or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | $dprf->{prf2}->compile($func,@_) or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $dprf->{score} = $dprf->{prf1}{score}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | return $dprf->populate(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | ## $dprf = $dprf->uncompile() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | ## + un-compiles all scores for $dprd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | sub uncompile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uncompile: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my $dprf = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | $dprf->{prf1}->uncompile() if ($dprf->{prf1}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | $dprf->{prf2}->uncompile() if ($dprf->{prf2}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | return $dprf->SUPER::uncompile(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | ## Trimming | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | ## \@keys = $prf->which(%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | ## + returns 'good' keys for trimming options %opts: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | ## ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | ## cutoff => $cutoff, ##-- retain only items with $prf->{$prf->{score}}{$item} >= $cutoff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | ## kbest => $kbest, ##-- retain only $kbest items | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | ## kbesta => $kbesta, ##-- retain only $kbest items (absolute value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | ## return => $which, ##-- either 'good' (default) or 'bad' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | ## as => $as, ##-- 'hash' or 'array'; default='array' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | ## ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | ## + INHERITED from DiaColloDB::Profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | ## $dprf = $dprf->trim(%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | ## + %opts: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | ## ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | ## kbest => $kbest, ##-- retain only $kbest items (by score value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | ## kbesta => $kbesta, ##-- retain only $kbest items (by score absolute value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | ## cutoff => $cutoff, ##-- retain only items with $prf->{$prf->{score}}{$item} >= $cutoff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | ## keep => $keep, ##-- retain keys @$keep (ARRAY) or keys(%$keep) (HASH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | ## drop => $drop, ##-- drop keys @$drop (ARRAY) or keys(%$drop) (HASH) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | ## ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | sub trim { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trim: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | my ($dprf,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my ($pa,$pb) = @$dprf{qw(prf1 prf2)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if ($opts{keep} || $opts{drop}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts{"keep"} or $opts{"drop"}
MC/DC0%0/2
$opts{"keep"} or $opts{"drop"}
$opts{"keep"}
$opts{"drop"}
Truth table0%0/3
A or B
A= $opts{"keep"}B= $opts{"drop"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | ##-- explicit keep request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | $dprf->populate() if (!$dprf->{score}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | $dprf->SUPER::trim(%opts) or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | ##-- heuristic (pre-)trimming | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | $dprf->pretrim($pa,$pb,%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | $dprf->populate(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | $dprf->SUPER::trim(%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | ##-- trim operand profiles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | my $keep = $dprf->{$dprf->{score}//'f12'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$dprf->{"score"} // "f12"
MC/DC0%0/1
$dprf->{"score"} // "f12"
$dprf->{"score"}
Truth table0%0/2
A
A= $dprf->{"score"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | $pa->trim(keep=>$keep) or return undef if ($pa); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$pa && ($pa->trim('keep', $keep) || (return undef))
$pa->trim("keep", $keep) or return undef
MC/DC0%0/2
$pa && ($pa->trim('keep', $keep) || (return undef))
$pa
$pa->trim("keep", $keep)
Truth table0%0/3
A && B
A= $paB= $pa->trim("keep", $keep)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | $pb->trim(keep=>$keep) or return undef if ($pb); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$pb && ($pb->trim('keep', $keep) || (return undef))
$pb->trim("keep", $keep) or return undef
MC/DC0%0/2
$pb && ($pb->trim('keep', $keep) || (return undef))
$pb
$pb->trim("keep", $keep)
Truth table0%0/3
A && B
A= $pbB= $pb->trim("keep", $keep)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | return $dprf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | ## ($pa,$pb) = $CLASS_OR_OBJECT->pretrim($pa,$pb,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | ## + perform pre-trimming on aligned profile pair ($pa,$pb) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | sub pretrim { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pretrim: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | my ($that,$pa,$pb,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $pretrim = $that->diffpretrim($opts{diff}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | if ($pretrim eq 'kbest') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | ##-- pre-trim: union of k-best collocates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | my %keep = map {($_=>undef)} (($pa ? @{$pa->which(%opts)} : qw()), ($pb ? @{$pb->which(%opts)} : qw())); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | $pa->trim(keep=>\%keep) if ($pa); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | $pb->trim(keep=>\%keep) if ($pb); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | ▶ | elsif ($pretrim eq 'restrict' && $pa && $pb) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$pretrim eq "restrict" and $pa and $pb
$pretrim eq "restrict" and $pa
MC/DC0%0/3
$pretrim eq "restrict" and $pa and $pb
$pretrim eq "restrict"
$pa
$pb
Truth table0%0/4
A and B and C
A= $pretrim eq "restrict"B= $paC= $pb
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | my @drop = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | (grep {!exists $pa->{f12}{$_}} keys %{$pb->{f12}}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | (grep {!exists $pb->{f12}{$_}} keys %{$pa->{f12}}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | $pa->trim(drop=>\@drop); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $pb->trim(drop=>\@drop); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | return ($pa,$pb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | ## Stringification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | ## $dprf = $dprf->stringify( $obj) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | ## $dprf = $dprf->stringify(\@key2str) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | ## $dprf = $dprf->stringify(\&key2str) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | ## $dprf = $dprf->stringify(\%key2str) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | ## + stringifies profile (destructive) via $obj->i2s($key2), $key2str->($i2) or $key2str->{$i2} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | sub stringify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringify: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my ($dprf,$i2s) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $i2s = $dprf->stringify_map($i2s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | $_->stringify($i2s) or return undef foreach (grep {defined($_)} $dprf->operands); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | return $dprf->SUPER::stringify($i2s); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | ## Binary operations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | ## $dprf = $dprf->_add($dprf2,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | ## + adds $dprf2 operand frequency data to $dprf operands (destructive) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | ## + implicitly un-compiles $dprf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | ## + %opts: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | ## N => $bool, ##-- whether to add N values (default:true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | ## f1 => $bool, ##-- whether to add f1 values (default:true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | sub _add { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my ($dpa,$dpb,%opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | $dpa->{prf1}->_add($dpb->{prf1}) if ($dpa->{prf1} && $dpb->{prf1}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dpa->{"prf1"} and $dpb->{"prf1"}
MC/DC0%0/2
$dpa->{"prf1"} and $dpb->{"prf1"}
$dpa->{"prf1"}
$dpb->{"prf1"}
Truth table0%0/3
A and B
A= $dpa->{"prf1"}B= $dpb->{"prf1"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | $dpa->{prf2}->_add($dpb->{prf2}) if ($dpa->{prf2} && $dpb->{prf2}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dpa->{"prf2"} and $dpb->{"prf2"}
MC/DC0%0/2
$dpa->{"prf2"} and $dpb->{"prf2"}
$dpa->{"prf2"}
$dpb->{"prf2"}
Truth table0%0/3
A and B
A= $dpa->{"prf2"}B= $dpb->{"prf2"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | return $dpa->uncompile(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | ## $dprf3 = $dprf1->add($dprf2,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | ## + returns sum of $dprf1 and $dprf2 operatnd frequency data (destructive) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | ## + see _add() method for %opts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | ## + INHERITED from DiaColloDB::Profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | ## $diff = $prf1->diff($prf2,%opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | ## + returns score-diff of $prf1 and $prf2 frequency data (destructive) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | ## + %opts: see _diff() method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | ## + INHERITED but probably useless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | ##============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | ## Footer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||