line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::ERC; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
38203
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
538
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION; |
8
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Name: Release-1-05 $ =~ /Release-(\d+)-(\d+)/; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw( |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
17
|
|
|
|
|
|
|
num2tag tag2num tag2num_init |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our %erc_terms = ( |
21
|
|
|
|
|
|
|
'h10' => 'about-erc', # analog for dir_type? |
22
|
|
|
|
|
|
|
'h12' => 'about-what', |
23
|
|
|
|
|
|
|
'h13' => 'about-when', |
24
|
|
|
|
|
|
|
'h14' => 'about-where', |
25
|
|
|
|
|
|
|
'h11' => 'about-who', |
26
|
|
|
|
|
|
|
'h15' => 'about-how', |
27
|
|
|
|
|
|
|
'h506' => 'contributor', |
28
|
|
|
|
|
|
|
'h514' => 'coverage', |
29
|
|
|
|
|
|
|
'h502' => 'creator', |
30
|
|
|
|
|
|
|
'h507' => 'date', |
31
|
|
|
|
|
|
|
'h504' => 'description', |
32
|
|
|
|
|
|
|
'c1' => 'ERC', |
33
|
|
|
|
|
|
|
'h9' => 'erc', # h0->h9 to not collide with dir_type |
34
|
|
|
|
|
|
|
'h0' => 'dir_type', |
35
|
|
|
|
|
|
|
'v1' => ':etal', |
36
|
|
|
|
|
|
|
'h509' => 'format', |
37
|
|
|
|
|
|
|
'c2' => 'four h\'s', |
38
|
|
|
|
|
|
|
'h510' => 'identifier', |
39
|
|
|
|
|
|
|
'h602' => 'in', |
40
|
|
|
|
|
|
|
'h5' => 'how', |
41
|
|
|
|
|
|
|
'h512' => 'language', |
42
|
|
|
|
|
|
|
'c3' => 'metadata', |
43
|
|
|
|
|
|
|
'h30' => 'meta-erc', # dirtype? |
44
|
|
|
|
|
|
|
'h32' => 'meta-what', |
45
|
|
|
|
|
|
|
'h33' => 'meta-when', |
46
|
|
|
|
|
|
|
'h34' => 'meta-where', |
47
|
|
|
|
|
|
|
'h31' => 'meta-who', |
48
|
|
|
|
|
|
|
'v2' => ':none', |
49
|
|
|
|
|
|
|
'h601' => 'note', |
50
|
|
|
|
|
|
|
'v3' => ':null', |
51
|
|
|
|
|
|
|
'c4' => 'object', |
52
|
|
|
|
|
|
|
'h505' => 'publisher', |
53
|
|
|
|
|
|
|
'c5' => 'resource', |
54
|
|
|
|
|
|
|
'h513' => 'relation', |
55
|
|
|
|
|
|
|
'h515' => 'rights', |
56
|
|
|
|
|
|
|
'h511' => 'source', |
57
|
|
|
|
|
|
|
'h503' => 'subject', |
58
|
|
|
|
|
|
|
'h20' => 'support-erc', # dirtype? |
59
|
|
|
|
|
|
|
'h22' => 'support-what', |
60
|
|
|
|
|
|
|
'h23' => 'support-when', |
61
|
|
|
|
|
|
|
'h24' => 'support-where', |
62
|
|
|
|
|
|
|
'h21' => 'support-who', |
63
|
|
|
|
|
|
|
'c6' => 'stub ERC', |
64
|
|
|
|
|
|
|
'v4' => ':tba', |
65
|
|
|
|
|
|
|
'h501' => 'title', |
66
|
|
|
|
|
|
|
'h508' => 'type', |
67
|
|
|
|
|
|
|
'v5' => ':unac', |
68
|
|
|
|
|
|
|
'v6' => ':unal', |
69
|
|
|
|
|
|
|
'v7' => ':unap', |
70
|
|
|
|
|
|
|
'v8' => ':unas', |
71
|
|
|
|
|
|
|
'v9' => ':unav', |
72
|
|
|
|
|
|
|
'v10' => ':unkn', |
73
|
|
|
|
|
|
|
'h2' => 'what', |
74
|
|
|
|
|
|
|
'h3' => 'when', |
75
|
|
|
|
|
|
|
'h4' => 'where', |
76
|
|
|
|
|
|
|
'h1' => 'who', |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
our %erc_tags; # for lazy evaluation |
80
|
|
|
|
|
|
|
our @erc_termlist; # for lazy evaluation |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub tag2num_init { |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
0
|
0
|
0
|
@erc_termlist = sort values %erc_terms; # so we can grep |
85
|
|
|
|
|
|
|
$erc_tags{$erc_terms{$_}} = $_ # so we can inverse map |
86
|
0
|
|
|
|
|
0
|
for (keys %erc_terms); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub tag2num { |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
0
|
0
|
0
|
0
|
@erc_termlist && %erc_tags or |
92
|
|
|
|
|
|
|
tag2num_init(); # one-time lazy definition |
93
|
0
|
|
|
|
|
0
|
my (@ret, $tag); |
94
|
0
|
|
|
|
|
0
|
foreach $tag (@_) { |
95
|
|
|
|
|
|
|
# if it doesn't look like a regexp, do exact match |
96
|
0
|
0
|
|
|
|
0
|
push(@ret, grep( |
97
|
|
|
|
|
|
|
($tag =~ /[\\\*\|\[\+\?\{\^\$]/ ? /$tag/ : /^$tag$/), |
98
|
|
|
|
|
|
|
@erc_termlist)); |
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
|
|
0
|
return @ret; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Returns an array of terms corresponding to args given as coded |
104
|
|
|
|
|
|
|
# synonyms for Dublin Kernel elements, eg, num2tag('h1') -> 'who'. |
105
|
|
|
|
|
|
|
# |
106
|
|
|
|
|
|
|
sub num2tag { |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
1
|
0
|
4685
|
my (@ret, $code); |
109
|
1
|
|
|
|
|
5
|
for (@_) { |
110
|
|
|
|
|
|
|
# Assume an 'h' in front if it starts with a digit. |
111
|
|
|
|
|
|
|
# |
112
|
4
|
|
|
|
|
17
|
($code = $_) =~ s/^(\d)/h$1/; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Return a defined hash value or the empty string. |
115
|
|
|
|
|
|
|
# |
116
|
4
|
100
|
|
|
|
22
|
push @ret, defined($erc_terms{$code}) ? |
117
|
|
|
|
|
|
|
$erc_terms{$code} : ''; |
118
|
|
|
|
|
|
|
} |
119
|
1
|
|
|
|
|
8
|
return @ret; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |