line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::aat_match; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
222394
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
46
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
38
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
6
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
7
|
2
|
|
|
2
|
|
301
|
use Moo; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
8
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1176
|
use Catmandu::Fix::Has; |
|
2
|
|
|
|
|
1217
|
|
|
2
|
|
|
|
|
9
|
|
10
|
2
|
|
|
2
|
|
1724
|
use Catmandu::Fix::Datahub::Util qw(declare_source); |
|
2
|
|
|
|
|
687
|
|
|
2
|
|
|
|
|
461
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::Base'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
15
|
|
|
|
|
|
|
has lang => (fix_opt => 1, default => sub { 'nl' }); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub emit { |
18
|
2
|
|
|
2
|
0
|
3088
|
my ($self, $fixer) = @_; |
19
|
2
|
|
|
|
|
3
|
my $perl = ''; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
5
|
$perl .= 'use Catmandu::Store::AAT::API;'; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
6
|
my $term = $fixer->generate_var(); |
24
|
2
|
|
|
|
|
63
|
my $aat = $fixer->generate_var(); |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
58
|
$perl .= "my ${term};"; |
27
|
2
|
|
|
|
|
11
|
$perl .= declare_source($fixer, $self->path, $term); |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
185
|
$perl .= "my ${aat} = Catmandu::Store::AAT::API->new(term => ${term}, language => '".$self->lang."');"; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$perl .= $fixer->emit_create_path( |
32
|
|
|
|
|
|
|
$fixer->var, |
33
|
|
|
|
|
|
|
$fixer->split_path($self->path), |
34
|
|
|
|
|
|
|
sub { |
35
|
2
|
|
|
2
|
|
147
|
my $root = shift; |
36
|
2
|
|
|
|
|
4
|
my $code = ''; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
5
|
$code .= "${root} = ${aat}->match();"; |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
5
|
return $code; |
41
|
|
|
|
|
|
|
} |
42
|
2
|
|
|
|
|
28
|
); |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
17
|
return $perl; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
__END__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=encoding utf-8 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Catmandu::Fix::aat_match - Perform a direct match between a term and a Subject in the AAT |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SYNOPSIS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
aat_match( |
59
|
|
|
|
|
|
|
path, |
60
|
|
|
|
|
|
|
-lang: nl |
61
|
|
|
|
|
|
|
) |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Perform a direct match between a term and the L<SPARQL endpoint|http://vocab.getty.edu/sparql> of the AAT. |
66
|
|
|
|
|
|
|
This fix will attempt to find a I<Subject> for which the I<prefLabel> in I<lang> (optional, default C<nl>) |
67
|
|
|
|
|
|
|
equals the term. Will return a single item if one is found, or an empty hash if none was found. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns the following data: |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
{ |
72
|
|
|
|
|
|
|
'id' => 'The dc:identifier of the Subject', |
73
|
|
|
|
|
|
|
'prefLabel' => 'The prefLabel in the provided language', |
74
|
|
|
|
|
|
|
'uri' => 'The URI of the Subject' |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 PARAMETERS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head3 Required parameters |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=over |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item C<path> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Path to the term. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=back |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head3 Optional parameters |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item C<lang> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Language of both the I<prefLabel> that is matched and the I<prefLabel> that is returned. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Pieter De Praetere E<lt>pieter at packed.be E<gt> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Copyright 2017- PACKED vzw |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 LICENSE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
110
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SEE ALSO |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L<Catmandu> |
115
|
|
|
|
|
|
|
L<Catmandu::Store::AAT> |
116
|
|
|
|
|
|
|
L<Catmandu::Fix::aat_search> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|