line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package KinoSearch1::Analysis::Stopalizer; |
2
|
4
|
|
|
4
|
|
35228
|
use strict; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
143
|
|
3
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
101
|
|
4
|
4
|
|
|
4
|
|
468
|
use KinoSearch1::Util::ToolSet; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
608
|
|
5
|
4
|
|
|
4
|
|
23
|
use base qw( KinoSearch1::Analysis::Analyzer ); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
916
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
4
|
|
|
4
|
|
56
|
__PACKAGE__->init_instance_vars( |
9
|
|
|
|
|
|
|
# constructor params / members |
10
|
|
|
|
|
|
|
stoplist => undef, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
3308
|
use Lingua::StopWords; |
|
4
|
|
|
|
|
1303
|
|
|
4
|
|
|
|
|
1432
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init_instance { |
17
|
3
|
|
|
3
|
1
|
8
|
my $self = shift; |
18
|
3
|
|
|
|
|
37
|
my $language = $self->{language} = lc( $self->{language} ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# verify a supplied stoplist |
21
|
3
|
100
|
|
|
|
18
|
if ( defined $self->{stoplist} ) { |
22
|
1
|
50
|
|
|
|
11
|
croak("stoplist must be a hashref") |
23
|
|
|
|
|
|
|
unless reftype( $self->{stoplist} ) eq 'HASH'; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
|
|
|
|
|
|
# create a stoplist if language was supplied |
27
|
2
|
50
|
|
|
|
21
|
if ( $language =~ /^(?:da|de|en|es|fr|it|nl|no|pt|ru|sv)$/ ) { |
|
|
0
|
|
|
|
|
|
28
|
2
|
|
|
|
|
14
|
$self->{stoplist} = Lingua::StopWords::getStopWords($language); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
# No Finnish stoplist, though we have a stemmmer. |
31
|
|
|
|
|
|
|
elsif ( $language eq 'fi' ) { |
32
|
0
|
|
|
|
|
|
$self->{stoplist} = {}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else { |
35
|
0
|
|
|
|
|
|
confess "Invalid language: '$language'"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |