line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Plugin::Lingua::EN::Inflect; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
156489
|
use strict; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
414
|
|
4
|
7
|
|
|
7
|
|
36
|
use warnings; |
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
269
|
|
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
33
|
use vars qw($VERSION); |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
552
|
|
7
|
|
|
|
|
|
|
$VERSION = 0.04; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Template::Plugin; |
10
|
7
|
|
|
7
|
|
34
|
use base qw(Template::Plugin); |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
4026
|
|
11
|
7
|
|
|
7
|
|
36335
|
use Lingua::EN::Inflect qw( inflect ); |
|
7
|
|
|
|
|
131806
|
|
|
7
|
|
|
|
|
5988
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
10
|
|
|
10
|
1
|
27083
|
my ($class, $context, $options) = @_; |
15
|
10
|
|
|
|
|
15
|
my $filter_factory; |
16
|
|
|
|
|
|
|
my $plugin; |
17
|
|
|
|
|
|
|
|
18
|
10
|
50
|
|
|
|
24
|
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
|
|
298
|
my $context = shift; |
39
|
7
|
100
|
|
|
|
15
|
my $filtopt = ref $_[-1] eq 'HASH' ? pop : {}; |
40
|
|
|
|
|
|
|
return sub { |
41
|
7
|
|
|
|
|
105
|
tt_inflect(@_, $filtopt); |
42
|
7
|
|
|
|
|
26
|
}; |
43
|
10
|
|
|
|
|
49
|
}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# plugin without options can be static |
46
|
10
|
|
|
|
|
17
|
$plugin = \&tt_inflect; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# now define the filter and return the plugin |
50
|
10
|
|
|
|
|
41
|
$context->define_filter('inflect', [ $filter_factory => 1 ]); |
51
|
10
|
|
|
|
|
231
|
return bless $plugin, $class; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub tt_inflect { |
55
|
7
|
50
|
|
7
|
1
|
17
|
my $options = ref $_[-1] eq 'HASH' ? pop : {}; |
56
|
7
|
|
|
|
|
8
|
my $number = $options->{ number }; |
57
|
7
|
100
|
|
|
|
19
|
Lingua::EN::Inflect::NUM($number) if $number; |
58
|
7
|
|
|
|
|
33
|
my $out = inflect(join('', @_)); |
59
|
7
|
|
|
|
|
4945
|
return $out; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
2
|
1
|
369
|
sub classical { shift; return Lingua::EN::Inflect::classical(@_); } |
|
2
|
|
|
|
|
10
|
|
63
|
1
|
|
|
1
|
1
|
2753
|
sub def_noun { shift; return Lingua::EN::Inflect::def_noun(@_); } |
|
1
|
|
|
|
|
5
|
|
64
|
1
|
|
|
1
|
1
|
360
|
sub def_verb { shift; return Lingua::EN::Inflect::def_verb(@_); } |
|
1
|
|
|
|
|
6
|
|
65
|
1
|
|
|
1
|
1
|
1033
|
sub def_adj { shift; return Lingua::EN::Inflect::def_adj(@_); } |
|
1
|
|
|
|
|
4
|
|
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
|
4
|
|
|
4
|
1
|
1412
|
sub A { shift; return Lingua::EN::Inflect::A(@_); } |
|
4
|
|
|
|
|
13
|
|
69
|
2
|
|
|
2
|
1
|
833
|
sub AN { shift; return Lingua::EN::Inflect::AN(@_); } |
|
2
|
|
|
|
|
9
|
|
70
|
12
|
|
|
12
|
1
|
7649
|
sub NO { shift; return Lingua::EN::Inflect::NO(@_); } |
|
12
|
|
|
|
|
36
|
|
71
|
2
|
|
|
2
|
1
|
620
|
sub NUM { shift; return Lingua::EN::Inflect::NUM(@_); } |
|
2
|
|
|
|
|
7
|
|
72
|
8
|
|
|
8
|
1
|
1730
|
sub NUMWORDS { shift; return Lingua::EN::Inflect::NUMWORDS(@_); } |
|
8
|
|
|
|
|
23
|
|
73
|
8
|
|
|
8
|
1
|
787
|
sub ORD { return Lingua::EN::Inflect::ORD($_[1]); } |
74
|
1
|
|
|
1
|
1
|
256
|
sub PART_PRES { shift; return Lingua::EN::Inflect::PART_PRES(@_); } |
|
1
|
|
|
|
|
6
|
|
75
|
8
|
|
|
8
|
1
|
2473
|
sub PL { shift; return Lingua::EN::Inflect::PL(@_); } |
|
8
|
|
|
|
|
18
|
|
76
|
2
|
|
|
2
|
1
|
1167
|
sub PL_N { shift; return Lingua::EN::Inflect::PL_N(@_); } |
|
2
|
|
|
|
|
10
|
|
77
|
2
|
|
|
2
|
1
|
679
|
sub PL_V { shift; return Lingua::EN::Inflect::PL_V(@_); } |
|
2
|
|
|
|
|
9
|
|
78
|
2
|
|
|
2
|
1
|
799
|
sub PL_ADJ { shift; return Lingua::EN::Inflect::PL_ADJ(@_); } |
|
2
|
|
|
|
|
9
|
|
79
|
1
|
|
|
1
|
1
|
377
|
sub PL_eq { shift; return Lingua::EN::Inflect::PL_eq(@_); } |
|
1
|
|
|
|
|
6
|
|
80
|
2
|
|
|
2
|
1
|
2496
|
sub PL_N_eq { shift; return Lingua::EN::Inflect::PL_N_eq(@_); } |
|
2
|
|
|
|
|
6
|
|
81
|
2
|
|
|
2
|
1
|
762
|
sub PL_V_eq { shift; return Lingua::EN::Inflect::PL_V_eq(@_); } |
|
2
|
|
|
|
|
7
|
|
82
|
2
|
|
|
2
|
1
|
701
|
sub PL_ADJ_eq { shift; return Lingua::EN::Inflect::PL_ADJ_eq(@_); } |
|
2
|
|
|
|
|
7
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |