← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 11:58:52 2013
Reported on Tue Oct 15 12:02:23 2013

Filename/usr/share/perl5/Lingua/Stem.pm
StatementsExecuted 14 statements in 3.30ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.34ms2.88msLingua::Stem::::BEGIN@7Lingua::Stem::BEGIN@7
11152µs52µsLingua::Stem::::BEGIN@9Lingua::Stem::BEGIN@9
11132µs40µsLingua::Stem::::BEGIN@5Lingua::Stem::BEGIN@5
0000s0sLingua::Stem::::__ANON__[:104]Lingua::Stem::__ANON__[:104]
0000s0sLingua::Stem::::__ANON__[:110]Lingua::Stem::__ANON__[:110]
0000s0sLingua::Stem::::__ANON__[:116]Lingua::Stem::__ANON__[:116]
0000s0sLingua::Stem::::__ANON__[:122]Lingua::Stem::__ANON__[:122]
0000s0sLingua::Stem::::__ANON__[:128]Lingua::Stem::__ANON__[:128]
0000s0sLingua::Stem::::__ANON__[:34]Lingua::Stem::__ANON__[:34]
0000s0sLingua::Stem::::__ANON__[:39]Lingua::Stem::__ANON__[:39]
0000s0sLingua::Stem::::__ANON__[:69]Lingua::Stem::__ANON__[:69]
0000s0sLingua::Stem::::__ANON__[:74]Lingua::Stem::__ANON__[:74]
0000s0sLingua::Stem::::__ANON__[:79]Lingua::Stem::__ANON__[:79]
0000s0sLingua::Stem::::__ANON__[:84]Lingua::Stem::__ANON__[:84]
0000s0sLingua::Stem::::__ANON__[:89]Lingua::Stem::__ANON__[:89]
0000s0sLingua::Stem::::__ANON__[:94]Lingua::Stem::__ANON__[:94]
0000s0sLingua::Stem::::__ANON__[:99]Lingua::Stem::__ANON__[:99]
0000s0sLingua::Stem::::add_exceptionsLingua::Stem::add_exceptions
0000s0sLingua::Stem::::clear_stem_cacheLingua::Stem::clear_stem_cache
0000s0sLingua::Stem::::delete_exceptionsLingua::Stem::delete_exceptions
0000s0sLingua::Stem::::get_exceptionsLingua::Stem::get_exceptions
0000s0sLingua::Stem::::get_localeLingua::Stem::get_locale
0000s0sLingua::Stem::::newLingua::Stem::new
0000s0sLingua::Stem::::set_localeLingua::Stem::set_locale
0000s0sLingua::Stem::::stemLingua::Stem::stem
0000s0sLingua::Stem::::stem_cachingLingua::Stem::stem_caching
0000s0sLingua::Stem::::stem_in_placeLingua::Stem::stem_in_place
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Lingua::Stem;
2
3# $RCSfile: Stem.pm,v $ $Revision: 1.2 $ $Date: 1999/06/16 17:45:28 $ $Author: snowhare $
4
5345µs249µ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
use strict;
# spent 40µs making 1 call to Lingua::Stem::BEGIN@5 # spent 8µs making 1 call to strict::import
612µsrequire Exporter;
73294µs12.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
use Lingua::Stem::AutoLoader;
# 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
BEGIN {
1011µs $Lingua::Stem::VERSION = '0.84';
11120µs @Lingua::Stem::ISA = qw (Exporter);
121700ns @Lingua::Stem::EXPORT = ();
1314µ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);
14129µ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 );
2112.59ms152µs}
# spent 52µs making 1 call to Lingua::Stem::BEGIN@9
22
23my $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 },
1311264µs};
132
133###
134
135sub 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
181sub 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
214sub 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
226sub 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
250sub 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
287sub 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
316sub 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
337sub 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
358sub 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
371sub 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
383154µs1;