Data-URIID
view release on metacpan or search on metacpan
lib/Data/URIID/Service.pm view on Meta::CPAN
P7704 => 'europeana-entity-identifier',
P8168 => 'factgrid-identifier',
P8406 => 'grove-art-online-identifier',
P9575 => 'amc-artist-identifier',
P10086 => 'a-p-and-p-artist-identifier',
P10689 => 'osm-way',
P10787 => 'factgrid-identifier',
P11693 => 'osm-node',
(map {$_ => 'musicbrainz-identifier'} @musicbrainz_wikidata_relations),
},
endpoint => {
sparql => 'https://query.wikidata.org/sparql',
entitydata => 'https://www.wikidata.org/wiki/Special:EntityData/%s.json?flavor=dump',
},
prefix => 'http://www.wikidata.org/entity/',
uuid_relations => \@musicbrainz_wikidata_relations,
special_ids => [
{
property => 'P1711',
type => 'british-museum-term',
to_service => sub {($_[0] =~ /^BIOG([1-9][0-9]+)$/)[0]},
lib/Data/URIID/Service.pm view on Meta::CPAN
],
};
my $config_factgrid = {
type => 'factgrid-identifier',
idmap => {
P76 => 'gnd-identifier',
P378 => 'viaf-identifier',
P980 => 'iconclass-identifier',
},
endpoint => {
sparql => 'https://database.factgrid.de/sparql',
entitydata => 'https://database.factgrid.de/wiki/Special:EntityData/%s.json?flavor=dump',
},
prefix => 'https://database.factgrid.de/entity/',
attributes => [
(map {my $c = $_; {
property => $c->[0],
from_service => sub {_online_lookup__wikibase__from_service__datetime($c->[1] => @_)},
}} (
[P38 => 'date_of_death'],
lib/Data/URIID/Service.pm view on Meta::CPAN
foreach my $property (@{$config->{uuid_relations}}) {
push(@ids, sprintf('?item wdt:%s "%s"', $property, $id));
}
}
}
return undef unless scalar @ids;
{
my $q = sprintf('SELECT * WHERE { { %s } } LIMIT 1', join('} UNION {', @ids));
my $res = $self->_get_json($config->{endpoint}{sparql}, query => {format => 'json', query => $q});
my $item = eval {$res->{results}{bindings}[0]{item}};
return undef unless $item;
return undef unless ($item->{type} // '') eq 'uri';
if (($item->{value} // '') =~ m#^\Q$config->{prefix}\E([QP][1-9][0-9]*)$#) {
return $1;
}
}
return undef;
}
sub _online_lookup__wikibase__stage_1 {
my ($self, $result, $id, $config) = @_;
my %ids = ($config->{type} => $id);
my %attr;
my %res = (id => \%ids, attributes => \%attr);
my $data = $self->_get_json(sprintf($config->{endpoint}{entitydata}, $id), local_override => ['%s.json', $id]);
$data = $data->{entities}{$id};
$attr{displayname} = {map {$_ => $data->{labels}{$_}{value}} keys %{$data->{labels}}};
$attr{description} = {map {$_ => $data->{descriptions}{$_}{value}} keys %{$data->{descriptions}}};
$res{wikidata_sitelinks} = $data->{sitelinks};
foreach my $property (keys %{$config->{idmap}}) {
foreach my $entry (@{$data->{claims}{$property} // []}) {
$ids{$config->{idmap}{$property}} = $entry->{mainsnak}{datavalue}{value};
( run in 0.232 second using v1.01-cache-2.11-cpan-b61123c0432 )