File Coverage

blib/lib/Lingua/Identifier/Feature/Trigrams.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 21 22 95.4


line stmt bran cond sub pod time code
1             package Lingua::Identifier::Feature::Trigrams;
2             $Lingua::Identifier::Feature::Trigrams::VERSION = '0.01';
3 2     2   33 use 5.006;
  2         6  
  2         75  
4 2     2   12 use strict;
  2         4  
  2         72  
5              
6 2     2   2005 use Text::Ngram 'ngram_counts';
  2         6724  
  2         291  
7              
8             sub features {
9 1     1 0 3 my $n = 3;
10              
11 1         3 my ($txt) = @_;
12 1         8 my $hash = ngram_counts $txt, $n;
13              
14 1         23873 my $total = 0;
15 1         449 $total += $hash->{$_} for keys %$hash;
16              
17 1         182 for my $k (keys %$hash) {
18 781         1559 $hash->{$k} = $hash->{$k} / $total;
19             }
20              
21 1         67 return $hash;
22             }
23              
24             =for Pod::Coverage features
25              
26             =cut
27              
28              
29             1;