| 1 | package Lingua::IT::Ita2heb::LettersSeq; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 11 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 11 | has ita_letters => ( | |||||||||||||||||||||||||||
| 12 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||||||||||
| 13 | is => 'ro', | ||||||||||||||||||||||||||||
| 14 | traits => ['Array'], | ||||||||||||||||||||||||||||
| 15 | handles => { | ||||||||||||||||||||||||||||
| 16 | '_letter' => 'get', | ||||||||||||||||||||||||||||
| 17 | '_count' => 'count', | ||||||||||||||||||||||||||||
| 18 | }, | ||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 11 | has idx => (isa => 'Int', traits => ['Number'], is => 'rw', | |||||||||||||||||||||||||||
| 22 | handles => { add_to_idx => 'add',}, default => -1, | ||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 11 | has wrote_vowel => ( | |||||||||||||||||||||||||||
| 26 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 27 | is => 'ro', | ||||||||||||||||||||||||||||
| 28 | traits => ['Bool'], | ||||||||||||||||||||||||||||
| 29 | default => 0, | ||||||||||||||||||||||||||||
| 30 | handles => | ||||||||||||||||||||||||||||
| 31 | { | ||||||||||||||||||||||||||||
| 32 | 'set_wrote_vowel' => 'set', | ||||||||||||||||||||||||||||
| 33 | 'unset_wrote_vowel' => 'unset', | ||||||||||||||||||||||||||||
| 34 | }, | ||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 11 | has text_to_add => ( | |||||||||||||||||||||||||||
| 38 | isa => 'Str', | ||||||||||||||||||||||||||||
| 39 | is => 'ro', | ||||||||||||||||||||||||||||
| 40 | traits => ['String'], | ||||||||||||||||||||||||||||
| 41 | default => q{}, | ||||||||||||||||||||||||||||
| 42 | handles => | ||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||
| 44 | add => 'append', | ||||||||||||||||||||||||||||
| 45 | _clear_text => 'clear', | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | sub current | ||||||||||||||||||||||||||||
| 50 | 1869 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
current: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 51 | 1869 | my ($self) = @_; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 1869 | return $self->_letter($self->idx()); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 499 | ▶ | sub next_index { | ||||||||||||||||||||||||||
|
Subroutine
next_index: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 499 | my ($self) = @_; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 499 | $self->_clear_text; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 499 | ▶ | if ($self->idx() == $self->_count - 1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||
| 63 | 95 | return; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | else | ||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||
| 67 | 404 | $self->add_to_idx(1); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 404 | return $self->idx(); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 671 | ▶ | sub at_start { | ||||||||||||||||||||||||||
|
Subroutine
at_start: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 671 | my ($self) = @_; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 671 | return ($self->idx == 0); | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 460 | ▶ | sub after_start { | ||||||||||||||||||||||||||
|
Subroutine
after_start: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 80 | 460 | my ($self) = @_; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 460 | return !($self->at_start); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 1262 | ▶ | sub before_end { | ||||||||||||||||||||||||||
|
Subroutine
before_end: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 1262 | my ($self) = @_; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 1262 | return ($self->idx < ($self->_count - 1)); | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 911 | ▶ | sub at_end { | ||||||||||||||||||||||||||
|
Subroutine
at_end: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 92 | 911 | my ($self) = @_; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 911 | return (not $self->before_end); | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 977 | ▶ | sub match_places { | ||||||||||||||||||||||||||
|
Subroutine
match_places: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||
| 98 | 977 | my ($self, $start_offset, $sets_seq) = @_; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 977 | foreach my $i (0 .. $#{$sets_seq}) { | |||||||||||||||||||||||||||
| 101 | 996 | my $let_idx = $self->idx() + $start_offset + $i; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 996 | ▶ | if (($let_idx < 0) || ($let_idx >= $self->_count)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$let_idx < 0 or $let_idx >= $self->_count
MC/DC0%0/2
$let_idx < 0 or $let_idx >= $self->_count
$let_idx < 0
$let_idx >= $self->_count
Truth table33%1/3
A or B
A= $let_idx < 0B= $let_idx >= $self->_count
| |||||||||||||||||||||||||||||
| 104 | { | ||||||||||||||||||||||||||||
| 105 | 0 | die "Letter index '$let_idx' is out of range."; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 996 | ▶ | if ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | not $self->_letter($let_idx) | ||||||||||||||||||||||||||||
| 110 | 996 | ~~ @{ $sets_seq->[$i] }) | |||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||
| 112 | 542 | return; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 435 | return 1; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 1111 | ▶ | sub safe_match_places { | ||||||||||||||||||||||||||
|
Subroutine
safe_match_places: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 120 | 1111 | my ($self, $start_offset, $sets_seq) = @_; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 1111 | ▶ | if ($self->idx + $start_offset >= 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 977 | return $self->match_places($start_offset, $sets_seq); | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | else { | ||||||||||||||||||||||||||||
| 126 | 134 | return; | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 466 | ▶ | sub match_before { | ||||||||||||||||||||||||||
|
Subroutine
match_before: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 131 | 466 | my ($self, $sets_seq) = @_; | |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 466 | return $self->safe_match_places((-@$sets_seq), $sets_seq); | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 152 | ▶ | sub match_after { | ||||||||||||||||||||||||||
|
Subroutine
match_after: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 137 | 152 | my ($self, $sets_seq) = @_; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 152 | ▶ | if ($self->idx + @$sets_seq >= $self->_count) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 24 | return; | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | else { | ||||||||||||||||||||||||||||
| 143 | 128 | return $self->safe_match_places(1, $sets_seq); | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 512 | ▶ | sub curr_lett_eq_next { | ||||||||||||||||||||||||||
|
Subroutine
curr_lett_eq_next: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 148 | 512 | my ($self) = @_; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 512 | ▶ | return ($self->at_end | ||||||||||||||||||||||||||
|
Condition100%3/3
$self->at_end || $self->current eq $self->_letter($self->idx + 1)
MC/DC100%2/2
$self->at_end || $self->current eq $self->_letter($self->idx + 1)
$self->at_end
$self->current eq $self->_letter($self->idx + 1)
Truth table100%3/3
A || B
A= $self->at_endB= $self->current eq $self->_letter($self->idx + 1)
| |||||||||||||||||||||||||||||
| 151 | || ($self->current eq $self->_letter($self->idx+1))); | ||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 35 | ▶ | sub middle_at_end { | ||||||||||||||||||||||||||
|
Subroutine
middle_at_end: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 155 | 35 | my ($self) = @_; | |||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 35 | ▶ | return ($self->after_start and $self->at_end); | ||||||||||||||||||||||||||
|
Condition100%3/3
$self->after_start && $self->at_end
MC/DC100%2/2
$self->after_start && $self->at_end
$self->after_start
$self->at_end
Truth table100%3/3
A && B
A= $self->after_startB= $self->at_end
| |||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | sub add_final | ||||||||||||||||||||||||||||
| 161 | 35 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
add_final: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 162 | 35 | my $self = shift; | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 35 | my ($non_final, $final) = @_; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 35 | my $verdict = $self->middle_at_end; | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 35 | ▶ | $self->add($verdict ? $final : $non_final); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 35 | return $verdict; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 11 | 1; # End of Lingua::IT::Ita2heb::LettersSeq | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | __END__ | ||||||||||||||||||||||||||||