| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Lingua::Stem; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
3966
|
use strict; |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
58
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
63
|
|
|
5
|
|
|
|
|
|
|
require Exporter; |
|
6
|
2
|
|
|
2
|
|
835
|
use Lingua::Stem::AutoLoader; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
200
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
|
9
|
2
|
|
|
2
|
|
6
|
$Lingua::Stem::VERSION = '2.30'; |
|
10
|
2
|
|
|
|
|
36
|
@Lingua::Stem::ISA = qw (Exporter); |
|
11
|
2
|
|
|
|
|
9
|
@Lingua::Stem::EXPORT = (); |
|
12
|
2
|
|
|
|
|
5
|
@Lingua::Stem::EXPORT_OK = qw (stem stem_in_place clear_stem_cache stem_caching add_exceptions delete_exceptions get_exceptions set_locale get_locale); |
|
13
|
2
|
|
|
|
|
5288
|
%Lingua::Stem::EXPORT_TAGS = ( 'all' => [qw (stem stem_in_place stem_caching clear_stem_cache add_exceptions delete_exceptions get_exceptions set_locale get_locale)], |
|
14
|
|
|
|
|
|
|
'stem' => [qw (stem)], |
|
15
|
|
|
|
|
|
|
'stem_in_place' => [qw (stem_in_place)], |
|
16
|
|
|
|
|
|
|
'caching' => [qw (stem_caching clear_stem_cache)], |
|
17
|
|
|
|
|
|
|
'locale' => [qw (set_locale get_locale)], |
|
18
|
|
|
|
|
|
|
'exceptions' => [qw (add_exceptions delete_exceptions get_exceptions)], |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $defaults = { |
|
23
|
|
|
|
|
|
|
-locale => 'en', |
|
24
|
|
|
|
|
|
|
-stemmer => \&Lingua::Stem::En::stem, |
|
25
|
|
|
|
|
|
|
-stem_in_place => \&Lingua::Stem::En::stem, |
|
26
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::En::stem_caching, |
|
27
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::En::clear_stem_cache, |
|
28
|
|
|
|
|
|
|
-exceptions => {}, |
|
29
|
|
|
|
|
|
|
-known_locales => { |
|
30
|
|
|
|
|
|
|
'da' => { -stemmer => \&Lingua::Stem::Da::stem, |
|
31
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::Da::stem_caching, |
|
32
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::Da::clear_stem_cache, |
|
33
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'da' locale"); }, |
|
34
|
|
|
|
|
|
|
}, |
|
35
|
|
|
|
|
|
|
'de' => { -stemmer => \&Lingua::Stem::De::stem, |
|
36
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::De::stem_caching, |
|
37
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::De::clear_stem_cache, |
|
38
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'de' locale"); }, |
|
39
|
|
|
|
|
|
|
}, |
|
40
|
|
|
|
|
|
|
'en' => { -stemmer => \&Lingua::Stem::En::stem, |
|
41
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::En::stem_caching, |
|
42
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::En::clear_stem_cache, |
|
43
|
|
|
|
|
|
|
-stem_in_place => \&Lingua::Stem::En::stem, |
|
44
|
|
|
|
|
|
|
}, |
|
45
|
|
|
|
|
|
|
'en_us' => { -stemmer => \&Lingua::Stem::En::stem, |
|
46
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::En::stem_caching, |
|
47
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::En::clear_stem_cache, |
|
48
|
|
|
|
|
|
|
-stem_in_place => \&Lingua::Stem::En::stem, |
|
49
|
|
|
|
|
|
|
}, |
|
50
|
|
|
|
|
|
|
'en-us' => { -stemmer => \&Lingua::Stem::En::stem, |
|
51
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::En::stem_caching, |
|
52
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::En::clear_stem_cache, |
|
53
|
|
|
|
|
|
|
-stem_in_place => \&Lingua::Stem::En::stem, |
|
54
|
|
|
|
|
|
|
}, |
|
55
|
|
|
|
|
|
|
'en_uk' => { -stemmer => \&Lingua::Stem::En::stem, |
|
56
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::En::stem_caching, |
|
57
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::En::clear_stem_cache, |
|
58
|
|
|
|
|
|
|
-stem_in_place => \&Lingua::Stem::En::stem, |
|
59
|
|
|
|
|
|
|
}, |
|
60
|
|
|
|
|
|
|
'en-uk' => { -stemmer => \&Lingua::Stem::En::stem, |
|
61
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::En::stem_caching, |
|
62
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::En::clear_stem_cache, |
|
63
|
|
|
|
|
|
|
-stem_in_place => \&Lingua::Stem::En::stem, |
|
64
|
|
|
|
|
|
|
}, |
|
65
|
|
|
|
|
|
|
'en-broken' => { -stemmer => \&Lingua::Stem::En_Broken::stem, |
|
66
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::En_Broken::stem_caching, |
|
67
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::En_Broken::clear_stem_cache, |
|
68
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'en-broken' locale"); }, |
|
69
|
|
|
|
|
|
|
}, |
|
70
|
|
|
|
|
|
|
'fr' => { -stemmer => \&Lingua::Stem::Fr::stem, |
|
71
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::Fr::stem_caching, |
|
72
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::Fr::clear_stem_cache, |
|
73
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'fr' locale"); }, |
|
74
|
|
|
|
|
|
|
}, |
|
75
|
|
|
|
|
|
|
'gl' => { -stemmer => \&Lingua::Stem::Gl::stem, |
|
76
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::Gl::stem_caching, |
|
77
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::Gl::clear_stem_cache, |
|
78
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'gl' locale"); }, |
|
79
|
|
|
|
|
|
|
}, |
|
80
|
|
|
|
|
|
|
'it' => { -stemmer => \&Lingua::Stem::It::stem, |
|
81
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::It::stem_caching, |
|
82
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::It::clear_stem_cache, |
|
83
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'it' locale"); }, |
|
84
|
|
|
|
|
|
|
}, |
|
85
|
|
|
|
|
|
|
'no' => { -stemmer => \&Lingua::Stem::No::stem, |
|
86
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::No::stem_caching, |
|
87
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::No::clear_stem_cache, |
|
88
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'no' locale"); }, |
|
89
|
|
|
|
|
|
|
}, |
|
90
|
|
|
|
|
|
|
'pt' => { -stemmer => \&Lingua::Stem::Pt::stem, |
|
91
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::Pt::stem_caching, |
|
92
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::Pt::clear_stem_cache, |
|
93
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'pt' locale"); }, |
|
94
|
|
|
|
|
|
|
}, |
|
95
|
|
|
|
|
|
|
'sv' => { -stemmer => \&Lingua::Stem::Sv::stem, |
|
96
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::Sv::stem_caching, |
|
97
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::Sv::clear_stem_cache, |
|
98
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'sv' locale"); }, |
|
99
|
|
|
|
|
|
|
}, |
|
100
|
|
|
|
|
|
|
'ru' => { -stemmer => \&Lingua::Stem::Ru::stem, |
|
101
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::Ru::stem_caching, |
|
102
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::Ru::clear_stem_cache, |
|
103
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'ru' locale"); }, |
|
104
|
|
|
|
|
|
|
}, |
|
105
|
|
|
|
|
|
|
'ru_ru' => { |
|
106
|
|
|
|
|
|
|
-stemmer => \&Lingua::Stem::Ru::stem, |
|
107
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::Ru::stem_caching, |
|
108
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::Ru::clear_stem_cache, |
|
109
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'ru_ru' locale"); }, |
|
110
|
|
|
|
|
|
|
}, |
|
111
|
|
|
|
|
|
|
'ru-ru' => { |
|
112
|
|
|
|
|
|
|
-stemmer => \&Lingua::Stem::Ru::stem, |
|
113
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::Ru::stem_caching, |
|
114
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::Ru::clear_stem_cache, |
|
115
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'ru-ru' locale"); }, |
|
116
|
|
|
|
|
|
|
}, |
|
117
|
|
|
|
|
|
|
'ru-ru.koi8-r' => { |
|
118
|
|
|
|
|
|
|
-stemmer => \&Lingua::Stem::Ru::stem, |
|
119
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::Ru::stem_caching, |
|
120
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::Ru::clear_stem_cache, |
|
121
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'ru-ru.koi8-r' locale"); }, |
|
122
|
|
|
|
|
|
|
}, |
|
123
|
|
|
|
|
|
|
'ru_ru.koi8-r' => { |
|
124
|
|
|
|
|
|
|
-stemmer => \&Lingua::Stem::Ru::stem, |
|
125
|
|
|
|
|
|
|
-stem_caching => \&Lingua::Stem::Ru::stem_caching, |
|
126
|
|
|
|
|
|
|
-clear_stem_cache => \&Lingua::Stem::Ru::clear_stem_cache, |
|
127
|
|
|
|
|
|
|
-stem_in_place => sub { require Carp; Carp::croak("'stem_in_place' not available for 'ru_ru.koi8-r' locale"); }, |
|
128
|
|
|
|
|
|
|
}, |
|
129
|
|
|
|
|
|
|
}, |
|
130
|
|
|
|
|
|
|
}; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
### |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub new { |
|
135
|
3
|
|
|
3
|
1
|
258
|
my $proto = shift; |
|
136
|
3
|
|
|
|
|
6
|
my $package = __PACKAGE__; |
|
137
|
3
|
|
|
|
|
5
|
my $proto_ref = ref($proto); |
|
138
|
3
|
|
|
|
|
5
|
my $class; |
|
139
|
3
|
50
|
|
|
|
9
|
if ($proto_ref) { |
|
|
|
50
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
0
|
$class = $proto_ref; |
|
141
|
|
|
|
|
|
|
} elsif ($proto) { |
|
142
|
3
|
|
|
|
|
7
|
$class = $proto; |
|
143
|
|
|
|
|
|
|
} else { |
|
144
|
0
|
|
|
|
|
0
|
$class = $package; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
3
|
|
|
|
|
7
|
my $self = bless {},$class; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# Set the defaults |
|
149
|
3
|
|
|
|
|
5
|
%{$self->{'Lingua::Stem'}->{-exceptions}} = %{$defaults->{-exceptions}}; |
|
|
3
|
|
|
|
|
16
|
|
|
|
3
|
|
|
|
|
8
|
|
|
150
|
3
|
|
|
|
|
8
|
$self->{'Lingua::Stem'}->{-locale} = $defaults->{-locale}; |
|
151
|
3
|
|
|
|
|
4
|
$self->{'Lingua::Stem'}->{-stemmer} = $defaults->{-stemmer}; |
|
152
|
3
|
|
|
|
|
7
|
$self->{'Lingua::Stem'}->{-stem_in_place} = $defaults->{-stem_in_place}; |
|
153
|
3
|
|
|
|
|
6
|
$self->{'Lingua::Stem'}->{-stem_caching} = $defaults->{-stem_caching}; |
|
154
|
3
|
|
|
|
|
5
|
$self->{'Lingua::Stem'}->{-clear_stem_cache} = $defaults->{-clear_stem_cache}; |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# Handle any passed parms |
|
157
|
3
|
|
|
|
|
5
|
my @errors = (); |
|
158
|
3
|
50
|
|
|
|
9
|
if ($#_ > -1) { |
|
159
|
0
|
|
|
|
|
0
|
my $parm_ref = $_[0]; |
|
160
|
0
|
0
|
|
|
|
0
|
if (not ref $parm_ref) { |
|
161
|
0
|
|
|
|
|
0
|
$parm_ref = {@_}; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
0
|
|
|
|
|
0
|
foreach my $key (keys %$parm_ref) { |
|
164
|
0
|
|
|
|
|
0
|
my $lc_key = lc ($key); |
|
165
|
0
|
0
|
|
|
|
0
|
if ($lc_key eq '-locale') { $self->set_locale($parm_ref->{$key}); } |
|
|
0
|
0
|
|
|
|
0
|
|
|
166
|
0
|
|
|
|
|
0
|
elsif ($lc_key eq '-default_locale') { set_locale($parm_ref->{$key}); } |
|
167
|
0
|
|
|
|
|
0
|
else { push (@errors," '$key' => '$parm_ref->{$key}'"); } |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
} |
|
170
|
3
|
50
|
|
|
|
9
|
if ($#errors > -1) { |
|
171
|
0
|
|
|
|
|
0
|
require Carp; |
|
172
|
0
|
|
|
|
|
0
|
Carp::croak ($package . "::new() - unrecognized parameters passed:" . join(', ',@errors)); |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
3
|
|
|
|
|
7
|
return $self; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
### |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub set_locale { |
|
181
|
47
|
|
|
47
|
1
|
15187
|
my ($self) = shift; |
|
182
|
|
|
|
|
|
|
|
|
183
|
47
|
|
|
|
|
59
|
my ($locale); |
|
184
|
47
|
100
|
|
|
|
86
|
if (ref $self) { |
|
185
|
14
|
|
|
|
|
22
|
($locale) = @_; |
|
186
|
14
|
|
|
|
|
29
|
$locale = lc $locale; |
|
187
|
14
|
50
|
|
|
|
31
|
if (not exists $defaults->{-known_locales}->{$locale}) { |
|
188
|
0
|
|
|
|
|
0
|
require Carp; |
|
189
|
0
|
|
|
|
|
0
|
Carp::croak (__PACKAGE__ . "::set_locale() - Unknown locale '$locale'"); |
|
190
|
|
|
|
|
|
|
} |
|
191
|
14
|
|
|
|
|
24
|
$self->{'Lingua::Stem'}->{-locale} = $locale; |
|
192
|
14
|
|
|
|
|
23
|
$self->{'Lingua::Stem'}->{-stemmer} = $defaults->{-known_locales}->{$locale}->{-stemmer}; |
|
193
|
14
|
|
|
|
|
25
|
$self->{'Lingua::Stem'}->{-stem_in_place} = $defaults->{-known_locales}->{$locale}->{-stem_in_place}; |
|
194
|
14
|
|
|
|
|
22
|
$self->{'Lingua::Stem'}->{-stem_caching} = $defaults->{-known_locales}->{$locale}->{-stem_caching}; |
|
195
|
14
|
|
|
|
|
20
|
$self->{'Lingua::Stem'}->{-clear_stem_cache} = $defaults->{-known_locales}->{$locale}->{-clear_stem_cache}; |
|
196
|
|
|
|
|
|
|
} else { |
|
197
|
33
|
|
|
|
|
46
|
$locale = lc $self; |
|
198
|
33
|
50
|
|
|
|
76
|
if (not exists $defaults->{-known_locales}->{$locale}) { |
|
199
|
0
|
|
|
|
|
0
|
require Carp; |
|
200
|
0
|
|
|
|
|
0
|
Carp::croak (__PACKAGE__ . "::set_locale() - Unknown locale '$locale'"); |
|
201
|
|
|
|
|
|
|
} |
|
202
|
33
|
|
|
|
|
39
|
$defaults->{-locale} = $locale; |
|
203
|
33
|
|
|
|
|
59
|
$defaults->{-stemmer} = $defaults->{-known_locales}->{$locale}->{-stemmer}; |
|
204
|
33
|
|
|
|
|
46
|
$defaults->{-stem_in_place} = $defaults->{-known_locales}->{$locale}->{-stem_in_place}; |
|
205
|
33
|
|
|
|
|
40
|
$defaults->{-stem_caching} = $defaults->{-known_locales}->{$locale}->{-stem_caching}; |
|
206
|
33
|
|
|
|
|
43
|
$defaults->{-clear_stem_cache} = $defaults->{-known_locales}->{$locale}->{-clear_stem_cache}; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
47
|
|
|
|
|
78
|
return; |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
### |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub get_locale { |
|
214
|
54
|
|
|
54
|
1
|
461
|
my $self = shift; |
|
215
|
|
|
|
|
|
|
|
|
216
|
54
|
100
|
|
|
|
91
|
if (ref $self) { |
|
217
|
17
|
|
|
|
|
41
|
return $self->{'Lingua::Stem'}->{-locale}; |
|
218
|
|
|
|
|
|
|
} else { |
|
219
|
37
|
|
|
|
|
84
|
return $defaults->{-locale}; |
|
220
|
|
|
|
|
|
|
} |
|
221
|
|
|
|
|
|
|
} |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
### |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
sub add_exceptions { |
|
226
|
6
|
|
|
6
|
1
|
46
|
my $self; |
|
227
|
|
|
|
|
|
|
|
|
228
|
6
|
|
|
|
|
10
|
my ($exceptions, $exception_list); |
|
229
|
6
|
|
|
|
|
12
|
my $reference = ref $_[0]; |
|
230
|
6
|
100
|
|
|
|
27
|
if ($reference eq 'HASH') { |
|
|
|
50
|
|
|
|
|
|
|
231
|
3
|
|
|
|
|
8
|
($exceptions) = @_; |
|
232
|
3
|
|
|
|
|
4
|
$exception_list = $defaults->{-exceptions}; |
|
233
|
|
|
|
|
|
|
} elsif (not $reference) { |
|
234
|
0
|
|
|
|
|
0
|
$exceptions = { @_ }; |
|
235
|
0
|
|
|
|
|
0
|
$exception_list = $defaults->{-exceptions}; |
|
236
|
|
|
|
|
|
|
} else { |
|
237
|
3
|
|
|
|
|
4
|
$self = shift; |
|
238
|
3
|
|
|
|
|
6
|
($exceptions) = @_; |
|
239
|
3
|
|
|
|
|
4
|
$exception_list = $self->{'Lingua::Stem'}->{-exceptions}; |
|
240
|
|
|
|
|
|
|
} |
|
241
|
6
|
|
|
|
|
25
|
while (my ($exception,$replace_with) = each %$exceptions) { |
|
242
|
6
|
|
|
|
|
24
|
$exception_list->{$exception} = $replace_with; |
|
243
|
|
|
|
|
|
|
} |
|
244
|
6
|
|
|
|
|
13
|
return; |
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
### |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub delete_exceptions { |
|
250
|
6
|
|
|
6
|
1
|
239
|
my $self; |
|
251
|
|
|
|
|
|
|
|
|
252
|
6
|
|
|
|
|
11
|
my ($exception_list,$exceptions); |
|
253
|
6
|
50
|
|
|
|
14
|
if ($#_ == -1) { |
|
254
|
0
|
|
|
|
|
0
|
$defaults->{-exceptions} = {}; |
|
255
|
0
|
|
|
|
|
0
|
return; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
6
|
|
|
|
|
26
|
my $reference =ref $_[0]; |
|
258
|
6
|
50
|
|
|
|
24
|
if ($reference eq 'ARRAY') { |
|
|
|
100
|
|
|
|
|
|
|
259
|
0
|
|
|
|
|
0
|
($exceptions) = @_; |
|
260
|
0
|
|
|
|
|
0
|
$exception_list = $defaults->{-exceptions}; |
|
261
|
|
|
|
|
|
|
} elsif (not $reference) { |
|
262
|
3
|
|
|
|
|
7
|
$exceptions = [@_]; |
|
263
|
3
|
|
|
|
|
7
|
$exception_list = $defaults->{-exceptions}; |
|
264
|
|
|
|
|
|
|
} else { |
|
265
|
3
|
|
|
|
|
5
|
$self = shift; |
|
266
|
3
|
50
|
|
|
|
7
|
if ($#_ == -1) { |
|
267
|
0
|
|
|
|
|
0
|
$self->{'Lingua::Stem'}->{-exceptions} = {}; |
|
268
|
|
|
|
|
|
|
} else { |
|
269
|
3
|
|
|
|
|
6
|
$reference = ref $_[0]; |
|
270
|
3
|
50
|
|
|
|
6
|
if ($reference eq 'ARRAY') { |
|
271
|
0
|
|
|
|
|
0
|
($exceptions) = @_; |
|
272
|
0
|
|
|
|
|
0
|
$exception_list = $self->{'Lingua::Stem'}->{-exceptions}; |
|
273
|
|
|
|
|
|
|
} else { |
|
274
|
3
|
|
|
|
|
7
|
($exceptions) = [@_]; |
|
275
|
3
|
|
|
|
|
7
|
$exception_list = $self->{'Lingua::Stem'}->{-exceptions}; |
|
276
|
|
|
|
|
|
|
} |
|
277
|
|
|
|
|
|
|
} |
|
278
|
|
|
|
|
|
|
} |
|
279
|
|
|
|
|
|
|
|
|
280
|
6
|
|
|
|
|
10
|
foreach (@$exceptions) { delete $exception_list->{$_}; } |
|
|
6
|
|
|
|
|
13
|
|
|
281
|
6
|
|
|
|
|
17
|
return; |
|
282
|
|
|
|
|
|
|
} |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
### |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
sub get_exceptions { |
|
287
|
|
|
|
|
|
|
|
|
288
|
12
|
|
|
12
|
1
|
37
|
my $exception_list = {}; |
|
289
|
12
|
100
|
|
|
|
35
|
if ($#_ == -1) { |
|
290
|
6
|
|
|
|
|
7
|
%$exception_list = %{$defaults->{-exceptions}}; |
|
|
6
|
|
|
|
|
14
|
|
|
291
|
6
|
|
|
|
|
14
|
return $exception_list; |
|
292
|
|
|
|
|
|
|
} |
|
293
|
6
|
|
|
|
|
12
|
my $reference = ref $_[0]; |
|
294
|
6
|
50
|
|
|
|
15
|
if ($reference eq 'ARRAY') { |
|
|
|
50
|
|
|
|
|
|
|
295
|
0
|
|
|
|
|
0
|
%$exception_list = %{$defaults->{-exceptions}}; |
|
|
0
|
|
|
|
|
0
|
|
|
296
|
|
|
|
|
|
|
} elsif ($reference) { |
|
297
|
6
|
|
|
|
|
8
|
my $self = shift; |
|
298
|
6
|
50
|
|
|
|
12
|
if ($#_ > -1) { |
|
299
|
0
|
|
|
|
|
0
|
foreach (@_) { |
|
300
|
0
|
|
|
|
|
0
|
$exception_list->{$_} = $self->{'Lingua::Stem'}->{-exceptions}->{$_}; |
|
301
|
|
|
|
|
|
|
} |
|
302
|
|
|
|
|
|
|
} else { |
|
303
|
6
|
|
|
|
|
9
|
%$exception_list = %{$self->{'Lingua::Stem'}->{-exceptions}}; |
|
|
6
|
|
|
|
|
25
|
|
|
304
|
|
|
|
|
|
|
} |
|
305
|
|
|
|
|
|
|
} else { |
|
306
|
0
|
|
|
|
|
0
|
foreach (@_) { |
|
307
|
0
|
|
|
|
|
0
|
$exception_list->{$_} = $_; |
|
308
|
|
|
|
|
|
|
} |
|
309
|
|
|
|
|
|
|
} |
|
310
|
6
|
|
|
|
|
17
|
return $exception_list; |
|
311
|
|
|
|
|
|
|
} |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
#### |
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
sub stem { |
|
316
|
22
|
|
|
22
|
1
|
191
|
my $self; |
|
317
|
22
|
50
|
|
|
|
49
|
return [] if ($#_ == -1); |
|
318
|
22
|
|
|
|
|
35
|
my ($exceptions,$locale,$stemmer); |
|
319
|
22
|
100
|
|
|
|
34
|
if (ref $_[0]) { |
|
320
|
6
|
|
|
|
|
10
|
my $self = shift; |
|
321
|
6
|
|
|
|
|
8
|
$exceptions = $self->{'Lingua::Stem'}->{-exceptions}; |
|
322
|
6
|
|
|
|
|
11
|
$stemmer = $self->{'Lingua::Stem'}->{-stemmer}; |
|
323
|
6
|
|
|
|
|
11
|
$locale = $self->{'Lingua::Stem'}->{-locale}; |
|
324
|
|
|
|
|
|
|
} else { |
|
325
|
16
|
|
|
|
|
24
|
$exceptions = $defaults->{-exceptions}; |
|
326
|
16
|
|
|
|
|
19
|
$stemmer = $defaults->{-stemmer}; |
|
327
|
16
|
|
|
|
|
22
|
$locale = $defaults->{-locale}; |
|
328
|
|
|
|
|
|
|
} |
|
329
|
22
|
|
|
|
|
319
|
&$stemmer({ -words => \@_, |
|
330
|
|
|
|
|
|
|
-locale => $locale, |
|
331
|
|
|
|
|
|
|
-exceptions => $exceptions }); |
|
332
|
|
|
|
|
|
|
} |
|
333
|
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
### |
|
335
|
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
sub stem_in_place { |
|
337
|
3
|
|
|
3
|
1
|
23
|
my $self; |
|
338
|
3
|
50
|
|
|
|
8
|
return [] if ($#_ == -1); |
|
339
|
3
|
|
|
|
|
5
|
my ($exceptions,$locale,$stemmer); |
|
340
|
3
|
50
|
|
|
|
7
|
if (ref $_[0]) { |
|
341
|
0
|
|
|
|
|
0
|
my $self = shift; |
|
342
|
0
|
|
|
|
|
0
|
$exceptions = $self->{'Lingua::Stem'}->{-exceptions}; |
|
343
|
0
|
|
|
|
|
0
|
$stemmer = $self->{'Lingua::Stem'}->{-stem_in_place}; |
|
344
|
0
|
|
|
|
|
0
|
$locale = $self->{'Lingua::Stem'}->{-locale}; |
|
345
|
|
|
|
|
|
|
} else { |
|
346
|
3
|
|
|
|
|
5
|
$exceptions = $defaults->{-exceptions}; |
|
347
|
3
|
|
|
|
|
4
|
$stemmer = $defaults->{-stem_in_place}; |
|
348
|
3
|
|
|
|
|
4
|
$locale = $defaults->{-locale}; |
|
349
|
|
|
|
|
|
|
} |
|
350
|
3
|
|
|
|
|
14
|
&$stemmer({ -words => [\@_], |
|
351
|
|
|
|
|
|
|
-locale => $locale, |
|
352
|
|
|
|
|
|
|
-exceptions => $exceptions }); |
|
353
|
|
|
|
|
|
|
} |
|
354
|
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
### |
|
356
|
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
sub clear_stem_cache { |
|
358
|
0
|
|
|
0
|
1
|
|
my $clear_stem_cache_sub; |
|
359
|
0
|
0
|
|
|
|
|
if (ref $_[0]) { |
|
360
|
0
|
|
|
|
|
|
my $self = shift; |
|
361
|
0
|
|
|
|
|
|
$clear_stem_cache_sub = $self->{'Lingua::Stem'}->{-clear_stem_cache}; |
|
362
|
|
|
|
|
|
|
} else { |
|
363
|
0
|
|
|
|
|
|
$clear_stem_cache_sub = $defaults->{-clear_stem_cache}; |
|
364
|
|
|
|
|
|
|
} |
|
365
|
0
|
|
|
|
|
|
&$clear_stem_cache_sub; |
|
366
|
|
|
|
|
|
|
} |
|
367
|
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
### |
|
369
|
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
sub stem_caching { |
|
371
|
0
|
|
|
0
|
1
|
|
my $stem_caching_sub; |
|
372
|
0
|
|
|
|
|
|
my $first_parm_ref = ref $_[0]; |
|
373
|
0
|
0
|
0
|
|
|
|
if ($first_parm_ref && ($first_parm_ref ne 'HASH')) { |
|
374
|
0
|
|
|
|
|
|
my $self = shift; |
|
375
|
0
|
|
|
|
|
|
$stem_caching_sub = $self->{'Lingua::Stem'}->{-stem_caching}; |
|
376
|
|
|
|
|
|
|
} else { |
|
377
|
0
|
|
|
|
|
|
$stem_caching_sub = $defaults->{-stem_caching}; |
|
378
|
|
|
|
|
|
|
} |
|
379
|
0
|
|
|
|
|
|
&$stem_caching_sub(@_); |
|
380
|
|
|
|
|
|
|
} |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
1; |