| 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
| |||||||||||||||
| 49 | 124 | ▶ | return $plural if $plural eq 'us'; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 50 | |||||||||||||||
| 51 | 124 | ▶ | if ($word =~ /es$/) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 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__ | ||||||||||||||