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') { }
112 1 11 if (exists $params{'limit'})
113 0 1 if $params{'limit'} < 1
118 0 12 if %params
129 106 98 if (defined $self->{'token_dict'}{$t}) { }
138 367 204 if ($n > 1) { }
139 32 335 unless $self->{'lastngram'}[$n - 1] ne ''
144 330 209 if (($self->{'table'}[$n]{$self->{'lastngram'}[$n]} += 1) == 1)
148 31 508 if ($self->{'firstngram'}[$n] eq '')
152 1 23 if (exists $self->{'limit'} and $self->{'total_distinct_count'} > 2 * $self->{'limit'})
160 0 4 if (exists $self->{'limit'})
170 0 18 if ($cont < 0)
172 6 0 if ($self->{'skiprex'} eq '' and $self->{'tokenrex'} eq '' and $self->{'processtoken'} eq '' and $cont == 0)
187 54 32 if ($self->{'skiprex'} ne '' and $textl =~ /^$self->{'skiprex'}/)
189 56 30 if (defined $self->{'skipinsert'})
193 4 82 if (length $textl < $cont)
194 5 77 if (length $textl == 0)
197 77 0 if ($self->{'tokenrex'} ne '') { }
198 77 0 if ($textl =~ /^$self->{'tokenrex'}/)
203 0 77 if $_ eq ''
205 1 76 if (length $textl < $cont)
206 1 0 if (defined $self->{'allow_iproc'} and $self->{'allow_iproc'} and ref $self->{'processtoken'} eq 'CODE')
212 76 0 if (ref $self->{'processtoken'} eq 'CODE')
227 2 4 if $#a == -1
238 0 7 if (defined $self->{'inputlayer'})
244 7 0 if (not ref $f) { }
245 0 7 unless open F, "$f"
251 0 7 if ($input_layer ne '')
257 2 1 if ($self->{'skiprex'} eq '' and $self->{'tokenrex'} eq '' and $self->{'processtoken'} eq '')
267 7 7 if length $text <= $text_l
276 0 7 if ($input_layer ne '')
281 7 0 unless ref $f
282 1 6 if (exists $self->{'limit'})
289 0 2 unless exists $self->{'limit'} and $self->{'limit'} > 0
301 11 11 if ($f <= $prunefrequency) { }
4 7 elsif ($nextprunefrequency > $f) { }
310 1 3 if $self->{'total_distinct_count'} <= $self->{'limit'}
311 0 3 if $nextprunefrequency <= $prunefrequency
335 26 1 exists $params{'n'} ? :
336 2 25 exists $params{'onlyfirst'} ? :
337 0 27 exists $params{'normalize'} ? :
340 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') { }
343 0 0 if $onlyfirst
351 0 29 unless $self->{'table'}[$n]{$b} <=> $self->{'table'}[$n]{$a}
356 2 25 if $onlyfirst
361 0 262 $opt_normalize ? :
371 0 11 exists $params{'n'} ? :
372 1 10 exists $params{'onlyfirst'} ? :
373 0 11 exists $params{'normalize'} ? :
379 1 10 exists $params{'out'} ? :
382 1 10 if ($out and not ref $out)
383 0 1 unless open FH, ">$out"
394 10 1 unless $spartan
397 4 26 if ($spartan and $n < $self->{'windowsize'})
398 25 1 unless ($spartan)
408 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') { }
411 0 0 if $onlyfirst
421 2 24 if $onlyfirst
429 1 25 if ($out)
431 25 1 unless $spartan
434 10 1 unless $spartan
436 1 10 if ($out)
438 1 0 unless ref $out
450 4 6 if (/^\\(\S)/) { }
0 6 elsif (/^\^_/) { }
2 4 elsif (/^\^(\S)/) { }
0 4 elsif (/^\`(\S)/) { }
0 4 elsif (/^_+/) { }
4 0 elsif (/^[^\\^\`\s_]+/) { }