Inflexion/Term.pm

filter: Statementstmt 76.3% 194 / 254 Branchbran 82.8% 63 / 76 Conditioncond 57.6% 113 / 196 MC/DCmcdc 14.8% 14 / 94 Subroutinesub 61.6% 45 / 73 Podpod 0.0% 0 / 7 totaltotal 61.2% 429 / 700 CC 104 SCAR 22.5
CC
104
Cov
70%
__ANON__
30.0
ordinal
30.0
plural
25.8
CRAP 9.5
« Inflexion/Indefinite.pm ↑ Summary
1 package Lingua::EN::Inflexion::Term;
2  
3 33 ▶use 5.010; use warnings; use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4 33 ▶no if $] >= 5.018, warnings => "experimental::smartmatch";
Subroutine BEGIN: called CC=1 SCAR=0.0
5 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 33 ▶use match::smart 'match';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 33 ▶use Hash::Util 'fieldhash';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 33 fieldhash my %term_of;
12  
13 # Inside-out constructor...
14 sub new {
15 26151 ▶ my ($class, $term) = @_;
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
16  
17 26151 my $object = bless do{ \my $scalar }, $class;
18  
19 26151 ▶ $term_of{$object} = $term // croak "Missing arg to $class ctor";
Condition33%1/3
$term // croak("Missing arg to $class ctor")
l!l&&r!l&&!r
2615100
MC/DC0%0/2
$term // croak("Missing arg to $class ctor")
$term croak("Missing arg to $class ctor")
Truth table33%1/3
A // B
A= $termB= croak("Missing arg to $class ctor")
ABresult
1X1
011
000
20  
21 26151 return $object;
22 }
23  
24 # Replicate casing...
25 my $encase = sub {
26 31822 ▶ my ($original, $target) = @_;
Subroutine __ANON__: called CC=8 SCAR=20.8
27  
28 # Special case for 'I'
29 31822 ▶ return $target if $original eq 'I' || $target eq 'I';
Branch: 1 branch
BranchTrueFalseTotal
if $original eq "I" or $target eq "I" 22 31800 31822
Condition100%3/3
$original eq "I" or $target eq "I"
l!l&&r!l&&!r
13931800
MC/DC100%2/2
$original eq "I" or $target eq "I"
$original eq "I" $target eq "I"
Truth table100%3/3
A or B
A= $original eq "I"B= $target eq "I"
ABresult
1X1
011
000
30  
31 # Construct word-by-word case transformations...
32 my @transforms
33 31800 ▶ = map { /\A[[:lower:][:^alpha:]]+\Z/ ? sub { lc shift }
Subroutine __ANON__: called CC=1 SCAR=0.0
34 1540 ▶ : /\A[[:upper:]][[:lower:][:^alpha:]]+\Z/ ? sub { ucfirst lc shift }
Subroutine __ANON__: called CC=1 SCAR=0.0
35 451 ▶ : /\A[[:upper:][:^alpha:]]+\Z/ ? sub { uc shift }
Subroutine __ANON__: called CC=1 SCAR=0.0
36 68 ▶ : sub { shift }
Subroutine __ANON__: called CC=1 SCAR=0.0
37 33883 ▶ }
Branch: 3 branches
BranchTrueFalseTotal
/\A[[:lower:][:^alpha:]]+\Z/ ? : 31824 2059 33883
/\A[[:upper:]][[:lower:][:^alpha:]]+\Z/ ? : 1540 519 2059
/\A[[:upper:][:^alpha:]]+\Z/ ? : 451 68 519
38 split /\s+/, $original;
39  
40 31800 ▶ if (!@transforms) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@transforms) 2 31798 31800
41 2 ▶ @transforms = sub {shift};
Subroutine __ANON__: called CC=1 SCAR=0.0
42 }
43  
44 # Apply to target...
45 31800 $target =~ s{(\S+)}
46 33874 ▶ { my $transform = @transforms > 1 ? shift @transforms : $transforms[0];
Branch: 1 branch
BranchTrueFalseTotal
@transforms > 1 ? : 2085 31789 33874
47 33874 $transform->($1);
48 }xmseg;
49  
50 31800 return $target;
51 33 };
52  
53 # Report part-of-speech...
54 0 ▶sub is_noun { 0 }
Subroutine is_noun: not called CC=1 SCAR=6.9
Pod undocumented
55 0 ▶sub is_verb { 0 }
Subroutine is_verb: not called CC=1 SCAR=6.9
Pod undocumented
56 0 ▶sub is_adj { 0 }
Subroutine is_adj: not called CC=1 SCAR=6.9
Pod undocumented
57  
58 # Default classical/unassimilated mode does nothing...
59 0 ▶sub classical { return shift; }
Subroutine classical: not called CC=1 SCAR=6.9
Pod undocumented
60 0 ▶sub unassimilated { return shift->classical; }
Subroutine unassimilated: not called CC=1 SCAR=6.9
Pod undocumented
61  
62 # Coerce to original...
63 33 ▶use Scalar::Util qw< refaddr blessed >;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 use overload (
65 94 ▶ q[qr] => sub { return shift->as_regex(); },
Subroutine __ANON__: called CC=1 SCAR=0.0
66 1095 ▶ q[""] => sub { return "$term_of{shift()}"; },
Subroutine __ANON__: called CC=1 SCAR=0.0
67 0 ▶ q[0+] => sub { return refaddr(shift); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
68 4 ▶ q[bool] => sub { return 1; },
Subroutine __ANON__: called CC=1 SCAR=0.0
69 0 ▶ q[${}] => sub { croak "Can't coerce ", ref(shift), ' object to scalar reference'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
70 0 ▶ q[@{}] => sub { croak "Can't coerce ", ref(shift), ' object to array reference'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
71 0 ▶ q[%{}] => sub { croak "Can't coerce ", ref(shift), ' object to hash reference'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
72 0 ▶ q[&{}] => sub { croak "Can't coerce ", ref(shift), ' object to subroutine reference'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
73 0 ▶ q[*{}] => sub { croak "Can't coerce ", ref(shift), ' object to typeglob reference'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
74  
75 q[~~] => sub {
76 0 ▶ my ($term, $other_arg) = @_;
Subroutine __ANON__: not called CC=5 SCAR=34.0
77  
78 # Handle TERM ~~ TERM...
79 0 ▶ if (blessed($other_arg) && $other_arg->isa(__PACKAGE__)) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($other_arg) and $other_arg->isa(__PACKAGE__)) { } 0 0 0
Condition0%0/3
builtin::blessed($other_arg) and $other_arg->isa(__PACKAGE__)
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($other_arg) and $other_arg->isa(__PACKAGE__)
builtin::blessed($other_arg) $other_arg->isa(__PACKAGE__)
Truth table0%0/3
A and B
A= builtin::blessed($other_arg)B= $other_arg->isa(__PACKAGE__)
ABresult
0X0
100
111
80 0 ▶ return lc($term->singular) eq lc($other_arg->singular)
Condition0%0/6
lc $term->singular eq lc $other_arg->singular || lc $term->plural eq lc $other_arg->plural || lc $term->classical->plural eq lc $other_arg->classical->plural
l!l&&r!l&&!r
000
lc $term->singular eq lc $other_arg->singular or lc $term->plural eq lc $other_arg->plural
l!l&&r!l&&!r
000
MC/DC0%0/3
lc $term->singular eq lc $other_arg->singular || lc $term->plural eq lc $other_arg->plural || lc $term->classical->plural eq lc $other_arg->classical->plural
lc $term->singular eq lc $other_arg->singular lc $term->plural eq lc $other_arg->plural lc $term->classical->plural eq lc $other_arg->classical->plural
Truth table0%0/4
A or B || C
A= lc $term->singular eq lc $other_arg->singularB= lc $term->plural eq lc $other_arg->pluralC= lc $term->classical->plural eq lc $other_arg->classical->plural
ABCresult
1XX1
01X1
0011
0000
81 || lc($term->plural) eq lc($other_arg->plural)
82 || lc($term->classical->plural) eq lc($other_arg->classical->plural);
83 }
84  
85 # Otherwise just smartmatch against TERM as regex....
86 else {
87 0 return match($other_arg, $term->as_regex);
88 }
89 },
90  
91  
92 33 fallback => 1,
93 33 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
94  
95 # Treat as regex...
96 sub as_regex {
97 94 ▶ my ($self) = @_;
Subroutine as_regex: called CC=1 SCAR=0.0
Pod undocumented
98 94 my %seen;
99 94 my $pattern = join '|', map { quotemeta } reverse sort grep { !$seen{$_}++ }
100 ($self->singular, $self->plural, $self->classical->plural);
101 94 return qr{$pattern}i;
102 }
103  
104  
105 package Lingua::EN::Inflexion::Noun;
106 33 our @ISA = 'Lingua::EN::Inflexion::Term';
107  
108 33 ▶use Lingua::EN::Inflexion::Nouns;
Subroutine BEGIN: called CC=1 SCAR=0.0
109 33 ▶use Lingua::EN::Inflexion::Indefinite;
Subroutine BEGIN: called CC=1 SCAR=0.0
110  
111 # Report number of the noun...
112 sub is_plural {
113 3041 ▶ my ($self) = @_;
Subroutine is_plural: called CC=1 SCAR=0.0
114 3041 return Lingua::EN::Inflexion::Nouns::is_plural( $term_of{$self} );
115 }
116  
117 sub is_singular {
118 2473 ▶ my ($self) = @_;
Subroutine is_singular: called CC=1 SCAR=0.0
119 2473 return Lingua::EN::Inflexion::Nouns::is_singular( $term_of{$self} );
120 }
121  
122 # Report part-of-speech...
123 0 ▶sub is_noun { 1 }
Subroutine is_noun: not called CC=1 SCAR=6.9
124  
125 # Return plural and singular forms of the noun...
126  
127 33 my %noun_inflexion_of = (
128 # CASE TERM 0TH 1ST 2ND 3RD
129 nominative => {
130 i => { number => 'singular', person => 1,
131 singular => [qw< I I you it >],
132 plural => [qw< we we you they >],
133 },
134 you => { number => 'singular', person => 2,
135 singular => [qw< you I you it >],
136 plural => [qw< you we you they >],
137 },
138 she => { number => 'singular', person => 3,
139 singular => [qw< she I you she >],
140 plural => [qw< they we you they >],
141 },
142 he => { number => 'singular', person => 3,
143 singular => [qw< he I you he >],
144 plural => [qw< they we you they >],
145 },
146 it => { number => 'singular', person => 3,
147 singular => [qw< it I you it >],
148 plural => [qw< they we you they >],
149 },
150 we => { number => 'plural', person => 1,
151 singular => [qw< I I you it >],
152 plural => [qw< we we you they >],
153 },
154 they => { number => 'plural', person => 3,
155 singular => [qw< it I you it >],
156 plural => [qw< they we you they >],
157 },
158 one => { number => 'singular', person => 3,
159 singular => [qw< one I you one >],
160 plural => [qw< some we you some >],
161 },
162 this => { number => 'singular', person => 3,
163 singular => [qw< this this this this >],
164 plural => [qw< these these these these >],
165 },
166 that => { number => 'singular', person => 3,
167 singular => [qw< that that that that >],
168 plural => [qw< those those those those >],
169 },
170 these => { number => 'plural', person => 3,
171 singular => [qw< this this this this >],
172 plural => [qw< these these these these >],
173 },
174 those => { number => 'plural', person => 3,
175 singular => [qw< that that that that >],
176 plural => [qw< those those those those >],
177 },
178 who => { number => 'singular', person => 3,
179 singular => [qw< who who who who >],
180 plural => [qw< who who who who >],
181 },
182 whoever => { number => 'singular', person => 3,
183 singular => [qw< whoever whoever whoever whoever >],
184 plural => [qw< whoever whoever whoever whoever >],
185 },
186 whosoever => { number => 'singular', person => 3,
187 singular => [qw< whosoever whosoever whosoever whosoever >],
188 plural => [qw< whosoever whosoever whosoever whosoever >],
189 },
190 },
191 objective => {
192 me => { number => 'singular', person => 1,
193 singular => [qw< me me you it >],
194 plural => [qw< us us you them >],
195 },
196 you => { number => 'singular', person => 2,
197 singular => [qw< you me you it >],
198 plural => [qw< you us you them >],
199 },
200 her => { number => 'singular', person => 3,
201 singular => [qw< her me you her >],
202 plural => [qw< them us you them >],
203 },
204 him => { number => 'singular', person => 3,
205 singular => [qw< him me you him >],
206 plural => [qw< them us you them >],
207 },
208 it => { number => 'singular', person => 3,
209 singular => [qw< it me you it >],
210 plural => [qw< them us you them >],
211 },
212 one => { number => 'singular', person => 3,
213 singular => [qw< one me you one >],
214 plural => [qw< some us you some >],
215 },
216 us => { number => 'plural', person => 1,
217 singular => [qw< me me you it >],
218 plural => [qw< us us you them >],
219 },
220 them => { number => 'plural', person => 3,
221 singular => [qw< it me you it >],
222 plural => [qw< them us you them >],
223 },
224 this => { number => 'singular', person => 3,
225 singular => [qw< this this this this >],
226 plural => [qw< these these these these >],
227 },
228 that => { number => 'singular', person => 3,
229 singular => [qw< that that that that >],
230 plural => [qw< those those those those >],
231 },
232 these => { number => 'plural', person => 3,
233 singular => [qw< this this this this >],
234 plural => [qw< these these these these >],
235 },
236 those => { number => 'plural', person => 3,
237 singular => [qw< that that that that >],
238 plural => [qw< those those those those >],
239 },
240 whom => { number => 'singular', person => 3,
241 singular => [qw< whom whom whom whom >],
242 plural => [qw< whom whom whom whom >],
243 },
244 whomever => { number => 'singular', person => 3,
245 singular => [qw< whomever whomever whomever whomever >],
246 plural => [qw< whomever whomever whomever whomever >],
247 },
248 whomsoever => { number => 'singular', person => 3,
249 singular => [qw< whomsoever whomsoever whomsoever whomsoever >],
250 plural => [qw< whomsoever whomsoever whomsoever whomsoever >],
251 },
252 },
253 possessive => {
254 mine => { number => 'singular', person => 1,
255 singular => [qw< mine mine yours its >],
256 plural => [qw< ours ours yours theirs >],
257 },
258 yours => { number => 'singular', person => 2,
259 singular => [qw< yours mine yours its >],
260 plural => [qw< yours ours yours theirs >],
261 },
262 hers => { number => 'singular', person => 3,
263 singular => [qw< hers mine yours hers >],
264 plural => [qw< theirs ours yours theirs >],
265 },
266 his => { number => 'singular', person => 3,
267 singular => [qw< his mine yours his >],
268 plural => [qw< theirs ours yours theirs >],
269 },
270 its => { number => 'singular', person => 3,
271 singular => [qw< its mine yours its >],
272 plural => [qw< theirs ours yours theirs >],
273 },
274 "one's" => { number => 'singular', person => 3,
275 singular => [qw< one's mine yours one's >],
276 plural => [qw< theirs ours yours theirs >],
277 },
278 ours => { number => 'plural', person => 1,
279 singular => [qw< mine mine yours its >],
280 plural => [qw< ours ours yours theirs >],
281 },
282 theirs => { number => 'plural', person => 3,
283 singular => [qw< its mine yours its >],
284 plural => [qw< theirs ours yours theirs >],
285 },
286 whose => { number => 'singular', person => 3,
287 singular => [qw< whose whose whose whose >],
288 plural => [qw< whose whose whose whose >],
289 },
290 whosever => { number => 'singular', person => 3,
291 singular => [qw< whosever whosever whosever whosever >],
292 plural => [qw< whosever whosever whosever whosever >],
293 },
294 whosesoever=> { number => 'singular', person => 3,
295 singular => [qw< whosesoever whosesoever whosesoever whosesoever >],
296 plural => [qw< whosesoever whosesoever whosesoever whosesoever >],
297 },
298 },
299 reflexive => {
300 myself => { number => 'singular', person => 1,
301 singular => [qw< myself myself yourself itself >],
302 plural => [qw< ourselves ourselves yourselves themselves >],
303 },
304 yourself => { number => 'singular', person => 2,
305 singular => [qw< yourself myself yourself itself >],
306 plural => [qw< yourselves ourselves yourselves themselves >],
307 },
308 herself => { number => 'singular', person => 3,
309 singular => [qw< herself myself yourself herself >],
310 plural => [qw< themselves ourselves yourselves themselves >],
311 },
312 himself => { number => 'singular', person => 3,
313 singular => [qw< himself myself yourself himself >],
314 plural => [qw< themselves ourselves yourselves themselves >],
315 },
316 themself => { number => 'singular', person => 3,
317 singular => [qw< themselves myself yourself themselves >],
318 plural => [qw< themselves ourselves yourselves themselves >],
319 },
320 itself => { number => 'singular', person => 3,
321 singular => [qw< itself myself yourself itself >],
322 plural => [qw< themselves ourselves yourselves themselves >],
323 },
324 oneself => { number => 'singular', person => 3,
325 singular => [qw< oneself myself yourself oneself >],
326 plural => [qw< oneselves ourselves yourselves oneselves >],
327 },
328 ourselves => { number => 'plural', person => 1,
329 singular => [qw< myself myself yourself itself >],
330 plural => [qw< ourselves ourselves yourselves themselves >],
331 },
332 yourselves => { number => 'plural', person => 2,
333 singular => [qw< yourself myself yourself itself >],
334 plural => [qw< yourselves ourselves yourselves themselves >],
335 },
336 themselves => { number => 'plural', person => 3,
337 singular => [qw< themselves myself yourself themselves >],
338 plural => [qw< themselves ourselves yourselves themselves >],
339 },
340 oneselves => { number => 'plural', person => 3,
341 singular => [qw< oneself myself yourself oneself >],
342 plural => [qw< oneselves ourselves yourselves oneselves >],
343 },
344 },
345 );
346  
347 33 my $PREP_PAT = qr{ about | above | across | after | among | around | athwart
348 | at | before | behind | below | beneath | besides?
349 | between | betwixt | beyond | but | by | during
350 | except | for | from | into | in | near | off
351 | of | onto | on | out | over | since | till
352 | to | under | until | unto | upon | within | without | with
353 }xmsi;
354  
355 sub singular {
356 12074 ▶ my $self = shift;
Subroutine singular: called CC=12 SCAR=25.0
357 12074 ▶ my $person = shift // 0;
Condition100%2/2
shift() // 0
l!l
10811966
MC/DC100%1/1
shift() // 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
358  
359 12074 my $term = $term_of{$self};
360  
361 # Prepositions imply objective or possessive...
362 12074 ▶ my $preposition = $term =~ s{ \A ( \s* $PREP_PAT \s+ ) }{}xi ? $1 : q{};
Branch: 1 branch
BranchTrueFalseTotal
$term =~ s/ \A ( \s* $PREP_PAT \s+ ) //xi ? : 44 12030 12074
363  
364 return
365 $preposition ? $preposition
366 . $encase->( $term,
367 $noun_inflexion_of{objective }{lc $term}{singular}[$person]
368 // $noun_inflexion_of{possessive}{lc $term}{singular}[$person]
369 // $noun_inflexion_of{reflexive }{lc $term}{singular}[$person]
370 // $noun_inflexion_of{nominative}{lc $term}{singular}[$person]
371 // Lingua::EN::Inflexion::Nouns::convert_to_singular( $term, $person )
372 )
373 : $encase->( $term,
374 $noun_inflexion_of{nominative}{lc $term}{singular}[$person]
375 // $noun_inflexion_of{objective }{lc $term}{singular}[$person]
376 // $noun_inflexion_of{possessive}{lc $term}{singular}[$person]
377 12074 ▶ // $noun_inflexion_of{reflexive }{lc $term}{singular}[$person]
Branch: 1 branch
BranchTrueFalseTotal
$preposition ? : 44 12030 12074
Condition83%20/24
((($noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"nominative"}{lc $term}{"singular"}[$person]) // Lingua::EN::Inflexion::Nouns::convert_to_singular($term, $person)
l!l&&r!l&&!r
3860
(($noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"nominative"}{lc $term}{"singular"}[$person]
l!l&&r!l&&!r
3806
($noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"singular"}[$person]
l!l&&r!l&&!r
3806
$noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person]
l!l&&r!l&&!r
18206
((($noun_inflexion_of{"nominative"}{lc $term}{"singular"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"singular"}[$person]) // Lingua::EN::Inflexion::Nouns::convert_to_singular($term, $person)
l!l&&r!l&&!r
186118440
(($noun_inflexion_of{"nominative"}{lc $term}{"singular"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"singular"}[$person]
l!l&&r!l&&!r
1285811844
($noun_inflexion_of{"nominative"}{lc $term}{"singular"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person]
l!l&&r!l&&!r
903811902
$noun_inflexion_of{"nominative"}{lc $term}{"singular"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person]
l!l&&r!l&&!r
573311940
MC/DC0%0/5
((($noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"nominative"}{lc $term}{"singular"}[$person]) // Lingua::EN::Inflexion::Nouns::convert_to_singular($term, $person)
$noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person] $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person] $noun_inflexion_of{"reflexive"}{lc $term}{"singular"}[$person] $noun_inflexion_of{"nominative"}{lc $term}{"singular"}[$person] Lingua::EN::Inflexion::Nouns::convert_to_singular($term, $person)
MC/DC0%0/5
((($noun_inflexion_of{"nominative"}{lc $term}{"singular"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"singular"}[$person]) // Lingua::EN::Inflexion::Nouns::convert_to_singular($term, $person)
$noun_inflexion_of{"nominative"}{lc $term}{"singular"}[$person] $noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person] $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person] $noun_inflexion_of{"reflexive"}{lc $term}{"singular"}[$person] Lingua::EN::Inflexion::Nouns::convert_to_singular($term, $person)
Truth table50%3/6
A // B // C // D // E
A= $noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person]B= $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person]C= $noun_inflexion_of{"reflexive"}{lc $term}{"singular"}[$person]D= $noun_inflexion_of{"nominative"}{lc $term}{"singular"}[$person]E= Lingua::EN::Inflexion::Nouns::convert_to_singular($term, $person)
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
Truth table83%5/6
A // B // C // D // E
A= $noun_inflexion_of{"nominative"}{lc $term}{"singular"}[$person]B= $noun_inflexion_of{"objective"}{lc $term}{"singular"}[$person]C= $noun_inflexion_of{"possessive"}{lc $term}{"singular"}[$person]D= $noun_inflexion_of{"reflexive"}{lc $term}{"singular"}[$person]E= Lingua::EN::Inflexion::Nouns::convert_to_singular($term, $person)
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
378 // Lingua::EN::Inflexion::Nouns::convert_to_singular( $term, $person )
379 );
380 }
381  
382  
383 sub plural {
384 6481 ▶ my $self = shift;
Subroutine plural: called CC=12 SCAR=25.0
385 6481 ▶ my $person = shift // 0;
Condition100%2/2
shift() // 0
l!l
1986283
MC/DC100%1/1
shift() // 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
386  
387 6481 my $term = $term_of{$self};
388  
389 # Prepositions imply objective or possessive (or dative)...
390 6481 ▶ my $preposition = $term =~ s{ \A ( \s* $PREP_PAT \s+ ) }{}xi ? $1 : q{};
Branch: 1 branch
BranchTrueFalseTotal
$term =~ s/ \A ( \s* $PREP_PAT \s+ ) //xi ? : 96 6385 6481
391  
392 return
393 $preposition ? $preposition
394 . $encase->( $term,
395 $noun_inflexion_of{objective }{lc $term}{plural}[$person]
396 // $noun_inflexion_of{possessive}{lc $term}{plural}[$person]
397 // $noun_inflexion_of{reflexive }{lc $term}{plural}[$person]
398 // $noun_inflexion_of{nominative}{lc $term}{plural}[$person]
399 // Lingua::EN::Inflexion::Nouns::convert_to_modern_plural($term,$person)
400 )
401 : $encase->( $term,
402 $noun_inflexion_of{nominative}{lc $term}{plural}[$person]
403 // $noun_inflexion_of{objective }{lc $term}{plural}[$person]
404 // $noun_inflexion_of{possessive}{lc $term}{plural}[$person]
405 6481 ▶ // $noun_inflexion_of{reflexive }{lc $term}{plural}[$person]
Branch: 1 branch
BranchTrueFalseTotal
$preposition ? : 96 6385 6481
Condition83%20/24
((($noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person]) // Lingua::EN::Inflexion::Nouns::convert_to_modern_plural($term, $person)
l!l&&r!l&&!r
9060
(($noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person]
l!l&&r!l&&!r
9006
($noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]
l!l&&r!l&&!r
9006
$noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]
l!l&&r!l&&!r
58326
((($noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]) // Lingua::EN::Inflexion::Nouns::convert_to_modern_plural($term, $person)
l!l&&r!l&&!r
23061550
(($noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]
l!l&&r!l&&!r
177536155
($noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]
l!l&&r!l&&!r
121566208
$noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]
l!l&&r!l&&!r
78436264
MC/DC0%0/5
((($noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person]) // Lingua::EN::Inflexion::Nouns::convert_to_modern_plural($term, $person)
$noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person] $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person] $noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] Lingua::EN::Inflexion::Nouns::convert_to_modern_plural($term, $person)
MC/DC0%0/5
((($noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]) // Lingua::EN::Inflexion::Nouns::convert_to_modern_plural($term, $person)
$noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person] $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person] Lingua::EN::Inflexion::Nouns::convert_to_modern_plural($term, $person)
Truth table50%3/6
A // B // C // D // E
A= $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]B= $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]C= $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]D= $noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person]E= Lingua::EN::Inflexion::Nouns::convert_to_modern_plural($term, $person)
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
Truth table83%5/6
A // B // C // D // E
A= $noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person]B= $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]C= $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]D= $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]E= Lingua::EN::Inflexion::Nouns::convert_to_modern_plural($term, $person)
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
406 // Lingua::EN::Inflexion::Nouns::convert_to_modern_plural($term,$person)
407 );
408 }
409  
410  
411 sub indef_article {
412 0 ▶ my ($self) = @_;
Subroutine indef_article: not called CC=1 SCAR=6.9
413  
414 0 return Lingua::EN::Inflexion::Indefinite::select_indefinite_article($self->singular);
415 }
416  
417 sub indefinite {
418 956 ▶ my ($self, $count) = @_;
Subroutine indefinite: called CC=3 SCAR=11.0
419 956 ▶ $count //= 1;
Condition100%2/2
$count //= 1
l!l
717239
MC/DC100%1/1
$count //= 1
$count
Truth table100%2/2
A
A= $count
Aresult
11
00
420  
421 956 ▶ if ($count == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count == 1) { } 478 478 956
422 478 return Lingua::EN::Inflexion::Indefinite::prepend_indefinite_article($self->singular);
423 }
424 else {
425 478 return "$count " . $self->plural;
426 }
427 }
428  
429  
430 # Conversions to ordinal and cardinal numbers (with module loaded on demand)...
431 my $num2word = sub {
432 2 ▶ state $load = require Lingua::EN::Nums2Words && Lingua::EN::Nums2Words::set_case('lower');
Subroutine __ANON__: called CC=2 SCAR=14.0
Condition0%0/3
require Lingua::EN::Nums2Words && Lingua::EN::Nums2Words::set_case('lower')
!ll&&!rl&&r
000
MC/DC0%0/2
require Lingua::EN::Nums2Words && Lingua::EN::Nums2Words::set_case('lower')
require Lingua::EN::Nums2Words Lingua::EN::Nums2Words::set_case('lower')
Truth table0%0/3
A && B
A= require Lingua::EN::Nums2WordsB= Lingua::EN::Nums2Words::set_case('lower')
ABresult
0X0
100
111
433 0 Lingua::EN::Nums2Words::num2word(@_);
434 33 };
435  
436 my $num2word_short_ordinal = sub {
437 0 ▶ state $load = require Lingua::EN::Nums2Words && Lingua::EN::Nums2Words::set_case('lower');
Subroutine __ANON__: not called CC=2 SCAR=17.9
Condition0%0/3
require Lingua::EN::Nums2Words && Lingua::EN::Nums2Words::set_case('lower')
!ll&&!rl&&r
000
MC/DC0%0/2
require Lingua::EN::Nums2Words && Lingua::EN::Nums2Words::set_case('lower')
require Lingua::EN::Nums2Words Lingua::EN::Nums2Words::set_case('lower')
Truth table0%0/3
A && B
A= require Lingua::EN::Nums2WordsB= Lingua::EN::Nums2Words::set_case('lower')
ABresult
0X0
100
111
438 0 Lingua::EN::Nums2Words::num2word_short_ordinal(@_);
439 33 };
440  
441 my $num2word_ordinal = sub {
442 0 ▶ state $load = require Lingua::EN::Nums2Words && Lingua::EN::Nums2Words::set_case('lower');
Subroutine __ANON__: not called CC=2 SCAR=17.9
Condition0%0/3
require Lingua::EN::Nums2Words && Lingua::EN::Nums2Words::set_case('lower')
!ll&&!rl&&r
000
MC/DC0%0/2
require Lingua::EN::Nums2Words && Lingua::EN::Nums2Words::set_case('lower')
require Lingua::EN::Nums2Words Lingua::EN::Nums2Words::set_case('lower')
Truth table0%0/3
A && B
A= require Lingua::EN::Nums2WordsB= Lingua::EN::Nums2Words::set_case('lower')
ABresult
0X0
100
111
443 0 Lingua::EN::Nums2Words::num2word_ordinal(@_);
444 33 };
445  
446 # These words may need an "and" before them...
447 33 my $LAST_WORD = qr{
448 one | two | three | four | five | six | seven | eight | nine | ten
449 | eleven | twelve | teen | ty
450 | first | second | third | [rfxnhe]th
451 }x;
452  
453 # These words may need an "and" after them...
454 33 my $POWER_WORD = qr{
455 hundred | thousand | \S+illion
456 }x;
457  
458 sub cardinal {
459 4 ▶ my $value = $term_of{ shift() };
Subroutine cardinal: called CC=5 SCAR=19.0
460 4 my $max_trans = shift();
461  
462 # Load the necessary module, and compensate for its persnicketiness...
463 4 state $load = require Lingua::EN::Words2Nums;
464 4 ▶ local $SIG{__WARN__} = sub{};
Subroutine __ANON__: not called CC=1 SCAR=0.0
465  
466 # Make sure we have a number...
467 4 ▶ $value = Lingua::EN::Words2Nums::words2nums($value) // $value;
Condition33%1/3
Lingua::EN::Words2Nums::words2nums($value) // $value
l!l&&r!l&&!r
400
MC/DC0%0/2
Lingua::EN::Words2Nums::words2nums($value) // $value
Lingua::EN::Words2Nums::words2nums($value) $value
Truth table33%1/3
A // B
A= Lingua::EN::Words2Nums::words2nums($value)B= $value
ABresult
1X1
011
000
468  
469 # If it's above threshold, return it as a number...
470 4 ▶ return $value
Branch: 1 branch
BranchTrueFalseTotal
if defined $max_trans and $value >= $max_trans 2 2 4
Condition100%3/3
defined $max_trans and $value >= $max_trans
!ll&&!rl&&r
112
MC/DC100%2/2
defined $max_trans and $value >= $max_trans
defined $max_trans $value >= $max_trans
Truth table100%3/3
A and B
A= defined $max_transB= $value >= $max_trans
ABresult
0X0
100
111
471 if defined $max_trans && $value >= $max_trans;
472  
473 # Otherwise, convert it to words...
474 2 my $words = $num2word->($value);
475  
476 # Correct for proper English pronunciation...
477 0 ▶ if ($value > 100) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value > 100) 0 0 0
478 0 $words =~ s{ ($POWER_WORD) \s+ (\S*$LAST_WORD) \b } {$1 and $2}gx;
479 0 $words =~ s{ (?<! and ) \s+ (\S*$LAST_WORD) $ } { and $1}gx;
480 0 $words =~ s{ ^ ([^,]+),([^,]+) $ } {$1$2}x;
481 }
482  
483 0 return $words;
484 }
485  
486 sub ordinal {
487 0 ▶ my $value = $term_of{ shift() };
Subroutine ordinal: not called CC=5 SCAR=34.0
488 0 my $max_trans = shift();
489  
490 # Load the necessary module, and compensate for its persnicketiness...
491 0 state $load = require Lingua::EN::Words2Nums;
492 0 ▶ local $SIG{__WARN__} = sub{};
Subroutine __ANON__: not called CC=1 SCAR=6.9
493  
494 # Make sure we have a number...
495 0 ▶ $value = Lingua::EN::Words2Nums::words2nums($value) // $value;
Condition0%0/3
Lingua::EN::Words2Nums::words2nums($value) // $value
l!l&&r!l&&!r
000
MC/DC0%0/2
Lingua::EN::Words2Nums::words2nums($value) // $value
Lingua::EN::Words2Nums::words2nums($value) $value
Truth table0%0/3
A // B
A= Lingua::EN::Words2Nums::words2nums($value)B= $value
ABresult
1X1
011
000
496  
497 # If it's above threshold, return it as a number...
498 0 ▶ return $num2word_short_ordinal->($value)
Branch: 1 branch
BranchTrueFalseTotal
if defined $max_trans and $value >= $max_trans 0 0 0
Condition0%0/3
defined $max_trans and $value >= $max_trans
!ll&&!rl&&r
000
MC/DC0%0/2
defined $max_trans and $value >= $max_trans
defined $max_trans $value >= $max_trans
Truth table0%0/3
A and B
A= defined $max_transB= $value >= $max_trans
ABresult
0X0
100
111
499 if defined $max_trans && $value >= $max_trans;
500  
501 # Otherwise, convert it to words...
502 0 my $words = $num2word_ordinal->( $value );
503  
504 # Correct for proper English pronunciation...
505 0 ▶ if ($value > 100) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value > 100) 0 0 0
506 0 $words =~ s{ ($POWER_WORD) \s+ (\S*$LAST_WORD) \b } {$1 and $2}gx;
507 0 $words =~ s{ (?<! and ) \s+ (\S*$LAST_WORD) $ } { and $1}gx;
508 0 $words =~ s{ ^ ([^,]+),([^,]+) $ } {$1$2}x;
509 }
510  
511 0 return $words;
512 }
513  
514  
515 # Return a classical version of the term...
516 5015 ▶sub classical { Lingua::EN::Inflexion::Noun::Classical->new(shift) }
Subroutine classical: called CC=1 SCAR=0.0
517  
518  
519 package Lingua::EN::Inflexion::Noun::Classical;
520 33 our @ISA = 'Lingua::EN::Inflexion::Noun';
521  
522 # Inside-out ctor expects a base-class object to clone...
523 sub new {
524 5015 ▶ my ($class, $orig_object) = @_;
Subroutine new: called CC=2 SCAR=6.9
525  
526 5015 my $new_object = bless do{ \my $scalar }, $class;
527  
528 # Special case of "them" (because "it" -> "they" and "it -> "them" are ambiguous)...
529 $term_of{$new_object}
530 5015 ▶ = $term_of{$orig_object} eq 'them' ? $term_of{$orig_object}
Branch: 1 branch
BranchTrueFalseTotal
$term_of{$orig_object} eq 'them' ? : 1 5014 5015
531 : $orig_object->singular;
532  
533 # Otherwise...
534  
535 5015 return $new_object;
536 }
537  
538 # Already a classical noun, so this is now idempotent...
539 0 ▶sub classical { return shift }
Subroutine classical: not called CC=1 SCAR=6.9
540  
541 # Classical plurals are different...
542 sub plural {
543 4845 ▶ my $self = shift;
Subroutine plural: called CC=12 SCAR=32.5
544 4845 ▶ my $person = shift // 0;
Condition50%1/2
shift() // 0
l!l
04845
MC/DC0%0/1
shift() // 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
545  
546 4845 my $term = $term_of{$self};
547  
548 # Prepositions imply objective or possessive (or dative)...
549 4845 ▶ my $preposition = $term =~ s{ \A ( \s* $PREP_PAT \s+ ) }{}xi ? $1 : q{};
Branch: 1 branch
BranchTrueFalseTotal
$term =~ s/ \A ( \s* $PREP_PAT \s+ ) //xi ? : 0 4845 4845
550  
551  
552 return
553 $preposition ? $preposition
554 . $encase->( $term,
555 $noun_inflexion_of{objective }{lc $term}{plural}[$person]
556 // $noun_inflexion_of{possessive}{lc $term}{plural}[$person]
557 // $noun_inflexion_of{reflexive }{lc $term}{plural}[$person]
558 // $noun_inflexion_of{nominative}{lc $term}{plural}[$person]
559 // Lingua::EN::Inflexion::Nouns::convert_to_classical_plural($term,$person)
560 )
561 : $encase->( $term,
562 $noun_inflexion_of{nominative}{lc $term}{plural}[$person]
563 // $noun_inflexion_of{objective }{lc $term}{plural}[$person]
564 // $noun_inflexion_of{possessive}{lc $term}{plural}[$person]
565 4845 ▶ // $noun_inflexion_of{reflexive }{lc $term}{plural}[$person]
Branch: 1 branch
BranchTrueFalseTotal
$preposition ? : 0 4845 4845
Condition45%11/24
((($noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person]) // Lingua::EN::Inflexion::Nouns::convert_to_classical_plural($term, $person)
l!l&&r!l&&!r
000
(($noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person]
l!l&&r!l&&!r
000
($noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]
l!l&&r!l&&!r
000
$noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]
l!l&&r!l&&!r
000
((($noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]) // Lingua::EN::Inflexion::Nouns::convert_to_classical_plural($term, $person)
l!l&&r!l&&!r
4348020
(($noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]
l!l&&r!l&&!r
3494802
($noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]
l!l&&r!l&&!r
24104811
$noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]
l!l&&r!l&&!r
1684821
MC/DC0%0/5
((($noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person]) // Lingua::EN::Inflexion::Nouns::convert_to_classical_plural($term, $person)
$noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person] $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person] $noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] Lingua::EN::Inflexion::Nouns::convert_to_classical_plural($term, $person)
MC/DC0%0/5
((($noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] // $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]) // $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]) // Lingua::EN::Inflexion::Nouns::convert_to_classical_plural($term, $person)
$noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person] $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person] $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person] $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person] Lingua::EN::Inflexion::Nouns::convert_to_classical_plural($term, $person)
Truth table0%0/6
A // B // C // D // E
A= $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]B= $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]C= $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]D= $noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person]E= Lingua::EN::Inflexion::Nouns::convert_to_classical_plural($term, $person)
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
Truth table83%5/6
A // B // C // D // E
A= $noun_inflexion_of{"nominative"}{lc $term}{"plural"}[$person]B= $noun_inflexion_of{"objective"}{lc $term}{"plural"}[$person]C= $noun_inflexion_of{"possessive"}{lc $term}{"plural"}[$person]D= $noun_inflexion_of{"reflexive"}{lc $term}{"plural"}[$person]E= Lingua::EN::Inflexion::Nouns::convert_to_classical_plural($term, $person)
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
566 // Lingua::EN::Inflexion::Nouns::convert_to_classical_plural($term,$person)
567 );
568 }
569  
570 package Lingua::EN::Inflexion::Verb;
571 33 our @ISA = 'Lingua::EN::Inflexion::Term';
572  
573 33 ▶use Lingua::EN::Inflexion::Verbs;
Subroutine BEGIN: called CC=1 SCAR=0.0
574  
575 # Utility sub that adjusts final consonants when they need to be doubled in inflexions...
576 my $truncate = sub {
577 144 ▶ my ($term) = @_;
Subroutine __ANON__: called CC=10 SCAR=31.7
578  
579 # Apply the first relevant transform...
580 144 ▶ $term =~ s{ ie \Z }{y}x
Branch: 1 branch
BranchTrueFalseTotal
$term =~ s/ ie \Z /y/x or $term =~ s/ ue \Z /u/x or $term =~ s/ ([auy])e \Z /$1/x or $term =~ s/ ski \Z /ski/x or $term =~ s/ [^b]i \Z //x or $term =~ s/ ([^e])e \Z /$1/x or $term =~ / er \Z /x or $term =~ s/ (.[bdghklmnprstz][o]([n])) \Z /$1/x or $term =~ s/ ([^aeiou][aeiouy]([bcdlgmnprstv])) \Z /$1$2/x or $term =~ s/ e \Z //x 108 36 144
Condition37%9/24
$term =~ s/ ie \Z /y/x or $term =~ s/ ue \Z /u/x or $term =~ s/ ([auy])e \Z /$1/x or $term =~ s/ ski \Z /ski/x or $term =~ s/ [^b]i \Z //x or $term =~ s/ ([^e])e \Z /$1/x or $term =~ / er \Z /x or $term =~ s/ (.[bdghklmnprstz][o]([n])) \Z /$1/x or $term =~ s/ ([^aeiou][aeiouy]([bcdlgmnprstv])) \Z /$1$2/x
l!l&&r!l&&!r
036108
$term =~ s/ ie \Z /y/x or $term =~ s/ ue \Z /u/x or $term =~ s/ ([auy])e \Z /$1/x or $term =~ s/ ski \Z /ski/x or $term =~ s/ [^b]i \Z //x or $term =~ s/ ([^e])e \Z /$1/x or $term =~ / er \Z /x or $term =~ s/ (.[bdghklmnprstz][o]([n])) \Z /$1/x
l!l&&r!l&&!r
00144
$term =~ s/ ie \Z /y/x or $term =~ s/ ue \Z /u/x or $term =~ s/ ([auy])e \Z /$1/x or $term =~ s/ ski \Z /ski/x or $term =~ s/ [^b]i \Z //x or $term =~ s/ ([^e])e \Z /$1/x or $term =~ / er \Z /x
l!l&&r!l&&!r
00144
$term =~ s/ ie \Z /y/x or $term =~ s/ ue \Z /u/x or $term =~ s/ ([auy])e \Z /$1/x or $term =~ s/ ski \Z /ski/x or $term =~ s/ [^b]i \Z //x or $term =~ s/ ([^e])e \Z /$1/x
l!l&&r!l&&!r
00144
$term =~ s/ ie \Z /y/x or $term =~ s/ ue \Z /u/x or $term =~ s/ ([auy])e \Z /$1/x or $term =~ s/ ski \Z /ski/x or $term =~ s/ [^b]i \Z //x
l!l&&r!l&&!r
00144
$term =~ s/ ie \Z /y/x or $term =~ s/ ue \Z /u/x or $term =~ s/ ([auy])e \Z /$1/x or $term =~ s/ ski \Z /ski/x
l!l&&r!l&&!r
00144
$term =~ s/ ie \Z /y/x or $term =~ s/ ue \Z /u/x or $term =~ s/ ([auy])e \Z /$1/x
l!l&&r!l&&!r
00144
$term =~ s/ ie \Z /y/x or $term =~ s/ ue \Z /u/x
l!l&&r!l&&!r
00144
MC/DC11%1/9
$term =~ s/ ie \Z /y/x or $term =~ s/ ue \Z /u/x or $term =~ s/ ([auy])e \Z /$1/x or $term =~ s/ ski \Z /ski/x or $term =~ s/ [^b]i \Z //x or $term =~ s/ ([^e])e \Z /$1/x or $term =~ / er \Z /x or $term =~ s/ (.[bdghklmnprstz][o]([n])) \Z /$1/x or $term =~ s/ ([^aeiou][aeiouy]([bcdlgmnprstv])) \Z /$1$2/x
$term =~ s/ ie \Z /y/x $term =~ s/ ue \Z /u/x $term =~ s/ ([auy])e \Z /$1/x $term =~ s/ ski \Z /ski/x $term =~ s/ [^b]i \Z //x $term =~ s/ ([^e])e \Z /$1/x $term =~ / er \Z /x $term =~ s/ (.[bdghklmnprstz][o]([n])) \Z /$1/x $term =~ s/ ([^aeiou][aeiouy]([bcdlgmnprstv])) \Z /$1$2/x
Truth table20%2/10
A or B or C or D or E or F or G or H or I
A= $term =~ s/ ie \Z /y/xB= $term =~ s/ ue \Z /u/xC= $term =~ s/ ([auy])e \Z /$1/xD= $term =~ s/ ski \Z /ski/xE= $term =~ s/ [^b]i \Z //xF= $term =~ s/ ([^e])e \Z /$1/xG= $term =~ / er \Z /xH= $term =~ s/ (.[bdghklmnprstz][o]([n])) \Z /$1/xI= $term =~ s/ ([^aeiou][aeiouy]([bcdlgmnprstv])) \Z /$1$2/x
ABCDEFGHIresult
1XXXXXXXX1
01XXXXXXX1
001XXXXXX1
0001XXXXX1
00001XXXX1
000001XXX1
0000001XX1
00000001X1
0000000011
0000000000
581 or $term =~ s{ ue \Z }{u}x
582 or $term =~ s{ ([auy])e \Z }{$1}x
583  
584 or $term =~ s{ ski \Z }{ski}x
585 or $term =~ s{ [^b]i \Z }{}x
586  
587 or $term =~ s{ ([^e])e \Z }{$1}x
588  
589 or $term =~ m{ er \Z }x
590 or $term =~ s{ (.[bdghklmnprstz][o]([n])) \Z }{$1}x
591  
592 or $term =~ s{ ([^aeiou][aeiouy]([bcdlgmnprstv])) \Z }{$1$2}x
593  
594 or $term =~ s{ e \Z }{}x;
595  
596 144 return $term;
597 33 };
598  
599 # Report status of verb...
600 sub is_plural {
601 219 ▶ my ($self) = @_;
Subroutine is_plural: called CC=1 SCAR=0.0
602 219 return Lingua::EN::Inflexion::Verbs::is_plural( $term_of{$self} );
603 }
604  
605 sub is_singular {
606 230 ▶ my ($self) = @_;
Subroutine is_singular: called CC=1 SCAR=0.0
607 230 return Lingua::EN::Inflexion::Verbs::is_singular( $term_of{$self} );
608 }
609  
610 sub is_present {
611 0 ▶ my ($self) = @_;
Subroutine is_present: not called CC=1 SCAR=6.9
612 0 return Lingua::EN::Inflexion::Verbs::is_present( $term_of{$self} );
613 }
614  
615 sub is_past {
616 0 ▶ my ($self) = @_;
Subroutine is_past: not called CC=1 SCAR=6.9
617 0 return Lingua::EN::Inflexion::Verbs::is_past( $term_of{$self} );
618 }
619  
620 sub is_pres_part {
621 0 ▶ my ($self) = @_;
Subroutine is_pres_part: not called CC=1 SCAR=6.9
622 0 return Lingua::EN::Inflexion::Verbs::is_pres_part( $term_of{$self} );
623 }
624  
625 sub is_past_part {
626 0 ▶ my ($self) = @_;
Subroutine is_past_part: not called CC=1 SCAR=6.9
627 0 return Lingua::EN::Inflexion::Verbs::is_past_part( $term_of{$self} );
628 }
629  
630 # Report part-of-speech...
631 0 ▶sub is_verb { 1 }
Subroutine is_verb: not called CC=1 SCAR=6.9
632  
633  
634 # Conversions...
635  
636 sub singular {
637 1001 ▶ my $self = shift;
Subroutine singular: called CC=10 SCAR=23.1
638 1001 ▶ my $person = shift // 0;
Condition100%2/2
shift() // 0
l!l
424577
MC/DC100%1/1
shift() // 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
639 1001 my $term = $term_of{$self};
640  
641 # Find the right inflexion...
642 1001 my $inflexion;
643  
644 # "To be" is special...
645 1001 ▶ if ($self =~ m{ \A (?: is | am | are ) \Z }x) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self =~ / \A (?: is | am | are ) \Z /x) { } 18 983 1001
elsif ($person == 3 or $person == 0) { } 707 276 983
646 18 ▶ return $person == 0 ? $term
Branch: 3 branches
BranchTrueFalseTotal
$person == 0 ? : 6 12 18
$person == 2 || !$self->is_singular ? : 4 8 12
$person == 1 ? : 4 4 8
Condition66%2/3
$person == 2 or not $self->is_singular
l!l&&r!l&&!r
408
MC/DC50%1/2
$person == 2 or not $self->is_singular
$person == 2 not $self->is_singular
Truth table66%2/3
A or not(B)
A= $person == 2B= not $self->is_singular
ABresult
1X1
011
000
647 : $person == 2 || !$self->is_singular ? 'are'
648 : $person == 1 ? 'am'
649 : 'is'
650 }
651  
652 # Third person uses the "notional" singular inflexion...
653 ▶ elsif ($person == 3 || $person == 0) {
Condition100%3/3
$person == 3 or $person == 0
l!l&&r!l&&!r
136571276
MC/DC100%2/2
$person == 3 or $person == 0
$person == 3 $person == 0
Truth table100%3/3
A or B
A= $person == 3B= $person == 0
ABresult
1X1
011
000
654 # Is it a known inflexion???
655 707 my $known = Lingua::EN::Inflexion::Verbs::convert_to_singular( $term );
656  
657 # Return with case-following...
658 707 ▶ return $encase->( $term, $known eq '_' ? $term : $known );
Branch: 1 branch
BranchTrueFalseTotal
$known eq '_' ? : 0 707 707
659 }
660  
661 # First and second person always use the uninflected (i.e. "notional "plural" form)...
662 else {
663 276 return plural($self);
664 }
665 }
666  
667 sub plural {
668 4447 ▶ my ($self) = @_;
Subroutine plural: called CC=2 SCAR=6.9
669 4447 my $term = $term_of{$self};
670  
671 # Is it a known inflexion???
672 4447 my $known = Lingua::EN::Inflexion::Verbs::convert_to_plural( $term );
673  
674 # Return with case-following...
675 4447 ▶ return $encase->( $term, $known eq '_' ? $term : $known );
Branch: 1 branch
BranchTrueFalseTotal
$known eq '_' ? : 1 4446 4447
676 }
677  
678 sub past {
679 1057 ▶ my ($self) = @_;
Subroutine past: called CC=3 SCAR=11.0
680 1057 my $term = $term_of{$self};
681 1057 my $root = $self->plural;
682  
683 # Is it a known inflexion???
684 1057 my $inflexion = Lingua::EN::Inflexion::Verbs::convert_to_past( $term );
685  
686 1057 ▶ if ($inflexion eq '_') {
Branch: 1 branch
BranchTrueFalseTotal
if ($inflexion eq "_") 48 1009 1057
687 48 $inflexion = Lingua::EN::Inflexion::Verbs::convert_to_past( $root );
688 }
689  
690 # Otherwise use the standard pattern...
691 1057 ▶ if ($inflexion eq '_') {
Branch: 1 branch
BranchTrueFalseTotal
if ($inflexion eq "_") 48 1009 1057
692 48 $inflexion = $truncate->($root) . 'ed';
693 }
694  
695 # Return with case-following...
696 1057 return $encase->( $term, $inflexion );
697 }
698  
699 sub pres_part {
700 1020 ▶ my ($self) = @_;
Subroutine pres_part: called CC=2 SCAR=6.9
701 1020 my $term = $term_of{$self};
702 1020 my $root = $self->plural;
703  
704 # Is it a known inflexion???
705 1020 my $inflexion = Lingua::EN::Inflexion::Verbs::convert_to_pres_part( $root );
706  
707 # Otherwise use the standard pattern...
708 1020 ▶ if ($inflexion eq '_') {
Branch: 1 branch
BranchTrueFalseTotal
if ($inflexion eq "_") 48 972 1020
709 48 $inflexion = $truncate->($root) . 'ing';
710 }
711  
712 # Return with case-following...
713 1020 return $encase->( $term, $inflexion );
714 }
715  
716 sub past_part {
717 1082 ▶ my ($self) = @_;
Subroutine past_part: called CC=2 SCAR=6.9
718 1082 my $term = $term_of{$self};
719 1082 my $root = $self->plural;
720  
721 # Is it a known inflexion???
722 1082 my $inflexion = Lingua::EN::Inflexion::Verbs::convert_to_past_part( $root );
723  
724 # Otherwise use the standard pattern...
725 1082 ▶ if ($inflexion eq '_') {
Branch: 1 branch
BranchTrueFalseTotal
if ($inflexion eq "_") 48 1034 1082
726 48 $inflexion = $truncate->($root) . 'ed';
727 }
728  
729 # Return with case-following...
730 1082 return $encase->( $term, $inflexion );
731 }
732  
733 sub indefinite {
734 0 ▶ my ($self, $count) = @_;
Subroutine indefinite: not called CC=3 SCAR=24.8
735 0 ▶ $count //= 1;
Condition0%0/2
$count //= 1
l!l
00
MC/DC0%0/1
$count //= 1
$count
Truth table0%0/2
A
A= $count
Aresult
11
00
736  
737 0 ▶ return $count == 1 ? $self->singular
Branch: 1 branch
BranchTrueFalseTotal
$count == 1 ? : 0 0 0
738 : $self->plural;
739 }
740  
741 sub as_regex {
742 0 ▶ my ($self) = @_;
Subroutine as_regex: not called CC=1 SCAR=6.9
743 0 my %seen;
744 0 my $pattern = join '|', map { quotemeta } reverse sort grep { !$seen{$_}++ }
745 ($self->singular, $self->plural,
746 $self->past, $self->past_part, $self->classical->pres_part);
747 0 return qr{$pattern}i;
748 }
749  
750  
751  
752  
753 package Lingua::EN::Inflexion::Adjective;
754 33 our @ISA = 'Lingua::EN::Inflexion::Term';
755  
756 # Load adjective tables, always taking first option...
757 33 my @adjectives = (
758 # Determiners...
759 'a' => 'some',
760 'an' => 'some',
761  
762 # Demonstratives...
763 'that' => 'those',
764 'this' => 'these',
765  
766 # Possessives...
767 'my' => 'our',
768 'your' => 'your',
769 'their' => 'their',
770 'her' => 'their',
771 'his' => 'their',
772 'its' => 'their',
773 );
774  
775 33 my (%adj_plural_of, %adj_singular_of, %adj_is_plural, %adj_is_singular);
776 33 ▶while (my ($sing, $plur) = splice @adjectives, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@adjectives, 0, 2)) 330 33 363
777 330 $adj_is_singular{$sing} = 1;
778 330 ▶ $adj_singular_of{$plur} //= $sing;
Condition66%2/3
$adj_singular_of{$plur} //= $sing
l!l&&r!l&&!r
1321980
MC/DC0%0/2
$adj_singular_of{$plur} //= $sing
$adj_singular_of{$plur} $sing
Truth table66%2/3
A //= B
A= $adj_singular_of{$plur}B= $sing
ABresult
1X1
011
000
779  
780 330 $adj_is_plural{$plur} = 1;
781 330 ▶ $adj_plural_of{$sing} //= $plur;
Condition33%1/3
$adj_plural_of{$sing} //= $plur
l!l&&r!l&&!r
03300
MC/DC0%0/2
$adj_plural_of{$sing} //= $plur
$adj_plural_of{$sing} $plur
Truth table33%1/3
A //= B
A= $adj_plural_of{$sing}B= $plur
ABresult
1X1
011
000
782 }
783  
784 33 my %adj_possessive_inflexion = (
785 # Term 0TH 1ST 2ND 3RD
786 'my' => { singular => [qw< my my your its >],
787 plural => [qw< our our your their >],
788 },
789 'your' => { singular => [qw< your my your its >],
790 plural => [qw< your our your their >],
791 },
792 'her' => { singular => [qw< her my your her >],
793 plural => [qw< their our your their >],
794 },
795 'his' => { singular => [qw< his my your his >],
796 plural => [qw< their our your their >],
797 },
798 'its' => { singular => [qw< its my your its >],
799 plural => [qw< their our your their >],
800 },
801 'our' => { singular => [qw< my my your its >],
802 plural => [qw< our our your their >],
803 },
804 'their' => { singular => [qw< its my your its >],
805 plural => [qw< their our your their >],
806 },
807 );
808  
809  
810 # Report part-of-speech...
811 0 ▶sub is_adj { 1 }
Subroutine is_adj: not called CC=1 SCAR=6.9
812  
813  
814 # Report number of adjective...
815 sub is_plural {
816 18 ▶ my ($self) = @_;
Subroutine is_plural: called CC=4 SCAR=15.2
817 18 my $term = $term_of{$self};
818 return $adj_is_plural{$term} || $adj_is_plural{lc $term}
819 18 ▶ || !$adj_is_singular{$term} && !$adj_is_singular{lc $term};
Condition55%5/9
$adj_is_plural{$term} || $adj_is_plural{lc $term} || !($adj_is_singular{$term} || $adj_is_singular{lc $term})
l!l&&r!l&&!r
6120
$adj_is_plural{$term} or $adj_is_plural{lc $term}
l!l&&r!l&&!r
6012
$adj_is_singular{$term} || $adj_is_singular{lc $term}
l!l&&r!l&&!r
0012
MC/DC0%0/4
$adj_is_plural{$term} || $adj_is_plural{lc $term} || !($adj_is_singular{$term} || $adj_is_singular{lc $term})
$adj_is_plural{$term} $adj_is_plural{lc $term} $adj_is_singular{$term} $adj_is_singular{lc $term}
Truth table40%2/5
A or B || not(C || D)
A= $adj_is_plural{$term}B= $adj_is_plural{lc $term}C= $adj_is_singular{$term}D= $adj_is_singular{lc $term}
ABCDresult
1XXX1
01XX1
00001
001X0
00010
820 }
821  
822 sub is_singular {
823 21 ▶ my ($self) = @_;
Subroutine is_singular: called CC=4 SCAR=15.2
824 21 my $term = $term_of{$self};
825 return $adj_is_singular{$term} || $adj_is_singular{lc $term}
826 21 ▶ || !$adj_is_plural{$term} && !$adj_is_plural{lc $term};
Condition55%5/9
$adj_is_singular{$term} || $adj_is_singular{lc $term} || !($adj_is_plural{$term} || $adj_is_plural{lc $term})
l!l&&r!l&&!r
9120
$adj_is_singular{$term} or $adj_is_singular{lc $term}
l!l&&r!l&&!r
9012
$adj_is_plural{$term} || $adj_is_plural{lc $term}
l!l&&r!l&&!r
0012
MC/DC0%0/4
$adj_is_singular{$term} || $adj_is_singular{lc $term} || !($adj_is_plural{$term} || $adj_is_plural{lc $term})
$adj_is_singular{$term} $adj_is_singular{lc $term} $adj_is_plural{$term} $adj_is_plural{lc $term}
Truth table40%2/5
A or B || not(C || D)
A= $adj_is_singular{$term}B= $adj_is_singular{lc $term}C= $adj_is_plural{$term}D= $adj_is_plural{lc $term}
ABCDresult
1XXX1
01XX1
00001
001X0
00010
827 }
828  
829  
830 # Conversions...
831  
832 sub singular {
833 49 ▶ my $self = shift;
Subroutine singular: called CC=7 SCAR=19.5
834 49 ▶ my $person = shift // 0;
Condition100%2/2
shift() // 0
l!l
1237
MC/DC100%1/1
shift() // 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
835  
836 49 my $term = $term_of{$self};
837  
838 49 my $singular;
839  
840 # Is it a composite possessive form???
841 49 ▶ if ($term =~ m{ \A (.*) 's? \Z }ixms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term =~ / \A (.*) 's? \Z /imsx) { } 21 28 49
842 21 my $word = Lingua::EN::Inflexion::Noun->new($1);
843 21 ▶ $singular = $word->is_singular ? $term : $word->singular . q{'s};
Branch: 1 branch
BranchTrueFalseTotal
$word->is_singular ? : 5 16 21
844 }
845  
846 # Otherwise, it's either a known inflexion, or uninflected...
847 else {
848 $singular = $adj_possessive_inflexion{lc $term}{singular}[$person]
849 // $adj_singular_of{$term}
850 28 ▶ // $adj_singular_of{lc $term}
Condition77%7/9
(($adj_possessive_inflexion{lc $term}{"singular"}[$person] // $adj_singular_of{$term}) // $adj_singular_of{lc $term}) // $term
l!l&&r!l&&!r
2260
($adj_possessive_inflexion{lc $term}{"singular"}[$person] // $adj_singular_of{$term}) // $adj_singular_of{lc $term}
l!l&&r!l&&!r
2206
$adj_possessive_inflexion{lc $term}{"singular"}[$person] // $adj_singular_of{$term}
l!l&&r!l&&!r
1936
MC/DC0%0/4
(($adj_possessive_inflexion{lc $term}{"singular"}[$person] // $adj_singular_of{$term}) // $adj_singular_of{lc $term}) // $term
$adj_possessive_inflexion{lc $term}{"singular"}[$person] $adj_singular_of{$term} $adj_singular_of{lc $term} $term
Truth table60%3/5
A // B // C // D
A= $adj_possessive_inflexion{lc $term}{"singular"}[$person]B= $adj_singular_of{$term}C= $adj_singular_of{lc $term}D= $term
ABCDresult
1XXX1
01XX1
001X1
00011
00000
851 // $term;
852 }
853  
854 49 return $encase->($term, $singular);
855 }
856  
857 sub plural {
858 64 ▶ my $self = shift;
Subroutine plural: called CC=8 SCAR=20.8
859 64 ▶ my $person = shift // 0;
Condition100%2/2
shift() // 0
l!l
2143
MC/DC100%1/1
shift() // 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
860 64 my $term = $term_of{$self};
861 64 my $plural = $term;
862  
863 # Is it an unequivocally plural possessive form???
864 64 ▶ if ($term =~ m{ ' \Z }ixms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($term =~ / ' \Z /imsx) { } 4 60 64
elsif ($term =~ / \A (.*) 's \Z /imsx) { } 17 43 60
865 4 return $term;
866 }
867 # Is it general possessive form???
868 elsif ($term =~ m{ \A (.*) 's \Z }ixms) {
869 17 my $word = Lingua::EN::Inflexion::Noun->new($1);
870 17 ▶ $plural = $word->is_plural() ? $term : $word->plural . q{'s};
Branch: 1 branch
BranchTrueFalseTotal
$word->is_plural ? : 1 16 17
871 17 $plural =~ s{ s's \Z }{s'}xms
872 }
873  
874 # Otherwise, it's either a known inflexion, or uninflected...
875 else {
876 $plural = $adj_possessive_inflexion{lc $term}{plural}[$person]
877 // $adj_plural_of{$term}
878 43 ▶ // $adj_plural_of{lc $term}
Condition77%7/9
(($adj_possessive_inflexion{lc $term}{"plural"}[$person] // $adj_plural_of{$term}) // $adj_plural_of{lc $term}) // $term
l!l&&r!l&&!r
3760
($adj_possessive_inflexion{lc $term}{"plural"}[$person] // $adj_plural_of{$term}) // $adj_plural_of{lc $term}
l!l&&r!l&&!r
3706
$adj_possessive_inflexion{lc $term}{"plural"}[$person] // $adj_plural_of{$term}
l!l&&r!l&&!r
3346
MC/DC0%0/4
(($adj_possessive_inflexion{lc $term}{"plural"}[$person] // $adj_plural_of{$term}) // $adj_plural_of{lc $term}) // $term
$adj_possessive_inflexion{lc $term}{"plural"}[$person] $adj_plural_of{$term} $adj_plural_of{lc $term} $term
Truth table60%3/5
A // B // C // D
A= $adj_possessive_inflexion{lc $term}{"plural"}[$person]B= $adj_plural_of{$term}C= $adj_plural_of{lc $term}D= $term
ABCDresult
1XXX1
01XX1
001X1
00011
00000
879 // $term;
880 }
881  
882 60 return $encase->($term, $plural);
883 }
884  
885  
886 33 1; # Magic true value required at end of module
887 __END__
« Inflexion/Indefinite.pm ↑ Summary