line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::Stem::Snowball::Ca; |
2
|
3
|
|
|
3
|
|
202208
|
use strict; |
|
3
|
|
|
|
|
32
|
|
|
3
|
|
|
|
|
118
|
|
3
|
3
|
|
|
3
|
|
23
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
119
|
|
4
|
3
|
|
|
3
|
|
1625
|
use utf8; |
|
3
|
|
|
|
|
57
|
|
|
3
|
|
|
|
|
18
|
|
5
|
3
|
|
|
3
|
|
170
|
use 5.006002; |
|
3
|
|
|
|
|
14
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
25
|
use Carp; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
218
|
|
8
|
3
|
|
|
3
|
|
26
|
use Exporter; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
173
|
|
9
|
3
|
|
|
|
|
1908
|
use vars qw( |
10
|
|
|
|
|
|
|
$VERSION |
11
|
|
|
|
|
|
|
@ISA |
12
|
|
|
|
|
|
|
@EXPORT_OK |
13
|
|
|
|
|
|
|
$AUTOLOAD |
14
|
|
|
|
|
|
|
%EXPORT_TAGS |
15
|
|
|
|
|
|
|
$stemmifier |
16
|
|
|
|
|
|
|
%instance_vars |
17
|
3
|
|
|
3
|
|
25
|
); |
|
3
|
|
|
|
|
9
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$VERSION = '0.01'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
@ISA = qw( Exporter DynaLoader ); |
22
|
|
|
|
|
|
|
%EXPORT_TAGS = ( 'all' => [qw( stem )] ); |
23
|
|
|
|
|
|
|
@EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
require DynaLoader; |
26
|
|
|
|
|
|
|
__PACKAGE__->bootstrap($VERSION); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Ensure that C symbols are exported so that other shared libaries (e.g. |
29
|
|
|
|
|
|
|
# KinoSearch) can use them. See Dynaloader docs. |
30
|
3
|
|
|
3
|
1
|
902
|
sub dl_load_flags {0x01} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# A shared home for the actual struct sb_stemmer C modules. |
33
|
|
|
|
|
|
|
$stemmifier = Lingua::Stem::Snowball::Ca::Stemmifier->new; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
%instance_vars = ( |
36
|
|
|
|
|
|
|
lang => 'ca', |
37
|
|
|
|
|
|
|
encoding => 'UTF-8', |
38
|
|
|
|
|
|
|
locale => undef, |
39
|
|
|
|
|
|
|
stemmer_id => -1, |
40
|
|
|
|
|
|
|
strip_apostrophes => 0, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
44
|
7
|
|
|
7
|
1
|
1924
|
my $class = shift; |
45
|
7
|
|
33
|
|
|
76
|
my $self = bless { %instance_vars, @_ }, ref($class) || $class; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Get an sb_stemmer. |
48
|
7
|
|
|
|
|
72
|
$self->_derive_stemmer; |
49
|
|
|
|
|
|
|
|
50
|
7
|
|
|
|
|
27
|
return $self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub stem { |
54
|
9
|
|
|
9
|
1
|
6593
|
my ( $self, $words, $locale, $is_stemmed ); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Support lots of DWIMmery. |
57
|
9
|
100
|
|
|
|
60
|
if ( UNIVERSAL::isa( $_[0], 'HASH' ) ) { |
58
|
6
|
|
|
|
|
19
|
( $self, $words, $is_stemmed ) = @_; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
3
|
|
|
|
|
9
|
( $words, $locale, $is_stemmed ) = @_; |
62
|
3
|
|
|
|
|
15
|
$self = __PACKAGE__->new( ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Bail if there's no input. |
66
|
9
|
50
|
66
|
|
|
44
|
return undef unless ( ref($words) or length($words) ); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Duplicate the input array and transform it into an array of stems. |
69
|
9
|
100
|
|
|
|
31
|
$words = ref($words) ? $words : [$words]; |
70
|
9
|
|
|
|
|
24
|
my @stems = map {lc} @$words; |
|
12
|
|
|
|
|
42
|
|
71
|
9
|
|
|
|
|
99
|
$self->stem_in_place( \@stems ); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Determine whether any stemming took place, if requested. |
74
|
9
|
50
|
|
|
|
30
|
if ( ref($is_stemmed) ) { |
75
|
0
|
|
|
|
|
0
|
$$is_stemmed = 0; |
76
|
0
|
0
|
|
|
|
0
|
if ( $self->{stemmer_id} == -1 ) { |
77
|
0
|
|
|
|
|
0
|
$$is_stemmed = 1; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else { |
80
|
0
|
|
|
|
|
0
|
for ( 0 .. $#stems ) { |
81
|
0
|
0
|
|
|
|
0
|
next if $stems[$_] eq $words->[$_]; |
82
|
0
|
|
|
|
|
0
|
$$is_stemmed = 1; |
83
|
0
|
|
|
|
|
0
|
last; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
9
|
100
|
|
|
|
52
|
return wantarray ? @stems : $stems[0]; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |