line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::Lingua::EN::Inflect; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
204246
|
use strict; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
242
|
|
4
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
219
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
33
|
use vars qw($VERSION); |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
493
|
|
7
|
|
|
|
|
|
|
$VERSION = 0.03; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Template::Plugin; |
10
|
6
|
|
|
6
|
|
39
|
use base qw(Template::Plugin); |
|
6
|
|
|
|
|
67
|
|
|
6
|
|
|
|
|
6205
|
|
11
|
6
|
|
|
6
|
|
41602
|
use Lingua::EN::Inflect qw( inflect ); |
|
6
|
|
|
|
|
155607
|
|
|
6
|
|
|
|
|
6194
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
10
|
|
|
10
|
1
|
36246
|
my ($class, $context, $options) = @_; |
15
|
10
|
|
|
|
|
19
|
my $filter_factory; |
16
|
|
|
|
|
|
|
my $plugin; |
17
|
|
|
|
|
|
|
|
18
|
10
|
50
|
|
|
|
39
|
if ($options) { |
19
|
|
|
|
|
|
|
# create a closure to generate filters with additional options |
20
|
|
|
|
|
|
|
$filter_factory = sub { |
21
|
0
|
|
|
0
|
|
0
|
my $context = shift; |
22
|
0
|
0
|
|
|
|
0
|
my $filtopt = ref $_[-1] eq 'HASH' ? pop : {}; |
23
|
0
|
|
|
|
|
0
|
@$filtopt{ keys %$options } = values %$options; |
24
|
|
|
|
|
|
|
return sub { |
25
|
0
|
|
|
|
|
0
|
tt_inflect(@_, $filtopt); |
26
|
0
|
|
|
|
|
0
|
}; |
27
|
0
|
|
|
|
|
0
|
}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# and a closure to represent the plugin |
30
|
|
|
|
|
|
|
$plugin = sub { |
31
|
0
|
0
|
|
0
|
|
0
|
my $plugopt = ref $_[-1] eq 'HASH' ? pop : {}; |
32
|
0
|
|
|
|
|
0
|
@$plugopt{ keys %$options } = values %$options; |
33
|
0
|
|
|
|
|
0
|
tt_inflect(@_, $plugopt); |
34
|
0
|
|
|
|
|
0
|
}; |
35
|
|
|
|
|
|
|
} else { |
36
|
|
|
|
|
|
|
# simple filter factory closure (no legacy options from constructor) |
37
|
|
|
|
|
|
|
$filter_factory = sub { |
38
|
7
|
|
|
7
|
|
385
|
my $context = shift; |
39
|
7
|
100
|
|
|
|
24
|
my $filtopt = ref $_[-1] eq 'HASH' ? pop : {}; |
40
|
|
|
|
|
|
|
return sub { |
41
|
7
|
|
|
|
|
125
|
tt_inflect(@_, $filtopt); |
42
|
7
|
|
|
|
|
36
|
}; |
43
|
10
|
|
|
|
|
62
|
}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# plugin without options can be static |
46
|
10
|
|
|
|
|
25
|
$plugin = \&tt_inflect; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# now define the filter and return the plugin |
50
|
10
|
|
|
|
|
58
|
$context->define_filter('inflect', [ $filter_factory => 1 ]); |
51
|
10
|
|
|
|
|
292
|
return bless $plugin, $class; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub tt_inflect { |
55
|
7
|
50
|
|
7
|
1
|
20
|
my $options = ref $_[-1] eq 'HASH' ? pop : {}; |
56
|
7
|
|
|
|
|
14
|
my $number = $options->{ number }; |
57
|
7
|
100
|
|
|
|
24
|
Lingua::EN::Inflect::NUM($number) if $number; |
58
|
7
|
|
|
|
|
44
|
my $out = inflect(join('', @_)); |
59
|
7
|
|
|
|
|
7262
|
return $out; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
0
|
1
|
0
|
sub classical { shift; return Lingua::EN::Inflect::classical(@_); } |
|
0
|
|
|
|
|
0
|
|
63
|
0
|
|
|
0
|
1
|
0
|
sub def_noun { shift; return Lingua::EN::Inflect::def_noun(@_); } |
|
0
|
|
|
|
|
0
|
|
64
|
0
|
|
|
0
|
1
|
0
|
sub def_verb { shift; return Lingua::EN::Inflect::def_verb(@_); } |
|
0
|
|
|
|
|
0
|
|
65
|
0
|
|
|
0
|
1
|
0
|
sub def_adj { shift; return Lingua::EN::Inflect::def_adj(@_); } |
|
0
|
|
|
|
|
0
|
|
66
|
0
|
|
|
0
|
1
|
0
|
sub def_a { shift; return Lingua::EN::Inflect::def_a(@_); } |
|
0
|
|
|
|
|
0
|
|
67
|
0
|
|
|
0
|
1
|
0
|
sub def_an { shift; return Lingua::EN::Inflect::def_an(@_); } |
|
0
|
|
|
|
|
0
|
|
68
|
0
|
|
|
0
|
1
|
0
|
sub A { shift; return Lingua::EN::Inflect::A(@_); } |
|
0
|
|
|
|
|
0
|
|
69
|
0
|
|
|
0
|
1
|
0
|
sub AN { shift; return Lingua::EN::Inflect::AN(@_); } |
|
0
|
|
|
|
|
0
|
|
70
|
5
|
|
|
5
|
1
|
19915
|
sub NO { shift; return Lingua::EN::Inflect::NO(@_); } |
|
5
|
|
|
|
|
110
|
|
71
|
0
|
|
|
0
|
1
|
0
|
sub NUM { shift; return Lingua::EN::Inflect::NUM(@_); } |
|
0
|
|
|
|
|
0
|
|
72
|
6
|
|
|
6
|
1
|
944
|
sub NUMWORDS { shift; return Lingua::EN::Inflect::NUMWORDS(@_); } |
|
6
|
|
|
|
|
17
|
|
73
|
6
|
|
|
6
|
1
|
510
|
sub ORD { return Lingua::EN::Inflect::ORD($_[1]); } |
74
|
0
|
|
|
0
|
1
|
|
sub PART_PRES { shift; return Lingua::EN::Inflect::PART_PRES(@_); } |
|
0
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
1
|
|
sub PL { shift; return Lingua::EN::Inflect::PL(@_); } |
|
0
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
1
|
|
sub PL_N { shift; return Lingua::EN::Inflect::PL_N(@_); } |
|
0
|
|
|
|
|
|
|
77
|
0
|
|
|
0
|
1
|
|
sub PL_V { shift; return Lingua::EN::Inflect::PL_V(@_); } |
|
0
|
|
|
|
|
|
|
78
|
0
|
|
|
0
|
1
|
|
sub PL_ADJ { shift; return Lingua::EN::Inflect::PL_ADJ(@_); } |
|
0
|
|
|
|
|
|
|
79
|
0
|
|
|
0
|
1
|
|
sub PL_eq { shift; return Lingua::EN::Inflect::PL_eq(@_); } |
|
0
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
1
|
|
sub PL_N_eq { shift; return Lingua::EN::Inflect::PL_N_eq(@_); } |
|
0
|
|
|
|
|
|
|
81
|
0
|
|
|
0
|
1
|
|
sub PL_V_eq { shift; return Lingua::EN::Inflect::PL_V_eq(@_); } |
|
0
|
|
|
|
|
|
|
82
|
0
|
|
|
0
|
1
|
|
sub PL_ADJ_eq { shift; return Lingua::EN::Inflect::PL_ADJ_eq(@_); } |
|
0
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |