| 1 | package Lingua::TokenParse; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | $Lingua::TokenParse::VERSION = '0.1602'; | |||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | our $AUTHORITY = 'cpan:GENE'; | |||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: DEPRECATED in favor of Lingua::Word::Parser | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | $VERSION = '0.1602'; | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Storable qw(retrieve store); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Math::BaseCalc (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | my $proto = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | my $class = ref $proto || $proto; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||
| 19 | verbose => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # The word to parse! | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | word => undef, | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # We need to use this. | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | word_length => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # Known tokens. | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | lexicon => {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # Local lexicon cache file name. | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | lexicon_file => '', # ?: 'lexicon-' . time(), | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # All word parts. | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | parts => [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # All possible parts combinations. | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | combinations => [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # Scored list of the known parts combinations. | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | knowns => {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # Definitions of the known and unknown fragments in knowns. | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | definitions => {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # Fragment definition separator. | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | separator => ' + ', | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # Known-but-not-defined definition output string. | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | not_defined => '.', | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # Unknown definition output string. | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | unknown => '?', | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # Known trimming regexp rules. | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | constraints => [], | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | @_, # slurp anything else and override defaults. | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | $self->_init(); | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | ▶ | sub _init { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | warn "Entering _init()\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | ▶ | $self->word( $self->{word} ) if $self->{word}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # Retrieve our lexicon cache if a filename was set. | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | $self->lexicon_cache; | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | # Cache our lexicon if a filename has been given. | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | $self->lexicon_cache( $self->{lexicon_file} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | ▶ | if $self->{lexicon_file}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub verbose { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verbose: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $self->{verbose} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | return $self->{verbose}; | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | sub word { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
word: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # WORD: This method is the only place where word_length is set. | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | ▶ | warn "Entering word()\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | ▶ | if( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | $self->{word} = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | $self->{word_length} = length $self->{word}; | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | printf "\tword = %s\n\tlength = %d\n", | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | $self->{word}, $self->{word_length} | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | return $self->{word}; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 964 | ▶ | sub lexicon { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lexicon: called CC=5 SCAR=18.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 964 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | 964 | ▶ | if( @_ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | ▶ | $self->{lexicon} = @_ == 1 && ref $_[0] eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ? shift | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | : @_ % 2 == 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ? { @_ } | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | : {}; | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 964 | return $self->{lexicon}; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | ▶ | sub parts { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parts: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | ▶ | $self->{parts} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | return $self->{parts}; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 195 | ▶ | sub combinations { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
combinations: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 195 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | 195 | ▶ | $self->{combinations} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 195 | return $self->{combinations}; | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 3 | ▶ | sub knowns { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
knowns: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 3 | ▶ | $self->{knowns} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 3 | return $self->{knowns}; | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | sub definitions { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
definitions: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | $self->{definitions} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | return $self->{definitions}; | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub separator { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
separator: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | $self->{separator} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | return $self->{separator}; | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub not_defined { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
not_defined: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $self->{not_defined} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | return $self->{not_defined}; | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub unknown { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unknown: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $self->{unknown} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | return $self->{unknown}; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 46 | ▶ | sub constraints { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
constraints: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 46 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | 46 | ▶ | $self->{constraints} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 46 | return $self->{constraints}; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | ▶ | warn "Entering parse()\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | ▶ | $self->word( shift ) if @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | croak 'No word provided.' unless defined $self->{word}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | croak 'No lexicon defined.' unless keys %{ $self->{lexicon} }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # Reset our data structures. | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | $self->parts([]); | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | $self->definitions({}); | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | $self->combinations([]); | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | $self->knowns({}); | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | # Build new ones based on the word. | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | $self->build_parts; | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | $self->build_definitions; | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | $self->build_combinations; | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | $self->build_knowns; | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | ▶ | sub build_parts { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_parts: called CC=10 SCAR=32.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | warn "Entering build_parts()\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | for my $i (0 .. $self->{word_length} - 1) { | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | 9 | for my $j (1 .. $self->{word_length} - $i) { | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | 45 | my $part = substr $self->{word}, $i, $j; | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | 45 | push @{ $self->{parts} }, $part | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | 45 | unless grep { $part =~ /$_/ } | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | 45 | ▶ | @{ $self->constraints }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | ▶ | if($self->{verbose}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # XXX This is ugly. | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $last = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | for my $part (@{ $self->{parts} }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | print '', | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | ($last ? $last > length( $part ) ? "\n\t" : ', ' : "\t"), | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | $part; | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $last = length $part; | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | print "\n" if @{ $self->{parts} }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | return $self->{parts}; | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # Save a known combination entry => definition table. | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | ▶ | sub build_definitions { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_definitions: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | warn "Entering build_definitions()\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | for my $part (@{ $self->{parts} }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | $self->{definitions}{$part} = $self->{lexicon}{$part} | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 45 | ▶ | if $self->{lexicon}{$part}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | warn "\t", join( "\n\t", sort keys %{ $self->definitions } ), "\n" | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | return $self->{definitions}; | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | ▶ | sub build_combinations { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_combinations: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | ▶ | warn "Entering build_combinations()\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # field size for binary iteration (digits of precision) | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | my $y = $self->{word_length} - 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | # total number of zero-based combinations | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | my $z = 2 ** $y - 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | # field size for the count | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | my $lz = length $z; | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | # field size for a combination | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | my $m = $self->{word_length} + $y; | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | warn sprintf | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | "\tTotal combinations: %d\n\tConstrained combinations:\n", | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | $z + 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # Truth is a single partition character: the lowly dot. | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | my $c = Math::BaseCalc->new( digits => [ 0, '.' ] ); | |||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # Build a word part combination for each iteration. | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | for my $n ( 0 .. $z ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | # Iterate in base two. | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 256 | my $i = $c->to_base( $n ); | |||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # Get the binary digits as an array. | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 256 | my @i = split //, sprintf( '%0'.$y.'s', $i ); | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # Join the character and digit arrays into a partitioned word. | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 256 | my $t = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | # ..by stepping over the characters and peeling off a digit. | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 256 | for( split //, $self->{word} ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | # Zero values become ''. Haha! Truth prevails. | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2304 | ▶ | $t .= $_ . (shift( @i ) || ''); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift @i || ''
MC/DC100%1/1
shift @i || ''
shift @i
Truth table100%2/2
A
A= shift @i
| |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 256 | ▶ | unless( grep { $t =~ /$_/ } @{ $self->{constraints} } ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # Preach it. | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | printf "\t%".$lz.'d) %0'.$y.'s => %'.$m."s\n", $n, $i, $t | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 192 | ▶ | if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 192 | push @{ $self->combinations }, $t; | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | return $self->{combinations}; | |||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | ▶ | sub build_knowns { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_knowns: called CC=10 SCAR=23.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | ▶ | return unless scalar keys %{ $self->{lexicon} }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | ▶ | warn "Entering build_knowns()\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # Save the familiarity value for each "raw" combination. | ||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | for my $combo (@{ $self->{combinations} }) { | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | # Skip combinations that have already been seen. | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 192 | ▶ | next if exists $self->{knowns}{$combo}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 192 | my ($sum, $frag_sum, $char_sum) = (0, 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # Get the bits of the combination. | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 192 | my @chunks = split /\./, $combo; | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | 192 | for (@chunks) { | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | # XXX Uh.. Magically handle hyphens in lexicon entries. | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 960 | ($_, my $combo_seen) = _hyphenate($_, $self->lexicon, 0); | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||
| 269 | # Sum the combination familiarity values. | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 960 | ▶ | if ($combo_seen) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 108 | $frag_sum++; | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | 108 | $char_sum += length; | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # XXX Huh? Why? Can $_ change or something? | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # Stick our combination back together. | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 192 | $combo = join '.', @chunks; | |||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # Save this combination and its familiarity ratios. | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 192 | my $x = $frag_sum / @chunks; | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | 192 | my $y = $char_sum / $self->{word_length}; | |||||||||||||||||||||||||||||||||||||||||||||
| 282 | 192 | ▶ | warn "\t$combo: [$x, $y]\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 192 | ▶ | if( $x || $y ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$x or $y
MC/DC50%1/2
$x or $y
$x
$y
Truth table66%2/3
A or B
A= $xB= $y
| |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 85 | $self->{knowns}{$combo} = [ $x, $y ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 107 | delete $self->{knowns}{$combo}; | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | return $self->{knowns}; | |||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # Reduce the number of known combinations by concatinating adjacent | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | # unknowns (and then removing any duplicates produced). | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | #sub learn { | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # Get the list of (partially) unknown stem combinations. | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # Loop through each looking in %args or prompting for a definition. | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | #} | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # Update the given string with its actual lexicon value and increment | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # the seen flag. | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 960 | ▶ | sub _hyphenate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hyphenate: called CC=8 SCAR=29.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 960 | my ($string, $lexicon, $combo_seen) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 960 | ▶ | if (exists $lexicon->{$string}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 108 | ▶ | $combo_seen++ if defined $combo_seen; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | elsif (exists $lexicon->{"-$string"}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | $combo_seen++ if defined $combo_seen; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $string = "-$string"; | |||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | elsif (exists $lexicon->{"$string-"}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $combo_seen++ if defined $combo_seen; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $string = "$string-"; | |||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 960 | ▶ | return wantarray ? ($string, $combo_seen) : $string; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | sub output_knowns { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output_knowns: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my @out = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my $header = <<HEADER; | |||||||||||||||||||||||||||||||||||||||||||||
| 327 | Combination [frag familiarity, char familiarity] | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | Fragment definitions | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | HEADER | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | for my $known ( | |||||||||||||||||||||||||||||||||||||||||||||
| 333 | reverse sort { | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | $self->{knowns}{$a}[0] <=> $self->{knowns}{$b}[0] || | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | $self->{knowns}{$a}[1] <=> $self->{knowns}{$b}[1] | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'knowns'}{$a}[0] <=> $self->{'knowns'}{$b}[0] || $self->{'knowns'}{$a}[1] <=> $self->{'knowns'}{$b}[1]
MC/DC0%0/2
$self->{'knowns'}{$a}[0] <=> $self->{'knowns'}{$b}[0] || $self->{'knowns'}{$a}[1] <=> $self->{'knowns'}{$b}[1]
$self->{'knowns'}{$a}[0] <=> $self->{'knowns'}{$b}[0]
$self->{'knowns'}{$a}[1] <=> $self->{'knowns'}{$b}[1]
Truth table0%0/3
A || B
A= $self->{'knowns'}{$a}[0] <=> $self->{'knowns'}{$b}[0]B= $self->{'knowns'}{$a}[1] <=> $self->{'knowns'}{$b}[1]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | } keys %{ $self->{knowns} } | |||||||||||||||||||||||||||||||||||||||||||||
| 337 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my @definition; | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | for my $chunk (split /\./, $known) { | |||||||||||||||||||||||||||||||||||||||||||||
| 340 | push @definition, | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | defined $self->{definitions}{$chunk} | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | ? $self->{definitions}{$chunk} | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | ? $self->{definitions}{$chunk} | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | : $self->{not_defined} | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | : $self->{unknown}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | push @out, sprintf qq/%s [%s]\n%s/, | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | $known, | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | join (', ', map { sprintf '%0.2f', $_ } | |||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | @{ $self->{knowns}{$known} }), | |||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | join ($self->{separator}, @definition); | |||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | return wantarray ? @out : $header . join "\n\n", @out; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||
| 358 | # Naive, no locking read/write. If you run a production environment, | ||||||||||||||||||||||||||||||||||||||||||||||
| 359 | # you know what to do. | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 5 | ▶ | sub lexicon_cache { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lexicon_cache: called CC=15 SCAR=30.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 5 | my( $self, $file, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 362 | 5 | ▶ | warn "Entering lexicon_cache()\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # Set the file and the lexicon_file attribute if we are told to. | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 5 | ▶ | if( $file && $file eq 'lexicon_file' && $value ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$file and $file eq "lexicon_file" and $value
$file and $file eq "lexicon_file"
MC/DC66%2/3
$file and $file eq "lexicon_file" and $value
$file
$file eq "lexicon_file"
$value
Truth table75%3/4
A and B and C
A= $fileB= $file eq "lexicon_file"C= $value
| |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 1 | $self->{lexicon_file} = $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 367 | 1 | $file = $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # If there is no file try to use the lexicon_file. | ||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 5 | ▶ | $file ||= $self->{lexicon_file}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$file ||= $self->{"lexicon_file"}
MC/DC50%1/2
$file ||= $self->{"lexicon_file"}
$file
$self->{"lexicon_file"}
Truth table66%2/3
A ||= B
A= $fileB= $self->{"lexicon_file"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | # Otherwise, bail out! | ||||||||||||||||||||||||||||||||||||||||||||||
| 373 | warn( "No lexicon cache file set\n" ) and return | ||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 5 | ▶ | if $self->{verbose} && !$file; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition25%2/8
$self->{'verbose'} && !$file && (warn("No lexicon cache file set\n") && (return))
$self->{"verbose"} and not $file
warn "No lexicon cache file set\n" and return
MC/DC0%0/3
$self->{'verbose'} && !$file && (warn("No lexicon cache file set\n") && (return))
$self->{"verbose"}
not $file
warn "No lexicon cache file set\n"
Truth table25%1/4
A and not(B) && C
A= $self->{"verbose"}B= not $fileC= warn "No lexicon cache file set\n"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 5 | ▶ | if( $file ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # Store 'em if you got 'em. | ||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 3 | ▶ | if( keys %{ $self->{lexicon} } ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 2 | ▶ | warn "store( $self->{lexicon}, $file )\n" if $self->{verbose}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 2 | store( $self->{lexicon}, $file ); | |||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 382 | # ..Retrieve 'em if not. | ||||||||||||||||||||||||||||||||||||||||||||||
| 383 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 1 | ▶ | warn "retrieve( $file )\n" if $self->{verbose} && -e $file; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"verbose"} and -e $file
MC/DC0%0/2
$self->{"verbose"} and -e $file
$self->{"verbose"}
-e $file
Truth table33%1/3
A and B
A= $self->{"verbose"}B= -e $file
| |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | ▶ | $self->lexicon( retrieve( $file ) ) if -e $file; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||
| 392 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||