line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::aat_search; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
224282
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
50
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
41
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
5
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
12
|
|
7
|
2
|
|
|
2
|
|
310
|
use Moo; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
9
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
763
|
use Catmandu::Fix::Has; |
|
2
|
|
|
|
|
604
|
|
|
2
|
|
|
|
|
11
|
|
10
|
2
|
|
|
2
|
|
1334
|
use Catmandu::Fix::Datahub::Util qw(declare_source); |
|
2
|
|
|
|
|
341
|
|
|
2
|
|
|
|
|
402
|
|
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
|
3477
|
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
|
|
|
|
|
65
|
my $aat = $fixer->generate_var(); |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
59
|
$perl .= "my ${term};"; |
27
|
2
|
|
|
|
|
12
|
$perl .= declare_source($fixer, $self->path, $term); |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
228
|
$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
|
|
188
|
my $root = shift; |
36
|
2
|
|
|
|
|
16
|
my $code = ''; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
6
|
$code .= "${root} = ${aat}->search();"; |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
5
|
return $code; |
41
|
|
|
|
|
|
|
} |
42
|
2
|
|
|
|
|
38
|
); |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
19
|
return $perl; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
__END__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=encoding utf-8 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Catmandu::Fix::aat_search - Perform a search for a term in the AAT |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SYNOPSIS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
aat_search( |
59
|
|
|
|
|
|
|
path, |
60
|
|
|
|
|
|
|
-lang: nl |
61
|
|
|
|
|
|
|
) |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Perform a search for 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> that contains a I<prefLabel>, I<altLabel> or a |
67
|
|
|
|
|
|
|
I<Subject ID> containing the searched for term. More details can be found L<here|http://vocab.getty.edu/doc/#Full_Text_Search> |
68
|
|
|
|
|
|
|
(C<luc:term> is used). |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Returns an array of results containing the following data: |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
{ |
73
|
|
|
|
|
|
|
'id' => 'The dc:identifier of the Subject', |
74
|
|
|
|
|
|
|
'prefLabel' => 'The prefLabel in the provided language', |
75
|
|
|
|
|
|
|
'uri' => 'The URI of the Subject' |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 PARAMETERS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head3 Required parameters |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item C<path> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Path to the term. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=back |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head3 Optional parameters |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=over |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item C<lang> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Language of both the I<term> that is matched and the I<prefLabel> that is returned. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=back |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Pieter De Praetere E<lt>pieter at packed.be E<gt> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Copyright 2017- PACKED vzw |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 LICENSE |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
111
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SEE ALSO |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L<Catmandu> |
116
|
|
|
|
|
|
|
L<Catmandu::AAT> |
117
|
|
|
|
|
|
|
L<Catmandu::Store::AAT> |
118
|
|
|
|
|
|
|
L<Catmandu::Fix::aat_search> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|