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