| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package UR::Vocabulary; |
|
3
|
|
|
|
|
|
|
|
|
4
|
7
|
|
|
7
|
|
224
|
use strict; |
|
|
7
|
|
|
|
|
9
|
|
|
|
7
|
|
|
|
|
185
|
|
|
5
|
7
|
|
|
7
|
|
21
|
use warnings; |
|
|
7
|
|
|
|
|
12
|
|
|
|
7
|
|
|
|
|
202
|
|
|
6
|
7
|
|
|
7
|
|
26
|
use Lingua::EN::Inflect ("PL_V","PL"); |
|
|
7
|
|
|
|
|
9
|
|
|
|
7
|
|
|
|
|
3380
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require UR; |
|
9
|
|
|
|
|
|
|
our $VERSION = "0.46"; # UR $VERSION; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
UR::Object::Type->define( |
|
12
|
|
|
|
|
|
|
class_name => 'UR::Vocabulary', |
|
13
|
|
|
|
|
|
|
is => ['UR::Singleton'], |
|
14
|
|
|
|
|
|
|
doc => 'A word in the vocabulary of a given namespace.', |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub get_words_with_special_case { |
|
18
|
3
|
|
|
3
|
0
|
43
|
shift->_singleton_class_name->_words_with_special_case; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _words_with_special_case { |
|
22
|
3
|
|
|
3
|
|
6
|
return ('UR'); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub convert_to_title_case { |
|
26
|
480
|
|
|
480
|
0
|
1177
|
my $conversion_hashref = shift->_words_with_special_case_hashref; |
|
27
|
480
|
|
|
|
|
379
|
my @results; |
|
28
|
480
|
|
|
|
|
519
|
for my $word_in(@_) { |
|
29
|
491
|
|
|
|
|
475
|
my $word = lc($word_in); |
|
30
|
491
|
50
|
|
|
|
720
|
if (my $uc = $conversion_hashref->{$word}) { |
|
31
|
0
|
|
|
|
|
0
|
push @results, $uc; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
else { |
|
34
|
491
|
|
|
|
|
832
|
push @results, ucfirst($word); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
} |
|
37
|
480
|
50
|
66
|
|
|
1711
|
return $results[0] if @results == 1 and !wantarray; |
|
38
|
480
|
|
|
|
|
1831
|
return @results; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub convert_to_special_case { |
|
42
|
0
|
|
|
0
|
0
|
0
|
my $conversion_hashref = shift->_words_with_special_case_hashref; |
|
43
|
0
|
|
|
|
|
0
|
my @results; |
|
44
|
0
|
|
|
|
|
0
|
for my $word_in(@_) { |
|
45
|
0
|
|
|
|
|
0
|
my $word = lc($word_in); |
|
46
|
0
|
0
|
|
|
|
0
|
if (my $sc = $conversion_hashref->{$word}) { |
|
47
|
0
|
|
|
|
|
0
|
push @results, $sc; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
else { |
|
50
|
0
|
|
|
|
|
0
|
push @results, $word_in; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
} |
|
53
|
0
|
0
|
0
|
|
|
0
|
return $results[0] if @results == 1 and !wantarray; |
|
54
|
0
|
|
|
|
|
0
|
return @results; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _words_with_special_case_hashref { |
|
59
|
480
|
|
|
480
|
|
7636
|
my $self = shift->_singleton_object; |
|
60
|
480
|
|
|
|
|
517
|
my $hashref = $self->{_words_with_special_case_hashref}; |
|
61
|
480
|
100
|
|
|
|
838
|
return $hashref if $hashref; |
|
62
|
3
|
|
|
|
|
8
|
$hashref = { map { lc($_) => $_ } $self->get_words_with_special_case }; |
|
|
3
|
|
|
|
|
20
|
|
|
63
|
3
|
|
|
|
|
7
|
$self->{_words_with_special_case_hashref} = $hashref; |
|
64
|
3
|
|
|
|
|
6
|
return $hashref; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub singular_to_plural { |
|
68
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
69
|
0
|
|
|
|
|
|
return map { PL($_) } @_; |
|
|
0
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
our %exceptions = |
|
73
|
|
|
|
|
|
|
( |
|
74
|
|
|
|
|
|
|
statuses => 'status', |
|
75
|
|
|
|
|
|
|
is => 'is', |
|
76
|
|
|
|
|
|
|
has => 'has', |
|
77
|
|
|
|
|
|
|
cds => 'cds', |
|
78
|
|
|
|
|
|
|
); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub plural_to_singular { |
|
81
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
82
|
0
|
|
|
|
|
|
my ($lc,$override); |
|
83
|
|
|
|
|
|
|
return map { |
|
84
|
0
|
|
|
|
|
|
$lc = lc($_); |
|
|
0
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$override = $exceptions{$lc}; |
|
86
|
0
|
0
|
|
|
|
|
( $override ? $override : PL_V($_) ) |
|
87
|
|
|
|
|
|
|
} @_; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |