From: Bill Erickson Date: Thu, 19 Nov 2015 22:49:23 +0000 (-0500) Subject: JBAS-980 bib linking force thesaurus; local thesaurus X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=78091c44077997012215cee46c44984b1a3cb056;p=working%2FEvergreen.git JBAS-980 bib linking force thesaurus; local thesaurus Preliminary support for mapping local thesaurus values (ind2=7) to one of the supported authority leader/11 options. Signed-off-by: Bill Erickson --- diff --git a/KCLS/linking/authority_control_fields.pl b/KCLS/linking/authority_control_fields.pl index 61d737e5f6..230e9a36bc 100755 --- a/KCLS/linking/authority_control_fields.pl +++ b/KCLS/linking/authority_control_fields.pl @@ -567,6 +567,15 @@ my %AUTH_TO_BIB_IND2 = ( 'z' => '8' # Other ); +# Maps 6XX subfield $2 values to their equivalent authority leader/11 value. +# These occur when the indicator 2 == 7 ("Source specified in subfield $2") +my %BIB_SF2_TO_AUTH = ( + lcsh => 'a', + mesh => 'c', + nal => 'd', + rvm => 'v' +); + my $start_time = localtime(); if($input_file) { @@ -581,7 +590,25 @@ if($input_file) { # indicator 2 (thesaurus) value, returns the ID of the first # authority record in the set that matches the thesaurus. sub find_matching_auth_for_thesaurus { - my ($e, $cfield_ind2, $auth_ids) = @_; + my ($e, $bib_field, $auth_ids) = @_; + + my $cfield_ind2 = $bib_field->indicator(2) || ''; + + if ($cfield_ind2 eq '7') { + # subject thesaurus code is embedded in the bib field subfield 2 + + my $thesaurus = $bib_field->subfield('2') || ''; + announce("Found local thesaurus value $thesaurus"); + + $cfield_ind2 = $BIB_SF2_TO_AUTH{$thesaurus} || ''; + + if ($cfield_ind2) { + announce("Mapped local thesaurus '$thesaurus' to '$cfield_ind2'"); + } else { + announce("No mapping found for local thesaurus '$thesaurus'"); + return undef; + } + } my $auth_leaders = $e->json_query({ select => {afr => ['record', 'value']}, @@ -646,7 +673,7 @@ foreach my $rec_id (@records) { } next if !$match_tag; - announce("Searching for matches (auth tag=$match_tag): ". + announce("Searching for matches (auth tag=$match_tag): \n\t". Dumper(\@searches)); my @tags = ($match_tag); @@ -681,40 +708,31 @@ foreach my $rec_id (@records) { # Find the best authority record to use for linking. my $auth_id; - my $stop_looking = 0; - if ($bib_field->tag() ge 650 and $bib_field->tag() le 659) { - # If the controlled bib field has an indicator 2 value - # indicating the thesarus, use the first authority - # record in the set with the same thesaurus. + if ($bib_field->tag() =~ /^65[015]/) { + # Using the indicator-2 value from the controlled bib + # field, find the first authority in the list of matches + # that uses the same thesaurus. If no such authority + # is found, no matching occurs. # TODO: perhaps this step should be part of the - # validateion API search call above. + # validation API search call above. - my $cfield_ind2 = $bib_field->indicator(2); - - if (defined $cfield_ind2) { - - $auth_id = find_matching_auth_for_thesaurus( - $e, $cfield_ind2, $validates) || ''; - - announce("Thesaurus match for ind2=$cfield_ind2 returned $auth_id"); + $auth_id = find_matching_auth_for_thesaurus( + $e, $bib_field, $validates) || ''; - # If we don't find a matching authority record using - # the same thesuarus, we have nothing to link to. - $stop_looking = 1; - } - } - - # No best record found above. Use the first in the list. - $auth_id = $validates->[0] unless $auth_id or $stop_looking; + } else { + # For all other controlled fields, use the first + # authority record in the result set. + $auth_id = $validates->[0]; + } # Don't exit here just because we have no $auth_id. The # bib field could have been changed above in the cleanup / # delete phase. if ($auth_id) { - # Add the control number agency info from the matching - # authority record to the controlled bib field. + # Add the auth ID and control number agency info from the + # matching authority record to the controlled bib field. my $auth_003 = $e->json_query({ select => {afr => ['value']},