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'} ? :
33 0 12 unless $self->{'windowsize'} > 0
36 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') { }
116 1 11 if (exists $params{'limit'})
117 0 1 if $params{'limit'} < 1
122 0 12 if %params
133 106 98 if (defined $self->{'token_dict'}{$t}) { }
142 367 204 if ($n > 1) { }
143 32 335 unless $self->{'lastngram'}[$n - 1] ne ""
148 330 209 if (($self->{'table'}[$n]{$self->{'lastngram'}[$n]} += 1) == 1)
152 31 508 if ($self->{'firstngram'}[$n] eq "")
156 1 23 if (exists $self->{'limit'} and $self->{'total_distinct_count'} > 2 * $self->{'limit'})
164 0 4 if (exists $self->{'limit'})
174 0 18 if ($cont < 0)
176 6 0 if ($self->{'skiprex'} eq "" and $self->{'tokenrex'} eq "" and $self->{'processtoken'} eq "" and $cont == 0)
191 54 32 if ($self->{'skiprex'} ne "" and $textl =~ /^$self->{'skiprex'}/)
193 56 30 if (defined $self->{'skipinsert'})
197 4 82 if (length $textl < $cont)
198 5 77 if (length $textl == 0)
201 77 0 if ($self->{'tokenrex'} ne '') { }
202 77 0 if ($textl =~ /^$self->{'tokenrex'}/)
207 0 77 if $_ eq ""
209 1 76 if (length $textl < $cont)
210 1 0 if (defined $self->{'allow_iproc'} and $self->{'allow_iproc'} and ref $self->{'processtoken'} eq "CODE")
216 76 0 if (ref $self->{'processtoken'} eq "CODE")
231 2 4 if $#a == -1
242 0 7 if (defined $self->{'inputlayer'})
248 7 0 if (not ref $f) { }
249 0 7 unless open F, "$f"
255 0 7 if ($input_layer ne "")
261 2 1 if ($self->{'skiprex'} eq "" and $self->{'tokenrex'} eq "" and $self->{'processtoken'} eq "")
271 7 7 if length $text <= $text_l
280 0 7 if ($input_layer ne "")
285 7 0 unless ref $f
286 1 6 if (exists $self->{'limit'})
293 0 2 unless exists $self->{'limit'} and $self->{'limit'} > 0
305 11 11 if ($f <= $prunefrequency) { }
3 8 elsif ($nextprunefrequency > $f) { }
314 1 3 if $self->{'total_distinct_count'} <= $self->{'limit'}
315 0 3 if $nextprunefrequency <= $prunefrequency
339 26 1 exists $params{'n'} ? :
340 2 25 exists $params{'onlyfirst'} ? :
341 0 27 exists $params{'normalize'} ? :
344 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') { }
347 0 0 if $onlyfirst
355 0 31 unless $self->{'table'}[$n]{$b} <=> $self->{'table'}[$n]{$a}
360 2 25 if $onlyfirst
365 0 262 $opt_normalize ? :
375 0 11 exists $params{'n'} ? :
376 1 10 exists $params{'onlyfirst'} ? :
377 0 11 exists $params{'normalize'} ? :
383 1 10 exists $params{'out'} ? :
386 1 10 if ($out and not ref $out)
387 0 1 unless open FH, ">$out"
398 10 1 unless $spartan
401 4 26 if ($spartan and $n < $self->{'windowsize'})
402 25 1 unless ($spartan)
412 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') { }
415 0 0 if $onlyfirst
425 2 24 if $onlyfirst
433 1 25 if ($out)
435 25 1 unless $spartan
438 10 1 unless $spartan
440 1 10 if ($out)
442 1 0 unless ref $out
454 4 6 if (/^\\(\S)/) { }
0 6 elsif (/^\^_/) { }
2 4 elsif (/^\^(\S)/) { }
0 4 elsif (/^\`(\S)/) { }
0 4 elsif (/^_+/) { }
4 0 elsif (/^[^\\^\`\s_]+/) { }