| 1 | package Lingua::Stem::Cistem; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | $Lingua::Stem::Cistem::VERSION = '0.08'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | @Lingua::Stem::Cistem::ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | @Lingua::Stem::Cistem::EXPORT = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | @Lingua::Stem::Cistem::EXPORT_OK = qw(stem segment stem_robust segment_robust); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | %Lingua::Stem::Cistem::EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 'all' => [qw(stem segment stem_robust segment_robust)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 'orig' => [qw(stem segment)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 'robust' => [qw(stem_robust segment_robust)], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 43 | ▶ | sub stem { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stem: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 43 | ▶ | my $word = shift // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 43 | my $case_insensitive = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 43 | my $upper = (ucfirst $word eq $word); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 43 | $word = lc($word); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 43 | $word =~ tr/äöü/aou/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 43 | $word =~ s/ß/ss/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 43 | $word =~ s/^ge(.{4,})/$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 43 | $word =~ s/sch/\$/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 43 | $word =~ s/ei/\%/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 43 | $word =~ s/ie/\&/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 43 | $word =~ s/(.)\1/$1*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 43 | ▶ | while(length($word)>3) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 28 | ▶ | if( length($word)>5 && ($word =~ s/e[mr]$// || $word =~ s/nd$//) ) {} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%4/6
length $word > 5 and $word =~ s/e[mr]$// || $word =~ s/nd$//
$word =~ s/e[mr]$// or $word =~ s/nd$//
MC/DC33%1/3
length $word > 5 and $word =~ s/e[mr]$// || $word =~ s/nd$//
length $word > 5
$word =~ s/e[mr]$//
$word =~ s/nd$//
Truth table75%3/4
A and B or C
A= length $word > 5B= $word =~ s/e[mr]$//C= $word =~ s/nd$//
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ▶ | elsif( (!($upper) || $case_insensitive) && $word =~ s/t$//) {} | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
!$upper || $case_insensitive and $word =~ s/t$//
not $upper or $case_insensitive
MC/DC100%3/3
!$upper || $case_insensitive and $word =~ s/t$//
not $upper
$case_insensitive
$word =~ s/t$//
Truth table80%4/5
not(A) or B and C
A= not $upperB= $case_insensitiveC= $word =~ s/t$//
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | elsif( $word =~ s/[esn]$//) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 17 | else { last; } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 43 | $word =~ s/(.)\*/$1$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 43 | $word =~ s/\$/sch/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 43 | $word =~ s/\%/ei/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 43 | $word =~ s/\&/ie/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 43 | return $word; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 37 | ▶ | sub segment { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
segment: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 37 | ▶ | my $word = shift // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 37 | my $case_insensitive = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 37 | my $upper = (ucfirst $word eq $word); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 37 | $word = lc($word); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 37 | my $original = $word; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 37 | $word =~ s/sch/\$/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 37 | $word =~ s/ei/\%/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 37 | $word =~ s/ie/\&/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 37 | $word =~ s/(.)\1/$1*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 37 | my $suffix_length = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 37 | ▶ | while(length($word)>3){ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 21 | ▶ | if( length($word)>5 && ($word =~ s/(e[mr])$// || $word =~ s/(nd)$//) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%4/6
length $word > 5 and $word =~ s/(e[mr])$// || $word =~ s/(nd)$//
$word =~ s/(e[mr])$// or $word =~ s/(nd)$//
MC/DC33%1/3
length $word > 5 and $word =~ s/(e[mr])$// || $word =~ s/(nd)$//
length $word > 5
$word =~ s/(e[mr])$//
$word =~ s/(nd)$//
Truth table75%3/4
A and B or C
A= length $word > 5B= $word =~ s/(e[mr])$//C= $word =~ s/(nd)$//
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 3 | $suffix_length += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ▶ | elsif( (!($upper) || $case_insensitive) && $word =~ s/t$//) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
!$upper || $case_insensitive and $word =~ s/t$//
not $upper or $case_insensitive
MC/DC66%2/3
!$upper || $case_insensitive and $word =~ s/t$//
not $upper
$case_insensitive
$word =~ s/t$//
Truth table60%3/5
not(A) or B and C
A= not $upperB= $case_insensitiveC= $word =~ s/t$//
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 5 | $suffix_length++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | elsif( $word =~ s/([esn])$//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | $suffix_length++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 10 | else{ last; } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 37 | $word =~ s/(.)\*/$1$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 37 | $word =~ s/\$/sch/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 37 | $word =~ s/\%/ei/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 37 | $word =~ s/\&/ie/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 37 | my $suffix = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 37 | ▶ | if( $suffix_length ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 11 | $suffix = substr($original, - $suffix_length); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 37 | return ($word, $suffix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 51 | ▶ | sub stem_robust { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stem_robust: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 51 | ▶ | my $word = shift // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 51 | my $case_insensitive = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 51 | my $keep_ge_prefix = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 51 | my $ucfirst = (ucfirst $word eq $word); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 51 | $word = lc($word); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 51 | $word =~ tr/äöü/aou/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 51 | $word =~ s/([aou])\N{U+0308}/$1/g; # remove U+0308 COMBINING DIAERESIS | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 51 | $word =~ s/ß/ss/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 51 | ▶ | $word =~ s/^ge(.{4,})/$1/ unless $keep_ge_prefix; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 51 | $word =~ s/sch/\N{U+0006}/g; # \N{U+0006} ACK | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 51 | $word =~ s/ei/\N{U+0007}/g; # \N{U+0007} BEL | |||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 51 | $word =~ s/ie/\N{U+0008}/g; # \N{U+0008} BS | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 51 | $word =~ s/(.)\1/$1*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 51 | my @graphemes = $word =~ m/\X/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 51 | my $length = scalar @graphemes; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | #my $length = scalar (($word =~ m/\X/g)); # does not work | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 51 | ▶ | while($length > 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 32 | ▶ | if ( $length>5 && ($word =~ s/e[mr]$// || $word =~ s/nd$//) ) {$length -= 2;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%6/6
$length > 5 and $word =~ s/e[mr]$// || $word =~ s/nd$//
$word =~ s/e[mr]$// or $word =~ s/nd$//
MC/DC100%3/3
$length > 5 and $word =~ s/e[mr]$// || $word =~ s/nd$//
$length > 5
$word =~ s/e[mr]$//
$word =~ s/nd$//
Truth table100%4/4
A and B or C
A= $length > 5B= $word =~ s/e[mr]$//C= $word =~ s/nd$//
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 5 | ▶ | elsif ( (!($ucfirst) || $case_insensitive) && $word =~ s/t$//) {$length--;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
!$ucfirst || $case_insensitive and $word =~ s/t$//
not $ucfirst or $case_insensitive
MC/DC100%3/3
!$ucfirst || $case_insensitive and $word =~ s/t$//
not $ucfirst
$case_insensitive
$word =~ s/t$//
Truth table80%4/5
not(A) or B and C
A= not $ucfirstB= $case_insensitiveC= $word =~ s/t$//
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 5 | elsif ( $word =~ s/[esn]$//) {$length--;} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 19 | else { last; } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 51 | $word =~ s/(.)\*/$1$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 51 | $word =~ s/\N{U+0006}/sch/g; # \N{U+0006} ACK | |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 51 | $word =~ s/\N{U+0007}/ei/g; # \N{U+0007} BEL | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 51 | $word =~ s/\N{U+0008}/ie/g; # \N{U+0008} BS | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 51 | return $word; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 51 | ▶ | sub segment_robust { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
segment_robust: called CC=13 SCAR=25.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 51 | ▶ | my $word = shift // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 51 | my $case_insensitive = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 51 | my $keep_ge_prefix = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 51 | my $ucfirst = (ucfirst $word eq $word); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 51 | $word = lc($word); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 51 | $word =~ tr/äöü/aou/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 51 | $word =~ s/([aou])\N{U+0308}/$1/g; # remove U+0308 COMBINING DIAERESIS | |||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 51 | $word =~ s/ß/ss/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 51 | my $prefix = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 51 | ▶ | if (!$keep_ge_prefix && $word =~ s/^ge(.{4,})/$1/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $keep_ge_prefix and $word =~ s/^ge(.{4,})/$1/
MC/DC100%2/2
not $keep_ge_prefix and $word =~ s/^ge(.{4,})/$1/
not $keep_ge_prefix
$word =~ s/^ge(.{4,})/$1/
Truth table100%3/3
not(A) and B
A= not $keep_ge_prefixB= $word =~ s/^ge(.{4,})/$1/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | $prefix = 'ge'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 51 | my $original = $word; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 51 | $word =~ s/sch/\N{U+0006}/g; # \N{U+0006} ACK | |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 51 | $word =~ s/ei/\N{U+0007}/g; # \N{U+0007} BEL | |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 51 | $word =~ s/ie/\N{U+0008}/g; # \N{U+0008} BS | |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 51 | $word =~ s/(.)\1/$1*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 51 | my @graphemes = $word =~ m/\X/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 51 | my $length = scalar @graphemes; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 51 | my $suffix_length = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 51 | ▶ | while($length > 3){ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 32 | ▶ | if( $length > 5 && ($word =~ s/(e[mr])$// || $word =~ s/(nd)$//) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%6/6
$length > 5 and $word =~ s/(e[mr])$// || $word =~ s/(nd)$//
$word =~ s/(e[mr])$// or $word =~ s/(nd)$//
MC/DC100%3/3
$length > 5 and $word =~ s/(e[mr])$// || $word =~ s/(nd)$//
$length > 5
$word =~ s/(e[mr])$//
$word =~ s/(nd)$//
Truth table100%4/4
A and B or C
A= $length > 5B= $word =~ s/(e[mr])$//C= $word =~ s/(nd)$//
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | $suffix_length += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | $length -= 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | ▶ | elsif( (!($ucfirst) || $case_insensitive) && $word =~ s/t$//) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
!$ucfirst || $case_insensitive and $word =~ s/t$//
not $ucfirst or $case_insensitive
MC/DC100%3/3
!$ucfirst || $case_insensitive and $word =~ s/t$//
not $ucfirst
$case_insensitive
$word =~ s/t$//
Truth table80%4/5
not(A) or B and C
A= not $ucfirstB= $case_insensitiveC= $word =~ s/t$//
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 5 | $suffix_length++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 5 | $length--; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | elsif( $word =~ s/([esn])$//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 5 | $suffix_length++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | $length--; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 19 | else{ last; } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 51 | $word =~ s/(.)\*/$1$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 51 | $word =~ s/\N{U+0006}/sch/g; # \N{U+0006} ACK | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 51 | $word =~ s/\N{U+0007}/ei/g; # \N{U+0007} BEL | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 51 | $word =~ s/\N{U+0008}/ie/g; # \N{U+0008} BS | |||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 51 | my $suffix = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 51 | ▶ | if( $suffix_length ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 13 | $suffix = substr($original, - $suffix_length); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 51 | return ($prefix, $word, $suffix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||