line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::aat_match; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
228036
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
51
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
42
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
6
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
12
|
|
7
|
2
|
|
|
2
|
|
309
|
use Moo; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
9
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1232
|
use Catmandu::Fix::Has; |
|
2
|
|
|
|
|
1280
|
|
|
2
|
|
|
|
|
9
|
|
10
|
2
|
|
|
2
|
|
1749
|
use Catmandu::Fix::Datahub::Util qw(declare_source); |
|
2
|
|
|
|
|
733
|
|
|
2
|
|
|
|
|
438
|
|
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
|
3302
|
my ($self, $fixer) = @_; |
19
|
2
|
|
|
|
|
4
|
my $perl = ''; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
4
|
$perl .= 'use Catmandu::AAT::API;'; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
5
|
my $term = $fixer->generate_var(); |
24
|
2
|
|
|
|
|
62
|
my $aat = $fixer->generate_var(); |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
58
|
$perl .= "my ${term};"; |
27
|
2
|
|
|
|
|
12
|
$perl .= declare_source($fixer, $self->path, $term); |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
186
|
$perl .= "my ${aat} = Catmandu::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
|
|
158
|
my $root = shift; |
36
|
2
|
|
|
|
|
4
|
my $code = ''; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
7
|
$code .= "${root} = ${aat}->match();"; |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
6
|
return $code; |
41
|
|
|
|
|
|
|
} |
42
|
2
|
|
|
|
|
29
|
); |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
18
|
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::AAT> |
116
|
|
|
|
|
|
|
L<Catmandu::Store::AAT> |
117
|
|
|
|
|
|
|
L<Catmandu::Fix::aat_search> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|