blib/lib/Acme/Lingua/EN/Inflect/Modern.pm

filter: Statementstmt 100% 40 / 40 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 96.5% 56 / 58 CC 5 SCAR 8.9
CC
5
Cov
96%
_PL_noun
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
↑ Summary
1 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Acme::Lingua::EN::Inflect::Modern 0.008;
4  
5 11 ▶use parent qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # ABSTRACT: modernize Lingua::EN::Inflect rule's
7  
8 11 ▶use Lingua::EN::Inflect 1.86 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use Sub::Override 0.07;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 11 ▶BEGIN { our %EXPORT_TAGS = %Lingua::EN::Inflect::EXPORT_TAGS };
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 11 Exporter::export_ok_tags(qw( ALL ));
14  
15 #pod =head1 SYNOPSIS
16 #pod
17 #pod Lingua::EN::Inflect is great for converting singular word's to plural's, but
18 #pod does not always match modern usage. This module corrects the most common
19 #pod case's.
20 #pod
21 #pod See L<Lingua::EN::Inflect> for information on using this module, which has an
22 #pod identical interface.
23 #pod
24 #pod =cut
25  
26 11 my %todo = map { map { $_ => 1 } @$_ }
27 values %Lingua::EN::Inflect::EXPORT_TAGS;
28  
29 11 for my $routine (keys %todo) {
30 11 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 253 ▶ *{__PACKAGE__ . '::' . $routine} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
32 142 my $override = Sub::Override->new(
33 'Lingua::EN::Inflect::_PL_noun' => \&_PL_noun
34 );
35  
36 142 Lingua::EN::Inflect->can($routine)->(@_);
37 253 };
38 }
39  
40 11 my $original_PL_noun;
41 11 ▶BEGIN { $original_PL_noun = \&Lingua::EN::Inflect::_PL_noun; }
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 124 ▶sub _PL_noun {
Subroutine _PL_noun: called CC=5 SCAR=16.2
44 124 my ($word, $number) = @_;
45  
46 124 my $plural = $original_PL_noun->($word, $number);
47  
48 124 ▶ return $plural if $plural eq 'his';
Branch: 1 branch
BranchTrueFalseTotal
if $plural eq "his" 0 124 124
49 124 ▶ return $plural if $plural eq 'us';
Branch: 1 branch
BranchTrueFalseTotal
if $plural eq "us" 0 124 124
50  
51 124 ▶ if ($word =~ /es$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($word =~ /es$/) { } 5 119 124
elsif ($word =~ /y$/) { } 21 98 119
52 5 $plural =~ s/e(s$|s\|)/'$1/;
53 } elsif ($word =~ /y$/) {
54 21 $plural =~ s/(?:ie|y)?(s$|s\|)/y'$1/;
55 } else {
56 98 $plural =~ s/(s$|s\|)/'$1/;
57 }
58  
59 124 return $plural;
60 }
61  
62 #pod =head1 BUG'S
63 #pod
64 #pod Please report any bug's or feature request's via the GitHub issue tracker at
65 #pod L<https://github.com/rjbs/Acme-Lingua-EN-Inflect-Modern/issues>. I will be
66 #pod notified, and then you'll automatically be notified of progress on
67 #pod your bug as I make change's.
68 #pod
69 #pod =cut
70  
71 11 1;
72  
73 __END__
↑ Summary