line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::VIAF::API; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
9409
|
use strict; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
88
|
|
4
|
4
|
|
|
4
|
|
12
|
use warnings; |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
72
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
12
|
use Moo; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
22
|
|
7
|
4
|
|
|
4
|
|
784
|
use Catmandu::Sane; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
24
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
2273
|
use Catmandu::VIAF::API::ID; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Catmandu::VIAF::API::Query; |
11
|
|
|
|
|
|
|
use Catmandu::VIAF::API::Extract; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has term => (is => 'ro', required => 1); |
14
|
|
|
|
|
|
|
has lang => (is => 'ro', default => 'nl-NL'); |
15
|
|
|
|
|
|
|
has fallback_lang => (is => 'ro', default => 'en-US'); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub search { |
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
my $query = sprintf('local.mainHeadingEl = "%s" and local.personalNames = "%s"', $self->term, $self->term); |
20
|
|
|
|
|
|
|
my $api_q = Catmandu::VIAF::API::Query->new(query => $query, lang => $self->lang, fallback_lang => $self->fallback_lang); |
21
|
|
|
|
|
|
|
my $results = []; |
22
|
|
|
|
|
|
|
foreach my $result (@{$api_q->results}) { |
23
|
|
|
|
|
|
|
my $e = Catmandu::VIAF::API::Extract->new( |
24
|
|
|
|
|
|
|
api_response => $result, |
25
|
|
|
|
|
|
|
lang => $self->lang, |
26
|
|
|
|
|
|
|
fallback_lang => $self->fallback_lang |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
push @{$results}, $e->single(); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
return $results; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub match { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
my $query = sprintf('local.mainHeadingEl exact "%s" and local.personalNames = "%s"', $self->term, $self->term); |
36
|
|
|
|
|
|
|
my $api_q = Catmandu::VIAF::API::Query->new(query => $query, lang => $self->lang, fallback_lang => $self->fallback_lang); |
37
|
|
|
|
|
|
|
my $result = shift @{$api_q->results}; |
38
|
|
|
|
|
|
|
my $e = Catmandu::VIAF::API::Extract->new( |
39
|
|
|
|
|
|
|
api_response => $result, |
40
|
|
|
|
|
|
|
lang => $self->lang, |
41
|
|
|
|
|
|
|
fallback_lang => $self->fallback_lang |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
return $e->single(); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub id { |
47
|
|
|
|
|
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
my $api_id = Catmandu::VIAF::API::ID->new(viafid => $self->term); |
49
|
|
|
|
|
|
|
my $e = Catmandu::VIAF::API::Extract->new( |
50
|
|
|
|
|
|
|
api_response => $api_id->result, |
51
|
|
|
|
|
|
|
lang => $self->lang, |
52
|
|
|
|
|
|
|
fallback_lang => $self->fallback_lang |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
return $e->single(); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
__END__ |