line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::Stem::Patch::IO; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
87125
|
use v5.8.1; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
159
|
|
4
|
4
|
|
|
4
|
|
18
|
use utf8; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
24
|
|
5
|
4
|
|
|
4
|
|
83
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
132
|
|
6
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
143
|
|
7
|
4
|
|
|
4
|
|
1321
|
use parent 'Exporter'; |
|
4
|
|
|
|
|
755
|
|
|
4
|
|
|
|
|
17
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw( stem stem_io stem_aggressive stem_io_aggressive ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
*stem_io = \&stem; |
13
|
|
|
|
|
|
|
*stem_io_aggressive = \&stem_aggressive; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my %protect = ( |
16
|
|
|
|
|
|
|
root => { map { $_ => 1 } qw( |
17
|
|
|
|
|
|
|
la li me ni on vi |
18
|
|
|
|
|
|
|
) }, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub stem { |
22
|
117
|
|
|
117
|
0
|
11650
|
my $word = lc shift; |
23
|
|
|
|
|
|
|
|
24
|
117
|
|
|
|
|
161
|
for ($word) { |
25
|
|
|
|
|
|
|
# standalone roots |
26
|
117
|
100
|
|
|
|
291
|
last if $protect{root}{$word}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# nouns: -on -i -in → -o |
29
|
103
|
100
|
|
|
|
393
|
last if s{ (?: on | in? ) $}{o}x; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# remove -u from pronouns: elu ilu olu onu |
32
|
97
|
100
|
|
|
|
202
|
last if s{ (?<= ^ [eio] l | on ) u $}{}x; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# pariciple adjectives: -inta -anta -onta -ita -ata -ota → -ar |
35
|
89
|
100
|
|
|
|
180
|
last if s{ (?: [aio] n? t ) a $}{ar}x; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# verbs: -ir -or -is -as -os -us -ez → -ar |
38
|
77
|
|
|
|
|
169
|
s{ (?: [io] r | [aiou] s | ez ) $}{ar}x; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# remove -ab- from verbs |
41
|
77
|
|
|
|
|
153
|
s{ ab (?= ar $ ) }{}x; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
117
|
|
|
|
|
264
|
return $word; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub stem_aggressive { |
48
|
58
|
|
|
58
|
0
|
10250
|
my $word = stem(shift); |
49
|
|
|
|
|
|
|
|
50
|
58
|
|
|
|
|
61
|
for ($word) { |
51
|
|
|
|
|
|
|
# standalone roots |
52
|
58
|
100
|
|
|
|
99
|
last if $protect{root}{$word}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# remove final suffix |
55
|
50
|
|
|
|
|
104
|
s{ (?: [aeo] | ar ) $}{}x; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# remove -u from pronouns: elu ilu olu onu |
58
|
50
|
100
|
|
|
|
118
|
last if s{ (?<= ^ [eio] l | on ) u $}{}x; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
58
|
|
|
|
|
162
|
return $word; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |