line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::Stem::UniNE::DE; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
67023
|
use v5.8.1; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
92
|
|
4
|
2
|
|
|
2
|
|
11
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
19
|
|
5
|
2
|
|
|
2
|
|
44
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
74
|
|
6
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
62
|
|
7
|
2
|
|
|
2
|
|
938
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
309
|
|
|
2
|
|
|
|
|
15
|
|
8
|
2
|
|
|
2
|
|
948
|
use Unicode::CaseFold qw( fc ); |
|
2
|
|
|
|
|
1098
|
|
|
2
|
|
|
|
|
135
|
|
9
|
2
|
|
|
2
|
|
1083
|
use Unicode::Normalize qw( NFC ); |
|
2
|
|
|
|
|
2726
|
|
|
2
|
|
|
|
|
970
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( stem stem_de stem_aggressive stem_de_aggressive ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
*stem_de = \&stem; |
15
|
|
|
|
|
|
|
*stem_de_aggressive = \&stem_aggressive; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub stem { |
18
|
12
|
|
|
12
|
0
|
38
|
my ($word) = @_; |
19
|
|
|
|
|
|
|
|
20
|
12
|
|
|
|
|
57
|
$word = NFC fc $word; |
21
|
12
|
|
|
|
|
283
|
$word = remove_plural($word); |
22
|
|
|
|
|
|
|
|
23
|
12
|
|
|
|
|
62
|
return $word; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub stem_aggressive { |
27
|
48
|
|
|
48
|
0
|
155
|
my ($word) = @_; |
28
|
|
|
|
|
|
|
|
29
|
48
|
|
|
|
|
176
|
$word = NFC fc $word; |
30
|
48
|
|
|
|
|
614
|
$word = aggressive_diacritic($word); |
31
|
48
|
|
|
|
|
95
|
$word = aggressive_step1($word); |
32
|
48
|
|
|
|
|
100
|
$word = aggressive_step2($word); |
33
|
|
|
|
|
|
|
|
34
|
48
|
|
|
|
|
216
|
return $word; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub remove_plural { |
38
|
12
|
|
|
12
|
0
|
100
|
my ($word) = @_; |
39
|
12
|
|
|
|
|
31
|
my $length = length $word; |
40
|
|
|
|
|
|
|
|
41
|
12
|
50
|
|
|
|
37
|
return $word |
42
|
|
|
|
|
|
|
if $length < 5; |
43
|
|
|
|
|
|
|
|
44
|
12
|
|
|
|
|
29
|
$word = remove_diacritic($word); |
45
|
|
|
|
|
|
|
|
46
|
12
|
100
|
|
|
|
32
|
if ($length > 6) { |
47
|
2
|
100
|
|
|
|
20
|
return $word |
48
|
|
|
|
|
|
|
if $word =~ s{ nen $}{}x; # -nen |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
11
|
100
|
|
|
|
31
|
if ($length > 5) { |
52
|
7
|
100
|
|
|
|
57
|
return $word |
53
|
|
|
|
|
|
|
if $word =~ s{ (?: e[nrs] | se ) $}{}x; # -en -er -es -se |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
7
|
100
|
|
|
|
91
|
return $word |
57
|
|
|
|
|
|
|
if $word =~ s{ [enrs] $}{}x; # -e -n -r -s |
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
|
|
9
|
return $word; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub remove_diacritic { |
63
|
12
|
|
|
12
|
0
|
21
|
my ($word) = @_; |
64
|
|
|
|
|
|
|
|
65
|
12
|
|
|
1
|
|
51
|
$word =~ tr{äöü}{aou}; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
66
|
|
|
|
|
|
|
|
67
|
12
|
|
|
|
|
120
|
return $word; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub aggressive_diacritic { |
71
|
48
|
|
|
48
|
0
|
94
|
my ($word) = @_; |
72
|
|
|
|
|
|
|
|
73
|
48
|
|
|
|
|
99
|
for ($word) { |
74
|
|
|
|
|
|
|
#tr{áàâä}{a}; |
75
|
48
|
|
|
|
|
153
|
tr{áàâä}{a}; |
76
|
48
|
|
|
|
|
101
|
tr{íìîï}{i}; |
77
|
48
|
|
|
|
|
90
|
tr{óòôö}{o}; |
78
|
48
|
|
|
|
|
138
|
tr{úùûü}{u}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
48
|
|
|
|
|
122
|
return $word; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub aggressive_step1 { |
85
|
48
|
|
|
48
|
0
|
71
|
my ($word) = @_; |
86
|
48
|
|
|
|
|
102
|
my $length = length $word; |
87
|
|
|
|
|
|
|
|
88
|
48
|
100
|
|
|
|
120
|
if ($length > 5) { |
89
|
20
|
100
|
|
|
|
76
|
return $word |
90
|
|
|
|
|
|
|
if $word =~ s{ ern $}{}x; # -ern |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
47
|
100
|
|
|
|
90
|
if ($length > 4) { |
94
|
35
|
100
|
|
|
|
150
|
return $word |
95
|
|
|
|
|
|
|
if $word =~ s{ e[mnrs] $}{}x; # -em -en -er -es |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
41
|
100
|
|
|
|
81
|
if ($length > 3) { |
99
|
35
|
100
|
|
|
|
113
|
return $word |
100
|
|
|
|
|
|
|
if $word =~ s{ e $}{}x; # -e |
101
|
|
|
|
|
|
|
|
102
|
31
|
100
|
|
|
|
159
|
return $word |
103
|
|
|
|
|
|
|
if $word =~ s{ (?<= [bdfghklmnt] ) s $}{}x; # -s |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
27
|
|
|
|
|
78
|
return $word; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub aggressive_step2 { |
110
|
48
|
|
|
48
|
0
|
69
|
my ($word) = @_; |
111
|
48
|
|
|
|
|
70
|
my $length = length $word; |
112
|
|
|
|
|
|
|
|
113
|
48
|
100
|
|
|
|
99
|
if ($length > 5) { |
114
|
15
|
100
|
|
|
|
50
|
return $word |
115
|
|
|
|
|
|
|
if $word =~ s{ est $}{}x; # -est |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
47
|
100
|
|
|
|
98
|
if ($length > 4) { |
119
|
25
|
100
|
|
|
|
79
|
return $word |
120
|
|
|
|
|
|
|
if $word =~ s{ e[nr] $}{}x; # -en -er |
121
|
|
|
|
|
|
|
|
122
|
23
|
100
|
|
|
|
122
|
return $word |
123
|
|
|
|
|
|
|
if $word =~ s{ (?<= [bdfghklmnt] ) st $}{}x; # -st |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
35
|
|
|
|
|
83
|
return $word; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
__END__ |