From 8f810f0d0dad597800bd50c1d39c043b175428d0 Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Wed, 4 Sep 2013 14:17:57 -0400 Subject: [PATCH] Bug 7419: quiet warnings in deduplicator Quiet some warnings from the deduplicator script. Revised test plan: 1) Apply patches. 2) Import the sample records (sampleauths.mrc) file into Koha and make sure that they get indexed (by waiting until rebuild_zebra.pl runs automatically or by running rebuild_zebra.pl -a -z [-x] manually) 3) Deduplicate based on LCCN (replace {FIRSTAUTH} with the authid of the first imported record; on my system that number is 367123668): > misc/migration_tools/dedup_records.pl -t -v -a \ -l "authid >= {FIRSTAUTH}" -r -m "lc-card/010a" -s date 4) Check that you have 10 records that were chosen (you may have more, if you added more authorities after importing the sample data, but you should have at least the ten). 5) Deduplicate based on geographic heading, preferring Library of Congress authorities to local authorities: > misc/migration_tools/dedup_records.pl -t -v -a \ -l "authid >= {FIRSTAUTH}" -r -m "geographic/151a" -s "source=DLC" -s date 6) Check that you have 2 duplicate records replaced from amongst the new records. 7) Sign off. --- misc/migration_tools/dedup_records.pl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/misc/migration_tools/dedup_records.pl b/misc/migration_tools/dedup_records.pl index 8639a38..2a6c38b 100755 --- a/misc/migration_tools/dedup_records.pl +++ b/misc/migration_tools/dedup_records.pl @@ -205,10 +205,11 @@ MARC21 only. Prefer records which come from ABC based on the 003 field. =cut when (/^source=(.*)$/) { + my $goal = $1; push @selectors, sub { return ( defined $_[0]->{'record'}->field('003') - && $_[0]->{'record'}->field('003')->data() eq $1 + && $_[0]->{'record'}->field('003')->data() eq $goal ? 1 : 0 ); @@ -265,13 +266,14 @@ if ( $match =~ m#/# ) { $matcher->threshold( 1000 * scalar(@matchers) - 1 ); $matcher->code('TEMP'); $matcher->description('Temporary matcher for deduplication run'); - while ( $matchers[ $cnt++ ] =~ m#^([^/]+)/([0-9]{3})(.*)$# ) { + while ( $matchers[ $cnt ] && $matchers[ $cnt++ ] =~ m#^([^/]+)/([0-9]{3})(.*)$# ) { $matcher->add_simple_matchpoint( $1, 1000, $2, $3, 0, 0, '' ); } + $check ||= ''; my @checks = split( ',', $check ); $cnt = 0; - while ( $checks[ $cnt++ ] =~ m#^([0-9]{3})(.*)$# ) { - $matcher->add_simple_required_check( $1, $2, 0, 0, $1, $2, 0, 0, '' ); + while ( $checks[ $cnt ] && $checks[ $cnt++ ] =~ m#^([0-9]{3})(.*)$# ) { + $matcher->add_simple_required_check( $1, $2, 0, 0, '', $1, $2, 0, 0, '' ); } } else { -- 1.7.9.5