blib/lib/Lingua/Zompist/Kebreni.pm

filter: Statementstmt 83.6% 220 / 263 Branchbran 63.1% 77 / 122 Conditioncond 57.5% 46 / 80 MC/DCmcdc 9.8% 5 / 51 Subroutinesub 97.3% 36 / 37 Podpod 69.5% 16 / 23 totaltotal 69.4% 400 / 576 CC 90 SCAR 23.5
CC
90
Cov
74%
benefactive
25.3
antiben
25.3
volitional
13.0
CRAP 10.5
↑ Summary
1 package Lingua::Zompist::Kebreni;
2  
3 2 require 5.005;
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 # use warnings;
6 2 $^W = 1;
7 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 require Exporter;
10  
11 2 ▶use vars qw($VERSION @ISA @EXPORT_OK @EXPORT %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 $VERSION = '0.90';
14  
15 2 @ISA = qw(Exporter);
16  
17 2 ▶use overload '""' => 'to_string',
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1262 ▶ 'eq' => sub { $_[0]->to_string eq $_[1] }
Subroutine __ANON__: called CC=1 SCAR=0.0
19 2 ;
20  
21 2 ▶use constant BENEFACTIVE => 00001;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶use constant ANTIBEN => 00002;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use constant VOLITIONAL => 00004;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶use constant PERFECTIVE => 00010;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 ▶use constant DIR2 => 00020;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 2 ▶use constant POLITE => 00040;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 2 ▶use constant SUBORDINATE => 00100;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 2 ▶use constant SUPPLETIVE => 00200;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 2 ▶use constant MADE_POLITE => 00400;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 2 %EXPORT_TAGS = ( 'flags' => [ qw(
32 &BENEFACTIVE
33 &ANTIBEN
34 &VOLITIONAL
35 &PERFECTIVE
36 &DIR3
37 &POLITE
38 &SUBORDINATE
39 &SUPPLETIVE
40 &MADE_POLITE
41 ) ] );
42 2 $EXPORT_TAGS{'all'} = $EXPORT_TAGS{'flags'};
43  
44 2 @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
45  
46 2 @EXPORT = ();
47  
48  
49 # Constructor. This takes a string and returns a Lingua::Zompist::Kebreni
50 # object (which is currently represented internally as an hashref).
51 # Key 'word' is the decomposed form as an arrayref, key 'base' is the
52 # word in Latin script, and key 'suppletive' is 0 or 1, depending on
53 # whether the verb currently stores a suppletive polite form.
54 56 ▶sub new {
Subroutine new: called CC=6 SCAR=18.2
Pod documented
55 56 my $self = shift;
56 56 ▶ my $class = ref($self) || $self;
Condition66%2/3
ref $self || $self
l!l&&r!l&&!r
40160
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table66%2/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
57 56 my $word;
58 my $base;
59 56 my $flags;
60  
61 56 ▶ if(ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 40 16 56
62 40 $flags = $self->flags;
63 40 $word = decompose($base = shift);
64 40 ▶ if(@_) { $flags |= shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 40 0 40
65 40 ▶ if(@_) { $base = shift; } # override base for e.g. polite suppletives
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 40 0 40
66 } else {
67 16 $word = decompose($base = shift);
68 16 ▶ $flags = shift || 0;
Condition50%1/2
shift() || 0
l!l
016
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
69 }
70  
71 56 return bless {
72 word => $word,
73 base => $base,
74 flags => $flags,
75 }, $class;
76 }
77  
78  
79 # return the base word
80 5199 ▶sub base {
Subroutine base: called CC=1 SCAR=0.0
Pod documented
81 5199 my $self = shift;
82  
83 5199 return $self->{base};
84 }
85  
86  
87 # return the flags
88 3995 ▶sub flags {
Subroutine flags: called CC=1 SCAR=0.0
Pod documented
89 3995 my $self = shift;
90  
91 3995 return $self->{flags};
92 }
93  
94  
95 # String representation
96 2507 ▶sub to_string {
Subroutine to_string: called CC=1 SCAR=0.0
Pod undocumented
97 2507 my $self = shift;
98  
99 # carp "to_string called";
100  
101 # return $self->recompose;
102  
103 2507 return recompose($self->{word});
104 }
105  
106  
107 # Null operation
108 17 ▶sub null {
Subroutine null: called CC=1 SCAR=0.0
Pod documented
109 17 return $_[0];
110 }
111  
112  
113  
114  
115 # ========================================================
116 # Verb stuff
117 # Might factor this out into another package some day
118  
119 # Kebreni vowels
120 2 my %v = map { $_ => 1 } qw(i y u
121 e o
122 a );
123  
124 # Kebreni consonants
125 2 my %c = map { $_ => 1 } qw(p t c k
126 b d g
127 f th s h' s' h
128 v z z'
129 m n ng
130 l r );
131  
132 # Voiced versions of consonants
133 2 my %voice = ( 'p' => 'b',
134 't' => 'd',
135 'k' => 'g',
136 's' => 'z',
137 "s'" => "z'",
138 );
139  
140 # Fronted versions of vowels
141 2 my %front = ( 'a' => 'e',
142 'o' => 'e',
143 'u' => 'y',
144 'y' => 'i',
145 'i' => 'e',
146 'e' => 'e',
147 );
148  
149 # Backed versions of vowels
150 2 my %back = ( 'a' => 'o',
151 'e' => 'o',
152 'i' => 'y',
153 'y' => 'u',
154 'u' => 'o',
155 'o' => 'o',
156 );
157  
158 # Consonant changes in the subordinating form
159 2 my %subord= ( 'm' => 'n', # labials become dentals
160 'b' => 't', # b -> d -> t; might as well do it in one step
161 'p' => 't',
162 'd' => 't', # stops become unvoiced
163 'g' => 'k',
164 'z' => 's',
165 "z'" => "s'",
166 );
167  
168 # Raised version of the vowels
169 2 my %raise = ( 'a' => 'e',
170 'e' => 'i',
171 'o' => 'u',
172 'y' => 'y',
173 'i' => 'i',
174 'u' => 'u',
175 );
176  
177 # Lowered versions of the vowels
178 2 my %lower = ( 'i' => 'e',
179 'y' => 'e',
180 'e' => 'a',
181 'o' => 'a',
182 'u' => 'o',
183 'a' => 'a',
184 );
185  
186  
187  
188 # decompose a word into phonemes
189 # turns a word into an arrayref; the elements are vowels and consonants
190 # or consonant clusters.
191 # consonant clusters are represented by arrayrefs containing consonants
192 # as elements; other sounds are represented by themselves.
193 # # Returns a Lingua::Zompist::Kebreni::Verb object
194 # sub new ($) {
195 56 ▶sub decompose {
Subroutine decompose: called CC=7 SCAR=19.5
Pod undocumented
196 # my $self = shift;
197 # my $class = ref($self) || $self;
198 56 my $word = shift;
199  
200 # split up -- first try two-letter phonemes, then one-letter ones
201 56 my @phonemes = $word =~ /(th|s'|z'|h'|ng|[ptckiyubdgfsheovzmnalr])/g;
202  
203 # merge consonant clusters
204 56 my $i = 0;
205 56 ▶ while($i <= $#phonemes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#phonemes) 227 56 283
206 227 ▶ if($c{$phonemes[$i]} && $i < $#phonemes && $c{$phonemes[$i+1]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c{$phonemes[$i]} and $i < $#phonemes and $c{$phonemes[$i + 1]}) 4 223 227
Condition83%5/6
$c{$phonemes[$i]} and $i < $#phonemes and $c{$phonemes[$i + 1]}
!ll&&!rl&&r
1141094
$c{$phonemes[$i]} and $i < $#phonemes
!ll&&!rl&&r
1140113
MC/DC66%2/3
$c{$phonemes[$i]} and $i < $#phonemes and $c{$phonemes[$i + 1]}
$c{$phonemes[$i]} $i < $#phonemes $c{$phonemes[$i + 1]}
Truth table75%3/4
A and B and C
A= $c{$phonemes[$i]}B= $i < $#phonemesC= $c{$phonemes[$i + 1]}
ABCresult
0XX0
10X0
1100
1111
207 4 $phonemes[$i] = [ $phonemes[$i] ];
208 4 my $j = $i+1;
209 4 ▶ while($j <= $#phonemes && $c{$phonemes[$j]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $#phonemes and $c{$phonemes[$j]}) 4 4 8
Condition66%2/3
$j <= $#phonemes and $c{$phonemes[$j]}
!ll&&!rl&&r
044
MC/DC50%1/2
$j <= $#phonemes and $c{$phonemes[$j]}
$j <= $#phonemes $c{$phonemes[$j]}
Truth table66%2/3
A and B
A= $j <= $#phonemesB= $c{$phonemes[$j]}
ABresult
0X0
100
111
210 4 push @{ $phonemes[$i] }, $phonemes[$j];
211 4 $j++;
212 }
213 4 splice @phonemes, $i+1, $j-$i-1;
214 }
215 227 $i++;
216 }
217  
218 # return bless \@phonemes, $class;
219 56 return \@phonemes;
220 }
221  
222  
223 # make a copy of a word
224 4122 ▶sub copy ($) {
Subroutine copy: called CC=2 SCAR=6.9
Pod undocumented
225 # the data structure will only ever be two levels deep
226 4122 ▶ return [ map { ref $_ ? [ @$_ ] : $_ } @{$_[0]} ];
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 1115 19187 20302
227 }
228  
229  
230 # make a copy of a word
231 3915 ▶sub clone {
Subroutine clone: called CC=2 SCAR=8.1
Pod undocumented
232 3915 my $self = shift;
233  
234 # return bless copy($self), (ref($self) || $self);
235 return bless {
236 3915 ▶ word => copy($self->{word}),
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
391500
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
237 flags => $self->flags,
238 base => $self->base,
239 }, (ref($self) || $self);
240 }
241  
242  
243 # decompose consonant clusters by adding something in the middle
244 # takes three parameter: the word (an arrayref), the position of the
245 # consonant cluster (e.g. -2), and the something to add (usually a
246 # vowel). This will raise the cluster from an arrayref to a normal array
247 # element status.
248 # However, if the cluster had more than two consonants, only the last
249 # consonant is un-clustered.
250 # # This subroutine should not have to be called from outside the
251 # # Lingua::Zompist::Kebreni::Verb package
252 207 ▶sub add ($$@) {
Subroutine add: called CC=5 SCAR=19.8
Pod undocumented
253 207 my($word, $position, @newstuff) = @_;
254  
255 207 ▶ return $word unless ref $word->[$position];
Branch: 1 branch
BranchTrueFalseTotal
unless ref $word->[$position] 0 207 207
256  
257 # Make a copy
258 207 $word = copy $word;
259  
260 207 ▶ $position = @$word + $position if $position < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $position < 0 207 0 207
261  
262 207 ▶ if(@{$word->[$position]} == 2) {
Branch: 2 branches
BranchTrueFalseTotal
if (@{$word->[$position];} == 2) { } 207 0 207
elsif (@{$word->[$position];} > 2) { } 0 0 0
263 207 splice @$word, $position, 1, $word->[$position]->[0], @newstuff, $word->[$position]->[1];
264 0 } elsif(@{$word->[$position]} > 2) {
265 0 my $lastcons = splice @{$word->[$position]}, -1, 1;
266 0 splice @$word, $position+1, 0, @newstuff, $lastcons;
267 }
268  
269 207 return $word;
270 }
271  
272  
273 # recompose a word out of the arrayref structure
274 2507 ▶sub recompose ($) {
Subroutine recompose: called CC=2 SCAR=6.9
Pod undocumented
275 # maximum depth is two levels
276 2507 ▶ return join '', map { ref $_ ? @$_ : $_ } @{$_[0]};
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 461 14260 14721
277 }
278  
279  
280 # dump a word from the arrayref form
281 0 ▶sub dumpword ($) {
Subroutine dumpword: not called CC=2 SCAR=17.9
Pod undocumented
282 0 ▶ return join '', map { ref $_ ? '[' . join('',@$_) . ']' : $_ } @{$_[0]};
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 0 0 0
283 }
284  
285  
286 # form the perfective of a word. Expect the arrayref form.
287 601 ▶sub perfective ($) {
Subroutine perfective: called CC=5 SCAR=19.3
Pod documented
288 601 my $self = shift->clone;
289 601 my $word = $self->{word};
290  
291 601 ▶ if($self->{flags} & POLITE) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'flags'} & 32) { } 0 601 601
elsif ($self->{'flags'} & 64) { } 0 601 601
292 0 croak "Can't make a polite form perfective";
293 } elsif($self->{flags} & SUBORDINATE) {
294 0 croak "Can't make a subordinate form perfective";
295 }
296  
297 601 ▶ unless($v{$word->[-1]} && $v{$word->[-3]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v{$word->[-1]} and $v{$word->[-3]}) 0 601 601
Condition33%1/3
$v{$word->[-1]} and $v{$word->[-3]}
!ll&&!rl&&r
00601
MC/DC0%0/2
$v{$word->[-1]} and $v{$word->[-3]}
$v{$word->[-1]} $v{$word->[-3]}
Truth table33%1/3
A and B
A= $v{$word->[-1]}B= $v{$word->[-3]}
ABresult
0X0
100
111
298 0 croak "Funny word '" . dumpword($word) . "' does not have vowels in positions -3 and -1!";
299 }
300  
301 # swap last two vowels
302 601 ($word->[-1], $word->[-3]) = ($word->[-3], $word->[-1]);
303  
304 601 $self->{flags} |= PERFECTIVE;
305  
306 601 return $self;
307 }
308  
309  
310 # form the volitional of a word. Expect the arrayref form.
311 601 ▶sub volitional ($) {
Subroutine volitional: called CC=11 SCAR=25.7
Pod documented
312 601 my $self = shift->clone;
313 601 my $word = $self->{word};
314  
315 601 ▶ if($self->{flags} & PERFECTIVE) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'flags'} & 8) { } 0 601 601
elsif ($self->{'flags'} & 32) { } 0 601 601
elsif ($self->{'flags'} & 64) { } 0 601 601
316 0 croak "Can't make a perfective form volitional";
317 } elsif($self->{flags} & POLITE) {
318 0 croak "Can't make a polite form volitional";
319 } elsif($self->{flags} & SUBORDINATE) {
320 0 croak "Can't make a subordinate form perfective";
321 }
322  
323 # vowel-initial verbs form the volitional as if they had initial 'h'
324 # see http://www.zompist.com/board/messages/94.html
325 # es'u, however, adds 'v' for hysterical raisins
326 # XXX TODO FIXME
327 601 ▶ if($self->base eq "es'u" && !($self->flags & MADE_POLITE)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->base eq q[es'u] and not $self->flags & 256) { } 2 599 601
elsif ($v{$word->[0]}) { } 18 581 599
Condition100%3/3
$self->base eq "es'u" and not $self->flags & 256
!ll&&!rl&&r
561382
MC/DC100%2/2
$self->base eq "es'u" and not $self->flags & 256
$self->base eq "es'u" not $self->flags & 256
Truth table100%3/3
A and not(B)
A= $self->base eq "es'u"B= not $self->flags & 256
ABresult
0X0
100
111
328 2 unshift @$word, 'v';
329 } elsif($v{$word->[0]}) {
330 18 unshift @$word, 'h';
331 }
332  
333 # voice the initial consonant
334 601 ▶ $word->[0] = $voice{$word->[0]} if exists $voice{$word->[0]};
Branch: 1 branch
BranchTrueFalseTotal
if exists $voice{$word->[0]} 441 160 601
335  
336 # add an inital e
337 601 unshift @$word, 'e';
338  
339 # switch the first two vowels
340 601 ▶ unless($v{$word->[0]} && $v{$word->[2]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v{$word->[0]} and $v{$word->[2]}) 0 601 601
Condition33%1/3
$v{$word->[0]} and $v{$word->[2]}
!ll&&!rl&&r
00601
MC/DC0%0/2
$v{$word->[0]} and $v{$word->[2]}
$v{$word->[0]} $v{$word->[2]}
Truth table33%1/3
A and B
A= $v{$word->[0]}B= $v{$word->[2]}
ABresult
0X0
100
111
341 0 croak "Funny word '" . dumpword($word) . "' does not have vowels in positions 0 and 2!";
342 }
343 601 ($word->[0], $word->[2]) = ($word->[2], $word->[0]);
344  
345 # final -y becomes -u
346 601 ▶ $word->[-1] = 'u' if $word->[-1] eq 'y';
Branch: 1 branch
BranchTrueFalseTotal
if $word->[-1] eq "y" 24 577 601
347  
348 601 $self->{flags} |= VOLITIONAL;
349  
350 601 return $self;
351 }
352  
353  
354 # Exceptions with separate polite stems
355 # XXX FIXME TODO
356 2 my %polite = ( 'badu' => "seh'epu",
357 'tasu' => 'soru',
358 "es'u" => 'natu',
359 );
360  
361  
362 # form the polite stem
363 602 ▶sub make_polite {
Subroutine make_polite: called CC=2 SCAR=6.9
Pod documented
364 602 my $self = shift;
365  
366 602 $self->{flags} |= MADE_POLITE;
367  
368 602 ▶ if($polite{$self->base}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($polite{$self->base}) { } 40 562 602
369 40 return $self->new($polite{$self->base}, SUPPLETIVE, $self->base);
370 } else {
371 562 return $self;
372 }
373 }
374  
375  
376 # form the polite form of a word.
377 601 ▶sub polite ($$) {
Subroutine polite: called CC=10 SCAR=25.2
Pod documented
378 601 my $self = shift->clone;
379 601 my $word = $self->{word};
380  
381 601 ▶ if($self->{flags} & SUBORDINATE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"flags"} & 64) 0 601 601
382 0 croak "Can't make a subordinate form polite";
383 }
384 601 ▶ unless($self->{flags} & MADE_POLITE) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"flags"} & 256) 0 601 601
385 0 croak "Verb must be prepared with ->make_polite before calling ->polite";
386 }
387  
388 601 $self->{flags} |= POLITE;
389  
390 # If the form is a suppletive, don't insert -ri-/-ry-.
391 601 ▶ return $self if $self->{flags} & SUPPLETIVE;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"flags"} & 128 40 561 601
392  
393 # insert -ri- before the last consonant or -ry- if the vowel in the next
394 # syllable is a _u_.
395 561 ▶ my @insert = ($word->[-1] eq 'u' ? ('r', 'y') : ('r', 'i'));
Branch: 1 branch
BranchTrueFalseTotal
$word->[-1] eq 'u' ? : 69 492 561
396  
397 # check for -VCV
398 561 ▶ unless($v{$word->[-1]} && $v{$word->[-3]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v{$word->[-1]} and $v{$word->[-3]}) 0 561 561
Condition33%1/3
$v{$word->[-1]} and $v{$word->[-3]}
!ll&&!rl&&r
00561
MC/DC0%0/2
$v{$word->[-1]} and $v{$word->[-3]}
$v{$word->[-1]} $v{$word->[-3]}
Truth table33%1/3
A and B
A= $v{$word->[-1]}B= $v{$word->[-3]}
ABresult
0X0
100
111
399 0 croak "Funny word '" . dumpword($word) . "' does not have vowels in positions -3 and -1!";
400 }
401 561 ▶ unless(ref $word->[-2] or $c{$word->[-2]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $word->[-2] or $c{$word->[-2]}) 0 561 561
Condition66%2/3
ref $word->[-2] or $c{$word->[-2]}
l!l&&r!l&&!r
724890
MC/DC0%0/2
ref $word->[-2] or $c{$word->[-2]}
ref $word->[-2] $c{$word->[-2]}
Truth table66%2/3
A or B
A= ref $word->[-2]B= $c{$word->[-2]}
ABresult
1X1
011
000
402 0 croak "Funny word '" . dumpword($word) . "' does not have a consonant in position -2!";
403 }
404  
405 # is the last consonant a cluster? if so, use add(), otherwise just
406 # splice right in
407 561 ▶ if(ref $word->[-2]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $word->[-2]) { } 72 489 561
408 72 $word = add $word, -2, @insert;
409 72 $self->{word} = $word;
410 } else {
411 489 splice @$word, -2, 0, @insert;
412 }
413  
414 561 return $self;
415 }
416  
417  
418 # form the benefactive of a word
419 483 ▶sub benefactive ($) {
Subroutine benefactive: called CC=12 SCAR=32.3
Pod documented
420 483 my $self = shift->clone;
421 483 my $word = $self->{word};
422  
423 483 ▶ if($self->{flags} & ANTIBEN) {
Branch: 5 branches
BranchTrueFalseTotal
if ($self->{'flags'} & 2) { } 0 483 483
elsif ($self->{'flags'} & 4) { } 0 483 483
elsif ($self->{'flags'} & 8) { } 0 483 483
elsif ($self->{'flags'} & 32) { } 0 483 483
elsif ($self->{'flags'} & 64) { } 0 483 483
424 0 croak "Can't make an antibenefactive from benefactive";
425 } elsif($self->{flags} & VOLITIONAL) {
426 0 croak "Can't make a volitional form benefactive";
427 } elsif($self->{flags} & PERFECTIVE) {
428 0 croak "Can't make a perfective form benefactive";
429 } elsif($self->{flags} & POLITE) {
430 0 croak "Can't make a polite form benefactive";
431 } elsif($self->{flags} & SUBORDINATE) {
432 0 croak "Can't make a subordinate form benefactive";
433 }
434  
435 # check for -VC[uy]
436 483 ▶ unless($v{$word->[-1]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v{$word->[-1]}) 0 483 483
437 0 croak "Funny word '" . dumpword($word) . "' does not have a vowel in position -3!";
438 }
439 483 ▶ unless(ref $word->[-2] or $c{$word->[-2]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $word->[-2] or $c{$word->[-2]}) 0 483 483
Condition66%2/3
ref $word->[-2] or $c{$word->[-2]}
l!l&&r!l&&!r
963870
MC/DC0%0/2
ref $word->[-2] or $c{$word->[-2]}
ref $word->[-2] $c{$word->[-2]}
Truth table66%2/3
A or B
A= ref $word->[-2]B= $c{$word->[-2]}
ABresult
1X1
011
000
440 0 croak "Funny word '" . dumpword($word) . "' does not have a consonant in position -2!";
441 }
442 483 ▶ unless($word->[-1] eq 'u' or $word->[-1] eq 'y') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($word->[-1] eq "u" or $word->[-1] eq "y") 0 483 483
Condition66%2/3
$word->[-1] eq "u" or $word->[-1] eq "y"
l!l&&r!l&&!r
387960
MC/DC0%0/2
$word->[-1] eq "u" or $word->[-1] eq "y"
$word->[-1] eq "u" $word->[-1] eq "y"
Truth table66%2/3
A or B
A= $word->[-1] eq "u"B= $word->[-1] eq "y"
ABresult
1X1
011
000
443 0 croak "Funny word '" . dumpword($word) . "' does not end in -u or -y!";
444 }
445  
446 # front the stem vowel
447 # that's the last vowel of the root, according to
448 # http://www.zompist.com/board/messages/94.html
449 483 ▶ $word->[-3] = $front{$word->[-3]} || '???';
Condition50%1/2
$front{$word->[-3]} || '???'
l!l
4830
MC/DC0%0/1
$front{$word->[-3]} || '???'
$front{$word->[-3]}
Truth table50%1/2
A
A= $front{$word->[-3]}
Aresult
11
00
450  
451 # Change the final -u (or -y!) to -i
452 483 $word->[-1] = 'i';
453  
454 483 $self->{flags} |= BENEFACTIVE;
455  
456 483 return $self;
457 }
458  
459  
460 # form the "(anti)benefactive for the listener"
461 # assumes that benefactive() or antiben() has already been applied
462 482 ▶sub dir2 ($) {
Subroutine dir2: called CC=8 SCAR=23.2
Pod documented
463 482 my $self = shift->clone;
464  
465 482 ▶ unless($self->{flags} & BENEFACTIVE or $self->{flags} & ANTIBEN) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"flags"} & 1 or $self->{"flags"} & 2) 0 482 482
Condition66%2/3
$self->{"flags"} & 1 or $self->{"flags"} & 2
l!l&&r!l&&!r
2412410
MC/DC0%0/2
$self->{"flags"} & 1 or $self->{"flags"} & 2
$self->{"flags"} & 1 $self->{"flags"} & 2
Truth table66%2/3
A or B
A= $self->{"flags"} & 1B= $self->{"flags"} & 2
ABresult
1X1
011
000
466 0 croak "Can apply -to-listener only to (anti)benefactive forms";
467 }
468  
469 482 my $word = $self->{word};
470  
471 # check for -VCV
472 482 ▶ unless($v{$word->[-1]} && $v{$word->[-3]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v{$word->[-1]} and $v{$word->[-3]}) 0 482 482
Condition33%1/3
$v{$word->[-1]} and $v{$word->[-3]}
!ll&&!rl&&r
00482
MC/DC0%0/2
$v{$word->[-1]} and $v{$word->[-3]}
$v{$word->[-1]} $v{$word->[-3]}
Truth table33%1/3
A and B
A= $v{$word->[-1]}B= $v{$word->[-3]}
ABresult
0X0
100
111
473 0 croak "Funny word '" . dumpword($word) . "' does not have vowels in positions -3 and -1!";
474 }
475 482 ▶ unless(ref $word->[-2] or $c{$word->[-2]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $word->[-2] or $c{$word->[-2]}) 0 482 482
Condition66%2/3
ref $word->[-2] or $c{$word->[-2]}
l!l&&r!l&&!r
963860
MC/DC0%0/2
ref $word->[-2] or $c{$word->[-2]}
ref $word->[-2] $c{$word->[-2]}
Truth table66%2/3
A or B
A= ref $word->[-2]B= $c{$word->[-2]}
ABresult
1X1
011
000
476 0 croak "Funny word '" . dumpword($word) . "' does not have a consonant in position -2!";
477 }
478  
479 # add -ni- before the final consonant of the root
480  
481 # is the last consonant a cluster? if so, use add(), otherwise just
482 # splice right in
483 482 ▶ if(ref $word->[-2]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $word->[-2]) { } 96 386 482
484 96 $word = add $word, -2, 'n', 'i';
485 96 $self->{word} = $word;
486 } else {
487 386 splice @$word, -2, 0, 'n', 'i';
488 }
489  
490 482 $self->{flags} |= DIR2;
491  
492 482 return $self;
493 }
494  
495  
496 # form the antibenefactive
497 482 ▶sub antiben ($) {
Subroutine antiben: called CC=12 SCAR=32.3
Pod documented
498 482 my $self = shift->clone;
499 482 my $word = $self->{word};
500  
501 482 ▶ if($self->{flags} & BENEFACTIVE) {
Branch: 5 branches
BranchTrueFalseTotal
if ($self->{'flags'} & 1) { } 0 482 482
elsif ($self->{'flags'} & 4) { } 0 482 482
elsif ($self->{'flags'} & 8) { } 0 482 482
elsif ($self->{'flags'} & 32) { } 0 482 482
elsif ($self->{'flags'} & 64) { } 0 482 482
502 0 croak "Can't make a benefactive from antibenefactive";
503 } elsif($self->{flags} & VOLITIONAL) {
504 0 croak "Can't make a volitional form antibenefactive";
505 } elsif($self->{flags} & PERFECTIVE) {
506 0 croak "Can't make a perfective form antibenefactive";
507 } elsif($self->{flags} & POLITE) {
508 0 croak "Can't make a polite form antibenefactive";
509 } elsif($self->{flags} & SUBORDINATE) {
510 0 croak "Can't make a subordinate form antibenefactive";
511 }
512  
513 # check for -VC[uy]
514 482 ▶ unless($v{$word->[-1]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v{$word->[-1]}) 0 482 482
515 0 croak "Funny word '" . dumpword($word) . "' does not have a vowel in position -3!";
516 }
517 482 ▶ unless(ref $word->[-2] or $c{$word->[-2]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $word->[-2] or $c{$word->[-2]}) 0 482 482
Condition66%2/3
ref $word->[-2] or $c{$word->[-2]}
l!l&&r!l&&!r
963860
MC/DC0%0/2
ref $word->[-2] or $c{$word->[-2]}
ref $word->[-2] $c{$word->[-2]}
Truth table66%2/3
A or B
A= ref $word->[-2]B= $c{$word->[-2]}
ABresult
1X1
011
000
518 0 croak "Funny word '" . dumpword($word) . "' does not have a consonant in position -2!";
519 }
520 482 ▶ unless($word->[-1] eq 'u' or $word->[-1] eq 'y') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($word->[-1] eq "u" or $word->[-1] eq "y") 0 482 482
Condition66%2/3
$word->[-1] eq "u" or $word->[-1] eq "y"
l!l&&r!l&&!r
386960
MC/DC0%0/2
$word->[-1] eq "u" or $word->[-1] eq "y"
$word->[-1] eq "u" $word->[-1] eq "y"
Truth table66%2/3
A or B
A= $word->[-1] eq "u"B= $word->[-1] eq "y"
ABresult
1X1
011
000
521 0 croak "Funny word '" . dumpword($word) . "' does not end in -u or -y!";
522 }
523  
524 # back the stem vowel
525 # that's the last vowel of the root, according to
526 # http://www.zompist.com/board/messages/94.html
527 482 ▶ $word->[-3] = $back{$word->[-3]} || '???';
Condition50%1/2
$back{$word->[-3]} || '???'
l!l
4820
MC/DC0%0/1
$back{$word->[-3]} || '???'
$back{$word->[-3]}
Truth table50%1/2
A
A= $back{$word->[-3]}
Aresult
11
00
528  
529 # Change the final -u (or -y!) to -a
530 482 $word->[-1] = 'a';
531  
532 482 $self->{flags} |= ANTIBEN;
533  
534 482 return $self;
535 }
536  
537  
538 # form the subordinating form
539 601 ▶sub subordinate ($) {
Subroutine subordinate: called CC=7 SCAR=20.8
Pod documented
540 601 my $self = shift->clone;
541 601 my $word = $self->{word};
542  
543 # check for -VCV
544 601 ▶ unless($v{$word->[-1]} && $v{$word->[-3]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v{$word->[-1]} and $v{$word->[-3]}) 0 601 601
Condition33%1/3
$v{$word->[-1]} and $v{$word->[-3]}
!ll&&!rl&&r
00601
MC/DC0%0/2
$v{$word->[-1]} and $v{$word->[-3]}
$v{$word->[-1]} $v{$word->[-3]}
Truth table33%1/3
A and B
A= $v{$word->[-1]}B= $v{$word->[-3]}
ABresult
0X0
100
111
545 0 croak "Funny word '" . dumpword($word) . "' does not have vowels in positions -3 and -1!";
546 }
547 601 ▶ unless(ref $word->[-2] or $c{$word->[-2]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $word->[-2] or $c{$word->[-2]}) 0 601 601
Condition66%2/3
ref $word->[-2] or $c{$word->[-2]}
l!l&&r!l&&!r
365650
MC/DC0%0/2
ref $word->[-2] or $c{$word->[-2]}
ref $word->[-2] $c{$word->[-2]}
Truth table66%2/3
A or B
A= ref $word->[-2]B= $c{$word->[-2]}
ABresult
1X1
011
000
548 0 croak "Funny word '" . dumpword($word) . "' does not have a consonant in position -2!";
549 }
550  
551 # move the final vowel of the verb before the consonant
552  
553 # is the last consonant a cluster? if so, use add(), otherwise just
554 # splice right in
555 # use -1 rather than -2 for the position since we'll have spliced off
556 # the vowel in position -1 already
557 601 ▶ if(ref $word->[-2]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $word->[-2]) { } 36 565 601
558 36 $word = add $word, -1, splice(@$word, -1, 1);
559 36 $self->{word} = $word;
560 } else {
561 565 splice @$word, -1, 0, splice(@$word, -1, 1);
562 }
563  
564 # a labial stop becomes dental, a voiced stop becomes unvoiced
565 601 ▶ $word->[-1] = $subord{$word->[-1]} || $word->[-1];
Condition66%2/3
$subord{$word->[-1]} || $word->[-1]
l!l&&r!l&&!r
1204810
MC/DC0%0/2
$subord{$word->[-1]} || $word->[-1]
$subord{$word->[-1]} $word->[-1]
Truth table66%2/3
A || B
A= $subord{$word->[-1]}B= $word->[-1]
ABresult
1X1
011
000
566  
567 # Add -te
568 601 push @$word, 't', 'e';
569  
570 601 $self->{flags} |= SUBORDINATE;
571  
572 601 return $self;
573 }
574  
575  
576 # make the "one who does" form
577 16 ▶sub whodoes ($) {
Subroutine whodoes: called CC=1 SCAR=0.0
Pod documented
578 16 my $self = shift->clone;
579 16 my $word = $self->{word};
580  
581 16 splice @$word, -1, 1, 'e', 'u';
582  
583 16 return $self;
584 }
585  
586  
587 # make the feminine "one who does" form
588 16 ▶sub whodoesf ($) {
Subroutine whodoesf: called CC=1 SCAR=0.0
Pod documented
589 16 my $self = shift->clone;
590 16 my $word = $self->{word};
591  
592 16 splice @$word, -1, 1, 'e', 'c';
593  
594 16 return $self;
595 }
596  
597  
598 # make the "participle"
599 16 ▶sub participle ($) {
Subroutine participle: called CC=7 SCAR=20.7
Pod documented
600 16 my $self = shift->clone;
601 16 my $word = $self->{word};
602  
603 # check for -VCV
604 16 ▶ unless($v{$word->[-1]} && $v{$word->[-3]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v{$word->[-1]} and $v{$word->[-3]}) 0 16 16
Condition33%1/3
$v{$word->[-1]} and $v{$word->[-3]}
!ll&&!rl&&r
0016
MC/DC0%0/2
$v{$word->[-1]} and $v{$word->[-3]}
$v{$word->[-1]} $v{$word->[-3]}
Truth table33%1/3
A and B
A= $v{$word->[-1]}B= $v{$word->[-3]}
ABresult
0X0
100
111
605 0 croak "Funny word '" . dumpword($word) . "' does not have vowels in positions -3 and -1!";
606 }
607 16 ▶ unless(ref $word->[-2] or $c{$word->[-2]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $word->[-2] or $c{$word->[-2]}) 0 16 16
Condition66%2/3
ref $word->[-2] or $c{$word->[-2]}
l!l&&r!l&&!r
3130
MC/DC0%0/2
ref $word->[-2] or $c{$word->[-2]}
ref $word->[-2] $c{$word->[-2]}
Truth table66%2/3
A or B
A= ref $word->[-2]B= $c{$word->[-2]}
ABresult
1X1
011
000
608 0 croak "Funny word '" . dumpword($word) . "' does not have a consonant in position -2!";
609 }
610  
611 # change final vowel to -a
612 16 $word->[-1] = 'a';
613  
614 # is the last consonant a cluster? if so, use add(), otherwise just
615 # splice right in
616 16 ▶ if(ref $word->[-2]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $word->[-2]) { } 3 13 16
617 3 $word = add $word, -2, 'i';
618 3 $self->{word} = $word;
619 } else {
620 13 ▶ splice @$word, -2, 0, ($word->[-3] eq 'i' ? 'e' : 'i');
Branch: 1 branch
BranchTrueFalseTotal
$word->[-3] eq 'i' ? : 3 10 13
621 }
622  
623 16 return $self;
624 }
625  
626  
627 # form the action corresponding to a verb
628 16 ▶sub action ($) {
Subroutine action: called CC=6 SCAR=20.8
Pod documented
629 16 my $self = shift->clone;
630 16 my $word = $self->{word};
631  
632 # check for -VCV
633 16 ▶ unless($v{$word->[-1]} && $v{$word->[-3]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($v{$word->[-1]} and $v{$word->[-3]}) 0 16 16
Condition33%1/3
$v{$word->[-1]} and $v{$word->[-3]}
!ll&&!rl&&r
0016
MC/DC0%0/2
$v{$word->[-1]} and $v{$word->[-3]}
$v{$word->[-1]} $v{$word->[-3]}
Truth table33%1/3
A and B
A= $v{$word->[-1]}B= $v{$word->[-3]}
ABresult
0X0
100
111
634 0 croak "Funny word '" . dumpword($word) . "' does not have vowels in positions -3 and -1!";
635 }
636 16 ▶ unless(ref $word->[-2] or $c{$word->[-2]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $word->[-2] or $c{$word->[-2]}) 0 16 16
Condition66%2/3
ref $word->[-2] or $c{$word->[-2]}
l!l&&r!l&&!r
3130
MC/DC0%0/2
ref $word->[-2] or $c{$word->[-2]}
ref $word->[-2] $c{$word->[-2]}
Truth table66%2/3
A or B
A= ref $word->[-2]B= $c{$word->[-2]}
ABresult
1X1
011
000
637 0 croak "Funny word '" . dumpword($word) . "' does not have a consonant in position -2!";
638 }
639  
640 # lower the last root vowel
641 16 ▶ $word->[-3] = $lower{$word->[-3]} || '???';
Condition50%1/2
$lower{$word->[-3]} || '???'
l!l
160
MC/DC0%0/1
$lower{$word->[-3]} || '???'
$lower{$word->[-3]}
Truth table50%1/2
A
A= $lower{$word->[-3]}
Aresult
11
00
642  
643 # add -i
644 16 $word->[-1] = 'i';
645  
646 16 return $self;
647 }
648  
649  
650 2 1;
651  
652 __END__
↑ Summary