line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::Stem::UniNE::BG; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
41083
|
use v5.8.1; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
94
|
|
4
|
2
|
|
|
2
|
|
11
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
17
|
|
5
|
2
|
|
|
2
|
|
48
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
72
|
|
6
|
2
|
|
|
2
|
|
54
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
65
|
|
7
|
2
|
|
|
2
|
|
1013
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
307
|
|
|
2
|
|
|
|
|
12
|
|
8
|
2
|
|
|
2
|
|
1037
|
use Unicode::CaseFold qw( fc ); |
|
2
|
|
|
|
|
1139
|
|
|
2
|
|
|
|
|
149
|
|
9
|
2
|
|
|
2
|
|
1163
|
use Unicode::Normalize qw( NFC ); |
|
2
|
|
|
|
|
2788
|
|
|
2
|
|
|
|
|
777
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( stem stem_bg ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
*stem_bg = \&stem; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub stem { |
17
|
24
|
|
|
24
|
0
|
548
|
my ($word) = @_; |
18
|
|
|
|
|
|
|
|
19
|
24
|
|
|
|
|
86
|
$word = NFC fc $word; |
20
|
|
|
|
|
|
|
|
21
|
24
|
|
|
|
|
7224
|
my $length = length $word; |
22
|
|
|
|
|
|
|
|
23
|
24
|
50
|
|
|
|
73
|
return $word |
24
|
|
|
|
|
|
|
if $length < 4; |
25
|
|
|
|
|
|
|
|
26
|
24
|
100
|
|
|
|
58
|
if ($length > 5) { |
27
|
19
|
50
|
|
|
|
66
|
return $word |
28
|
|
|
|
|
|
|
if $word =~ s{ ища $}{}x; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
24
|
|
|
|
|
56
|
$word = remove_article($word); |
32
|
24
|
|
|
|
|
57
|
$word = remove_plural($word); |
33
|
24
|
|
|
|
|
37
|
$length = length $word; |
34
|
|
|
|
|
|
|
|
35
|
24
|
100
|
|
|
|
51
|
if ($length > 3) { |
36
|
23
|
|
|
|
|
41
|
$word =~ s{ я $}{}x; # masculine |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# normalization (e.g., -а could be a definite article or plural form) |
39
|
23
|
|
|
|
|
87
|
$word =~ s{ [аео] $}{}x; |
40
|
|
|
|
|
|
|
|
41
|
23
|
|
|
|
|
63
|
$length = length $word; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
24
|
100
|
|
|
|
992
|
if ($length > 4) { |
45
|
11
|
|
|
|
|
32
|
$word =~ s{ е (?= н $) }{}x; # -ен → -н |
46
|
|
|
|
|
|
|
|
47
|
11
|
|
|
|
|
14
|
$length = length $word; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
24
|
100
|
|
|
|
43
|
if ($length > 5) { |
51
|
6
|
|
|
1
|
|
24
|
$word =~ s{ ъ (?= \p{Cyrl} $) }{}x; # -ъ� → -� |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
15
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
24
|
|
|
|
|
122
|
return $word; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub remove_article { |
58
|
24
|
|
|
24
|
0
|
41
|
my ($word) = @_; |
59
|
24
|
|
|
|
|
44
|
my $length = length $word; |
60
|
|
|
|
|
|
|
|
61
|
24
|
100
|
|
|
|
51
|
if ($length > 6) { |
62
|
|
|
|
|
|
|
# definite article with adjectives and masculine |
63
|
13
|
100
|
|
|
|
35
|
return $word |
64
|
|
|
|
|
|
|
if $word =~ s{ ият $}{}x; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
23
|
100
|
|
|
|
56
|
if ($length > 5) { |
68
|
18
|
100
|
|
|
|
123
|
return $word |
69
|
|
|
|
|
|
|
if $word =~ s{ (?: |
70
|
|
|
|
|
|
|
ия # definite articles for nouns: |
71
|
|
|
|
|
|
|
| ът # ∙ masculine |
72
|
|
|
|
|
|
|
| та # ∙ feminine |
73
|
|
|
|
|
|
|
| то # ∙ neutral |
74
|
|
|
|
|
|
|
| те # ∙ plural |
75
|
|
|
|
|
|
|
) $}{}x; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
14
|
100
|
|
|
|
38
|
if ($length > 4) { |
79
|
12
|
100
|
|
|
|
34
|
return $word |
80
|
|
|
|
|
|
|
if $word =~ s{ ят $}{}x; # article for masculine |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
13
|
|
|
|
|
34
|
return $word; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub remove_plural { |
87
|
24
|
|
|
24
|
0
|
33
|
my ($word) = @_; |
88
|
24
|
|
|
|
|
68
|
my $length = length $word; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# specific plural rules for some words (masculine) |
91
|
24
|
100
|
|
|
|
50
|
if ($length > 6) { |
92
|
8
|
100
|
66
|
|
|
70
|
return $word |
|
|
|
100
|
|
|
|
|
93
|
|
|
|
|
|
|
if $word =~ s{ ове $}{}x |
94
|
|
|
|
|
|
|
|| $word =~ s{ еве $}{й}x |
95
|
|
|
|
|
|
|
|| $word =~ s{ овци $}{о}x; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
22
|
100
|
|
|
|
42
|
if ($length > 5) { |
99
|
12
|
100
|
100
|
|
|
160
|
return $word |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
100
|
|
|
|
|
|
|
if $word =~ s{ зи $}{г}x |
101
|
|
|
|
|
|
|
|| $word =~ s{ е ( \p{Cyrl} ) и $}{я$1}x # -е�и → -я� |
102
|
|
|
|
|
|
|
|| $word =~ s{ ци $}{к}x |
103
|
|
|
|
|
|
|
|| $word =~ s{ (?: та | ища ) $}{}x; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
16
|
100
|
|
|
|
38
|
if ($length > 4) { |
107
|
11
|
100
|
100
|
|
|
71
|
return $word |
108
|
|
|
|
|
|
|
if $word =~ s{ си $}{х}x |
109
|
|
|
|
|
|
|
|| $word =~ s{ и $}{}x; # plural for various nouns and adjectives |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
13
|
|
|
|
|
33
|
return $word; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
__END__ |