line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::viaf_match; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
223876
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
49
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
46
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
391
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
115085
|
|
|
2
|
|
|
|
|
15
|
|
7
|
2
|
|
|
2
|
|
443
|
use Moo; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
10
|
|
8
|
2
|
|
|
2
|
|
1267
|
use Catmandu::Fix::Has; |
|
2
|
|
|
|
|
1326
|
|
|
2
|
|
|
|
|
9
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
986
|
use Catmandu::Util qw(:is); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
549
|
|
11
|
2
|
|
|
2
|
|
773
|
use Catmandu::Fix::Datahub::Util qw(declare_source); |
|
2
|
|
|
|
|
709
|
|
|
2
|
|
|
|
|
429
|
|
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
|
833
|
my ($self, $fixer) = @_; |
19
|
1
|
|
|
|
|
2
|
my $perl = ''; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
2
|
$perl .= 'use Catmandu::VIAF::API;'; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
4
|
my $name = $fixer->generate_var(); |
24
|
1
|
|
|
|
|
33
|
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
|
|
|
|
|
96
|
$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
|
|
|
|
|
1
|
my $code = ''; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
3
|
$code .= "${root} = ${viaf}->match();"; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
3
|
return $code; |
41
|
|
|
|
|
|
|
} |
42
|
1
|
|
|
|
|
14
|
); |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
8
|
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 direct match between a name and a mainHeadingEl from VIAF |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
viaf_match(authorName, -lang:'nl-NL', -fallback_lang:'en-US') |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Perform a direct match between a name and a I<mainHeadingEl> and the |
66
|
|
|
|
|
|
|
I<local.personalNames> of a I<Person> in VIAF. 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
|
|
|
|
|
|
|
Returns the following data: |
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_search> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |