line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::viaf_search; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
232976
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
51
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
54
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
8
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
7
|
2
|
|
|
2
|
|
331
|
use Moo; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
9
|
|
8
|
2
|
|
|
2
|
|
802
|
use Catmandu::Fix::Has; |
|
2
|
|
|
|
|
629
|
|
|
2
|
|
|
|
|
9
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
984
|
use Catmandu::Util qw(:is); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
471
|
|
11
|
2
|
|
|
2
|
|
388
|
use Catmandu::Fix::Datahub::Util qw(declare_source); |
|
2
|
|
|
|
|
343
|
|
|
2
|
|
|
|
|
445
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
14
|
|
|
|
|
|
|
has lang => (fix_opt => 1, default => sub {'nl-NL'}); |
15
|
|
|
|
|
|
|
has fallback_lang => (fix_opt => 1, default => sub {'en-US'}); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub emit { |
18
|
1
|
|
|
1
|
0
|
890
|
my ($self, $fixer) = @_; |
19
|
1
|
|
|
|
|
3
|
my $perl = ''; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
2
|
$perl .= 'use Catmandu::VIAF::API;'; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
16
|
my $name = $fixer->generate_var(); |
24
|
1
|
|
|
|
|
39
|
my $viaf = $fixer->generate_var(); |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
31
|
$perl .= "my ${name};"; |
27
|
1
|
|
|
|
|
7
|
$perl .= declare_source($fixer, $self->path, $name); |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
97
|
$perl .= "my ${viaf} = Catmandu::VIAF::API->new(term => ${name}, lang => '".$self->lang."');"; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$perl .= $fixer->emit_create_path( |
32
|
|
|
|
|
|
|
$fixer->var, |
33
|
|
|
|
|
|
|
$fixer->split_path($self->path), |
34
|
|
|
|
|
|
|
sub { |
35
|
1
|
|
|
1
|
|
81
|
my $root = shift; |
36
|
1
|
|
|
|
|
2
|
my $code = ''; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
4
|
$code .= "${root} = ${viaf}->search();"; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
2
|
return $code; |
41
|
|
|
|
|
|
|
} |
42
|
1
|
|
|
|
|
16
|
); |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
9
|
return $perl; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
__END__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=encoding utf-8 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=for html <a href="https://travis-ci.org/thedatahub/Catmandu-VIAF"><img src="https://travis-ci.org/thedatahub/Catmandu-VIAF.svg?branch=master"></a> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Catmandu::Fix::viaf_match - Perform a search for a name in VIAF |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
viaf_search(authorName, -lang:'nl-NL', -fallback_lang:'en-US') |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Perform a search for a name. Both I<mainHeadingEl> and the |
66
|
|
|
|
|
|
|
I<local.personalNames> are queried. The fix will return |
67
|
|
|
|
|
|
|
the I<prefLabel> in the provided C<lang>, or C<fallback_lang> if one |
68
|
|
|
|
|
|
|
in C<lang> does not exist. If C<fallback_lang> also doesn't exist, the |
69
|
|
|
|
|
|
|
I<prefLabel> will be empty. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The fix returns a list, with elements in the following form: |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
{ |
74
|
|
|
|
|
|
|
'dcterms:identifier' => 'The identifier', |
75
|
|
|
|
|
|
|
'guid' => 'The VIAF URL', |
76
|
|
|
|
|
|
|
'schema:birthDate' => 'Birth date, if provided', |
77
|
|
|
|
|
|
|
'schema:deathDate' => 'Death date, if provided', |
78
|
|
|
|
|
|
|
'schema:description' => 'Description, if provided', |
79
|
|
|
|
|
|
|
'skos:prefLabel' => 'prefLabel, in lang or fallback_lang' |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 PARAMETERS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head3 Required parameters |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=over |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item C<path> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Path to the name. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=back |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head3 Optional parameters |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=over |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item C<lang> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Language of the returned C<skos:prefLabel>. Falls back to |
101
|
|
|
|
|
|
|
C<fallback_lang> if none was found. Use L<IETF language tags|https://en.wikipedia.org/wiki/IETF_language_tag>. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item C<fallback_lang> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Fallback language. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=back |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHOR |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Pieter De Praetere E<lt>pieter at packed.be E<gt> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 COPYRIGHT |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Copyright 2017- PACKED vzw |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 LICENSE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
120
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SEE ALSO |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<Catmandu> |
125
|
|
|
|
|
|
|
L<Catmandu::VIAF> |
126
|
|
|
|
|
|
|
L<Catmandu::Store::VIAF> |
127
|
|
|
|
|
|
|
L<Catmandu::Fix::viaf_match> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |