| 1 | package Lingua::Stem::UniNE::BG; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use v5.8.1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use parent 'Exporter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Unicode::CaseFold qw( fc ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Unicode::Normalize qw( NFC ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | our @EXPORT_OK = qw( stem stem_bg ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | *stem_bg = \&stem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 24 | ▶ | sub stem { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stem: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 24 | my ($word) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 24 | $word = NFC fc $word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 24 | my $length = length $word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 24 | ▶ | return $word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | if $length < 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 24 | ▶ | if ($length > 5) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 19 | ▶ | return $word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | if $word =~ s{ ища $}{}x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 24 | $word = remove_article($word); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 24 | $word = remove_plural($word); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 24 | $length = length $word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 24 | ▶ | if ($length > 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 23 | $word =~ s{ я $}{}x; # masculine | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # normalization (e.g., -а could be a definite article or plural form) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 23 | $word =~ s{ [аео] $}{}x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 23 | $length = length $word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 24 | ▶ | if ($length > 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 11 | $word =~ s{ е (?= н $) }{}x; # -ен → -н | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 11 | $length = length $word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 24 | ▶ | if ($length > 5) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | $word =~ s{ ъ (?= \p{Cyrl} $) }{}x; # -ъ� → -� | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 24 | return $word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 24 | ▶ | sub remove_article { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_article: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 24 | my ($word) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 24 | my $length = length $word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 24 | ▶ | if ($length > 6) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # definite article with adjectives and masculine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 13 | ▶ | return $word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | if $word =~ s{ ият $}{}x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 23 | ▶ | if ($length > 5) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 18 | ▶ | return $word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | if $word =~ s{ (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ия # definite articles for nouns: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | | ът # ∙ masculine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | | та # ∙ feminine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | | то # ∙ neutral | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | | те # ∙ plural | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ) $}{}x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 14 | ▶ | if ($length > 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 12 | ▶ | return $word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | if $word =~ s{ ят $}{}x; # article for masculine | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 13 | return $word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 24 | ▶ | sub remove_plural { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_plural: called CC=13 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 24 | my ($word) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 24 | my $length = length $word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # specific plural rules for some words (masculine) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 24 | ▶ | if ($length > 6) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 8 | ▶ | return $word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$word =~ s/ \x{43e}\x{432}\x{435} $//x or $word =~ s/ \x{435}\x{432}\x{435} $/\x{439}/x or $word =~ s/ \x{43e}\x{432}\x{446}\x{438} $/\x{43e}/x
$word =~ s/ \x{43e}\x{432}\x{435} $//x or $word =~ s/ \x{435}\x{432}\x{435} $/\x{439}/x
MC/DC66%2/3
$word =~ s/ \x{43e}\x{432}\x{435} $//x or $word =~ s/ \x{435}\x{432}\x{435} $/\x{439}/x or $word =~ s/ \x{43e}\x{432}\x{446}\x{438} $/\x{43e}/x
$word =~ s/ \x{43e}\x{432}\x{435} $//x
$word =~ s/ \x{435}\x{432}\x{435} $/\x{439}/x
$word =~ s/ \x{43e}\x{432}\x{446}\x{438} $/\x{43e}/x
Truth table75%3/4
A or B or C
A= $word =~ s/ \x{43e}\x{432}\x{435} $//xB= $word =~ s/ \x{435}\x{432}\x{435} $/\x{439}/xC= $word =~ s/ \x{43e}\x{432}\x{446}\x{438} $/\x{43e}/x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | if $word =~ s{ ове $}{}x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | || $word =~ s{ еве $}{й}x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | || $word =~ s{ овци $}{о}x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 22 | ▶ | if ($length > 5) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 12 | ▶ | return $word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$word =~ s/ \x{437}\x{438} $/\x{433}/x or $word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/x or $word =~ s/ \x{446}\x{438} $/\x{43a}/x or $word =~ s/ (?: \x{442}\x{430} | \x{438}\x{449}\x{430} ) $//x
$word =~ s/ \x{437}\x{438} $/\x{433}/x or $word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/x or $word =~ s/ \x{446}\x{438} $/\x{43a}/x
$word =~ s/ \x{437}\x{438} $/\x{433}/x or $word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/x
MC/DC100%4/4
$word =~ s/ \x{437}\x{438} $/\x{433}/x or $word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/x or $word =~ s/ \x{446}\x{438} $/\x{43a}/x or $word =~ s/ (?: \x{442}\x{430} | \x{438}\x{449}\x{430} ) $//x
$word =~ s/ \x{437}\x{438} $/\x{433}/x
$word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/x
$word =~ s/ \x{446}\x{438} $/\x{43a}/x
$word =~ s/ (?: \x{442}\x{430} | \x{438}\x{449}\x{430} ) $//x
Truth table100%5/5
A or B or C or D
A= $word =~ s/ \x{437}\x{438} $/\x{433}/xB= $word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/xC= $word =~ s/ \x{446}\x{438} $/\x{43a}/xD= $word =~ s/ (?: \x{442}\x{430} | \x{438}\x{449}\x{430} ) $//x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | if $word =~ s{ зи $}{г}x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | || $word =~ s{ е ( \p{Cyrl} ) и $}{я$1}x # -е�и → -я� | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | || $word =~ s{ ци $}{к}x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | || $word =~ s{ (?: та | ища ) $}{}x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 16 | ▶ | if ($length > 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 11 | ▶ | return $word | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$word =~ s/ \x{441}\x{438} $/\x{445}/x or $word =~ s/ \x{438} $//x
MC/DC100%2/2
$word =~ s/ \x{441}\x{438} $/\x{445}/x or $word =~ s/ \x{438} $//x
$word =~ s/ \x{441}\x{438} $/\x{445}/x
$word =~ s/ \x{438} $//x
Truth table100%3/3
A or B
A= $word =~ s/ \x{441}\x{438} $/\x{445}/xB= $word =~ s/ \x{438} $//x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | if $word =~ s{ си $}{х}x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | || $word =~ s{ и $}{}x; # plural for various nouns and adjectives | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 13 | return $word; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||