Branch Coverage

blib/lib/Text/Ngrams.pm
Criterion Covered Total %
branch 117 158 74.0


line true false branch
31 6 6 exists $params{'windowsize'} ? :
32 0 12 unless $self->{'windowsize'} > 0
35 3 9 if (not exists $params{'type'} or $params{'type'} eq 'character') { }
0 9 elsif ($params{'type'} eq 'utf8') { }
0 9 elsif ($params{'type'} eq 'utf8_character') { }
4 5 elsif ($params{'type'} eq 'byte') { }
5 0 elsif ($params{'type'} eq 'word') { }
109 1 11 if (exists $params{'limit'})
110 0 1 if $params{'limit'} < 1
115 0 12 if %params
126 106 98 if (defined $self->{'token_dict'}{$t}) { }
135 367 204 if ($n > 1) { }
136 32 335 unless $self->{'lastngram'}[$n - 1] ne ''
141 330 209 if (($self->{'table'}[$n]{$self->{'lastngram'}[$n]} += 1) == 1)
145 31 508 if ($self->{'firstngram'}[$n] eq '')
149 1 23 if (exists $self->{'limit'} and $self->{'total_distinct_count'} > 2 * $self->{'limit'})
157 0 4 if (exists $self->{'limit'})
167 0 18 if ($cont < 0)
169 6 0 if ($self->{'skiprex'} eq '' and $self->{'tokenrex'} eq '' and $self->{'processtoken'} eq '' and $cont == 0)
184 54 32 if ($self->{'skiprex'} ne '' and $textl =~ /^$self->{'skiprex'}/)
186 56 30 if (defined $self->{'skipinsert'})
190 4 82 if (length $textl < $cont)
191 5 77 if (length $textl == 0)
194 77 0 if ($self->{'tokenrex'} ne '') { }
195 77 0 if ($textl =~ /^$self->{'tokenrex'}/)
200 0 77 if $_ eq ''
202 1 76 if (length $textl < $cont)
203 1 0 if (defined $self->{'allow_iproc'} and $self->{'allow_iproc'} and ref $self->{'processtoken'} eq 'CODE')
209 76 0 if (ref $self->{'processtoken'} eq 'CODE')
224 2 4 if $#a == -1
235 0 7 if (defined $self->{'inputlayer'})
241 7 0 if (not ref $f) { }
242 0 7 unless open F, "$f"
247 0 7 if ($input_layer ne '')
253 2 1 if ($self->{'skiprex'} eq '' and $self->{'tokenrex'} eq '' and $self->{'processtoken'} eq '')
263 7 7 if length $text <= $text_l
272 0 7 if ($input_layer ne '')
277 7 0 unless ref $f
278 1 6 if (exists $self->{'limit'})
285 0 2 unless exists $self->{'limit'} and $self->{'limit'} > 0
297 11 11 if ($f <= $prunefrequency) { }
4 7 elsif ($nextprunefrequency > $f) { }
306 1 3 if $self->{'total_distinct_count'} <= $self->{'limit'}
307 0 3 if $nextprunefrequency <= $prunefrequency
331 26 1 exists $params{'n'} ? :
332 2 25 exists $params{'onlyfirst'} ? :
333 0 27 exists $params{'normalize'} ? :
336 20 7 if (not exists $params{'orderby'} or $params{'orderby'} eq 'ngram') { }
0 7 elsif ($params{'orderby'} eq 'none') { }
7 0 elsif ($params{'orderby'} eq 'frequency') { }
339 0 0 if $onlyfirst
347 0 30 unless $self->{'table'}[$n]{$b} <=> $self->{'table'}[$n]{$a}
352 2 25 if $onlyfirst
357 0 262 $opt_normalize ? :
367 0 11 exists $params{'n'} ? :
368 1 10 exists $params{'onlyfirst'} ? :
369 0 11 exists $params{'normalize'} ? :
375 1 10 exists $params{'out'} ? :
378 1 10 if ($out and not ref $out)
379 0 1 unless open FH, ">$out"
390 10 1 unless $spartan
393 4 26 if ($spartan and $n < $self->{'windowsize'})
394 25 1 unless ($spartan)
404 20 6 if (not exists $params{'orderby'} or $params{'orderby'} eq 'ngram') { }
0 6 elsif ($params{'orderby'} eq 'none') { }
6 0 elsif ($params{'orderby'} eq 'frequency') { }
407 0 0 if $onlyfirst
417 2 24 if $onlyfirst
425 1 25 if ($out)
427 25 1 unless $spartan
430 10 1 unless $spartan
432 1 10 if ($out)
434 1 0 unless ref $out
446 4 6 if (/^\\(\S)/) { }
0 6 elsif (/^\^_/) { }
2 4 elsif (/^\^(\S)/) { }
0 4 elsif (/^\`(\S)/) { }
0 4 elsif (/^_+/) { }
4 0 elsif (/^[^\\^\`\s_]+/) { }