line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::LA::Stemmer; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21436
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
628
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our %que_words = map {$_=>1} qw( atque quoque neque itaque absque apsque abusque |
7
|
|
|
|
|
|
|
adaeque adusque denique deque susque oblique peraeque plenisque |
8
|
|
|
|
|
|
|
quandoque quisque quaeque cuiusque cuique quemque quamque quaque |
9
|
|
|
|
|
|
|
quique quorumque quarumque quibusque quosque quasque quotusquisque |
10
|
|
|
|
|
|
|
quousque ubique undique usque uterque utique utroque utribique torque |
11
|
|
|
|
|
|
|
coque concoque contorque detorque decoque excoque extorque obtorque |
12
|
|
|
|
|
|
|
optorque retorque recoque attorque incoque intorque praetorque ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @noun_adj_suffix = qw( ibus ius ae am as em es ia is nt os ud um |
15
|
|
|
|
|
|
|
us a e i o u ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @verb_suffix = qw( iuntur beris erunt untur iunt mini ntur stis |
18
|
|
|
|
|
|
|
bor ero mur mus ris sti tis tur unt bo ns nt ri m r s t ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our %verb_suffix_transform_dict = qw( iuntur i erunt i untur i iunt i |
21
|
|
|
|
|
|
|
unt i beris bi bor bi bo bi ero eri ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub stem { |
24
|
1
|
50
|
|
1
|
0
|
117
|
my @words = ref($_[0]) ? @{$_[0]} : @_ ; |
|
0
|
|
|
|
|
0
|
|
25
|
1
|
|
|
|
|
2
|
my @stems; |
26
|
|
|
|
|
|
|
my $suffix; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
STEM: |
29
|
1
|
|
|
|
|
3
|
foreach my $word ( @words ){ |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# converts jv to iu |
32
|
9
|
|
|
|
|
14
|
$word =~ tr/jv/iu/; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# removes '-que' |
35
|
9
|
50
|
|
|
|
22
|
if( $word =~ /que$/o ){ |
36
|
0
|
0
|
|
|
|
0
|
if( $que_words{$word} ){ |
37
|
0
|
|
|
|
|
0
|
push @stems, $word; |
38
|
0
|
|
|
|
|
0
|
next STEM; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else{ |
41
|
0
|
|
|
|
|
0
|
$word =~ s/que$//o; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
9
|
|
|
|
|
14
|
for $suffix ( @noun_adj_suffix ){ |
46
|
125
|
100
|
|
|
|
995
|
if( $word =~ /$suffix$/ ){ |
47
|
7
|
50
|
|
|
|
18
|
if(length( $word ) - length ($suffix) >= 2){ |
48
|
7
|
|
|
|
|
57
|
$word =~ s/$suffix$//; |
49
|
7
|
|
|
|
|
21
|
push @stems, $word; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else { |
52
|
0
|
|
|
|
|
0
|
push @stems, $word; |
53
|
|
|
|
|
|
|
} |
54
|
7
|
|
|
|
|
16
|
next STEM; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
4
|
for $suffix ( @verb_suffix ){ |
59
|
50
|
100
|
|
|
|
355
|
if( $word =~ /$suffix$/ ){ |
60
|
1
|
50
|
|
|
|
10
|
if( $word =~ /$suffix$/ ){ |
61
|
1
|
|
|
|
|
7
|
foreach my $term (keys %verb_suffix_transform_dict){ |
62
|
9
|
50
|
|
|
|
85
|
if( $word =~ s/$term$/$verb_suffix_transform_dict{$term}/ ){ |
63
|
0
|
|
|
|
|
0
|
last; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
1
|
50
|
|
|
|
5
|
if(length( $word ) - length ($suffix) >= 2){ |
67
|
1
|
|
|
|
|
10
|
$word =~ s/$suffix$//; |
68
|
1
|
|
|
|
|
3
|
push @stems, $word; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
0
|
|
|
|
|
0
|
push @stems, $word; |
72
|
|
|
|
|
|
|
} |
73
|
1
|
|
|
|
|
4
|
next STEM; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
1
|
|
|
|
|
4
|
push @stems, $word; |
78
|
|
|
|
|
|
|
} |
79
|
1
|
50
|
|
|
|
14
|
wantarray ? @stems : \@stems; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
__END__ |