NAME MARC::Convert::Wikidata - Conversion class between MARC file to Wikibase::Datatype item. SYNOPSIS use MARC::Convert::Wikidata; my $obj = MARC::Convert::Wikidata->new(%params); my @values = $obj->look_for_external_id($external_id_name, $deprecation_flag); my $object = $obj->object; my $type = $obj->type; my $wikidata = $obj->wikidata; DESCRIPTION Original intent of this class was conversion from MARC records in National Library of the Czech Republic to Wikidata. The conversion is not simple, this mean that many things are concrete for this concrete national library. METHODS "new" my $obj = MARC::Convert::Wikidata->new(%params); Constructor. * "callback_cover" Cover callback Default value is undef. * "callback_lang" Language callback. Default value is undef. * "callback_people" People callback. Default value is undef. * "callback_publisher_place" Place of publication Wikidata lookup callback. Default value is undef. * "callback_publisher_name" Publisher Wikidata lookup callback. Default value is undef. * "callback_series" Book series Wikidata lookup callback. Default value is undef. * "date_retrieved" Retrieved date. Default value is undef. * "marc_record" MARC::Record object. It's required. * "verbose" Verbose mode. Could be 1 or 0. Default value is 0. Returns instance of object. "look_for_external_id" my @values = $obj->look_for_external_id($external_id_name, $deprecation_flag); Get external id values defined by name and deprecation flag (default is 0). Returns string. "object" my $object = $obj->object; Get data object created from MARC record. Returns MARC::Convert::Wikidata::Object instance. "type" my $type = $obj->type; Process MARC record and detect which record type is. Supported values are: monograph, audiobook and periodical. Returns string. "wikidata" my $wikidata = $obj->wikidata; Process conversion from MARC record to Wikibase::Datatype::Item which is possible to load to Wikidata. Returns Wikibase::Datatype instance. ERRORS new(): From Class::Utils::set_params(): Unknown parameter '%s'. From Mo::utils::check_isa(): Parameter 'marc_record' must be a 'MARC::Record' object. From Mo::utils::check_required(): Parameter 'marc_record' is required. type(): Unsupported item with leader '%s'. wikidata(): Item '%s' doesn't supported. Unsupported item with leader '%s'. EXAMPLE use strict; use warnings; use File::Temp (); use MARC::Convert::Wikidata; use MARC::File::XML; use MARC::Record; use Unicode::UTF8 qw(decode_utf8 encode_utf8); use Wikibase::Datatype::Print::Item; my $marc_xml = decode_utf8(<<'END'); 01177nam a2200349 i 4500 nkc20193102359 CZ PrNK 20190813103856.0 ta 190612s1917 xr af b 000 f cze cnb003102359 (Vázáno) ABA001 cze rda 821.162.3-3 Česká próza Konspekt 25 821-93 Literatura pro děti a mládež (beletrie) Konspekt 26 821.162.3-34 MRF 821-93 MRF (0:82-34) MRF Karafiát, Jan, 1846-1929 jk01052941 aut Broučci : pro malé i veliké děti / Jan Karafiát IV. vydání V Praze : Alois Hynek, [1917?] 85 stran, 5 nečíslovaných listů obrazových příloh : ilustrace (některé barevné) ; 24 cm text txt rdacontent bez média n rdamedia svazek nc rdacarrier české pohádky fd133970 czenas publikace pro děti fd133156 czenas Czech fairy tales eczenas children's literature eczenas ABA001 003102359 END my $marc_record = MARC::Record->new_from_xml($marc_xml, 'UTF-8'); # Object. my $obj = MARC::Convert::Wikidata->new( 'marc_record' => $marc_record, ); # Convert MARC record to Wikibase object. my $item = $obj->wikidata; # Print out. print encode_utf8(scalar Wikibase::Datatype::Print::Item::print($item)); # Output like: # TODO Add callbacks. # No callback method for translation of people in 'authors' method. # No callback method for translation of language. # Label: Broučci: pro malé i veliké děti (en) # Description: 1917 Czech book edition (en) # Statements: # P31: Q3331189 (normal) # P3184: cnb003102359 (normal) # References: # { # P248: Q86914821 # P3184: cnb003102359 # P813: 26 May 2023 (Q1985727) # } # P393: 4 (normal) # References: # { # P248: Q86914821 # P3184: cnb003102359 # P813: 26 May 2023 (Q1985727) # } # P1104: 85 (normal) # References: # { # P248: Q86914821 # P3184: cnb003102359 # P813: 26 May 2023 (Q1985727) # } # P577: 1917 (Q1985727) (normal) # References: # { # P248: Q86914821 # P3184: cnb003102359 # P813: 26 May 2023 (Q1985727) # } # P1680: pro malé i veliké děti (cs) (normal) # References: # { # P248: Q86914821 # P3184: cnb003102359 # P813: 26 May 2023 (Q1985727) # } # P1476: Broučci (cs) (normal) # References: # { # P248: Q86914821 # P3184: cnb003102359 # P813: 26 May 2023 (Q1985727) # } DEPENDENCIES Class::Utils, Error::Pure, MARC::Convert::Wikidata::Item::AudioBook, MARC::Convert::Wikidata::Item::BookEdition, MARC::Convert::Wikidata::Item::Periodical, MARC::Convert::Wikidata::Transform, MARC::Leader, Scalar::Util. SEE ALSO MARC::Record Perl extension for handling MARC records Wikibase::Datatype::Item Wikibase item datatype. REPOSITORY AUTHOR Michal Josef Špaček LICENSE AND COPYRIGHT © 2021-2024 Michal Josef Špaček BSD 2-Clause License VERSION 0.17