line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::viaf_match; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
224380
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
48
|
|
4
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
47
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
355
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
110758
|
|
|
2
|
|
|
|
|
14
|
|
7
|
2
|
|
|
2
|
|
417
|
use Moo; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
9
|
|
8
|
2
|
|
|
2
|
|
1214
|
use Catmandu::Fix::Has; |
|
2
|
|
|
|
|
1268
|
|
|
2
|
|
|
|
|
10
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1003
|
use Catmandu::Util qw(:is); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
586
|
|
11
|
2
|
|
|
2
|
|
857
|
use Catmandu::Fix::Datahub::Util qw(declare_source); |
|
2
|
|
|
|
|
698
|
|
|
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
|
906
|
my ($self, $fixer) = @_; |
19
|
1
|
|
|
|
|
2
|
my $perl = ''; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
3
|
$perl .= 'use Catmandu::VIAF::API;'; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
3
|
my $name = $fixer->generate_var(); |
24
|
1
|
|
|
|
|
34
|
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
|
|
|
|
|
100
|
$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}->match();"; |
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 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 |