Bugzilla – Attachment 175420 Details for
Bug 38693
dedup_authorities.pl - Add methods match-subfield and get-subfield
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38693 - dedup_authorities.pl - Add methods match-subfield and get-subfield
0001-Bug-38693-dedup_authorities.pl-Add-methods-match-sub.patch (text/plain), 4.10 KB, created by
Olli-Antti Kivilahti
on 2024-12-12 20:11:27 UTC
(
hide
)
Description:
Bug 38693 - dedup_authorities.pl - Add methods match-subfield and get-subfield
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2024-12-12 20:11:27 UTC
Size:
4.10 KB
patch
obsolete
>From e46e158ac82ff8669b6f348a8ca024adbdcd5432 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@hypernova.fi> >Date: Thu, 12 Dec 2024 22:05:13 +0200 >Subject: [PATCH] Bug 38693 - dedup_authorities.pl - Add methods match-subfield > and get-subfield > >Enables choosing the authority record with the biggest 001 >--method="get-subfield=001" > >Enables choosing the authority record from a specific cataloguing source >--method="match-subfield=040.a=FI-NL" > >With this combination authority records from a national authorities >repository can be merged to unofficial local authorities, while also >overwriting duplicate old records from the same source. >--- > bin/maintenance/dedup_authorities.pl | 43 ++++++++++++++++++++++++++-- > 1 file changed, 40 insertions(+), 3 deletions(-) > >diff --git a/bin/maintenance/dedup_authorities.pl b/bin/maintenance/dedup_authorities.pl >index 67cfb5d3..fb23bc68 100755 >--- a/bin/maintenance/dedup_authorities.pl >+++ b/bin/maintenance/dedup_authorities.pl >@@ -28,8 +28,8 @@ dedup_authorities.pl [ -h ] [ -where="authid < 5000" ] -c [ -v ] [ -m d ] [ -a P > Options: > -h --help display usage statement > -v --verbose increase verbosity, can be repeated for greater verbosity >- -m --method method for choosing the reference authority, can be: date, used, or ppn (UNIMARC) >- can be repeated >+ -m --method method for choosing the reference authority, can be: date, used, get-subfield, >+ match-subfield or ppn (UNIMARC). Can be repeated > -w --where a SQL WHERE statement to limit the authority records checked > -c --confirm without this parameter no changes will be made, script will run in test mode > -a --authtypecode check only specified auth type, repeatable >@@ -47,11 +47,13 @@ and in which order. > Letters can be: > date: keep the most recent authority (based on 005 field) > used: keep the most used authority >+ get-subfield: keep the authority that has a bigger sort value from the given subfield >+ match-subfield: keep the authority that exactly matches the subfield's content > ppn: PPN (UNIMARC only), keep the authority with a ppn (when some > authorities don't have one, based on 009 field) > > Example: >--m ppn -m date -m used >+-m ppn -m date -m used -m "match-subfield=040.a=FI-NL" -m "get-subfield=001" > Among the authorities that have a PPN, keep the most recent, > and if two (or more) have the same date in 005, keep the > most used. >@@ -113,6 +115,19 @@ foreach my $method (@methods) { > push @choose_subs, \&_has_ppn; > } elsif ( $method eq 'used' ) { > push @choose_subs, \&_get_usage; >+ } elsif ( $method =~ /^get-subfield\W >+ (?<field>\d\d\d)\W? >+ (?<subfield>\w)?$ >+ /x ) { >+ my ($field, $subfield) = ($+{field}, $+{subfield}); >+ push @choose_subs, sub { _get_subfield($field, $subfield, @_); }; >+ } elsif ( $method =~ /^match-subfield\W >+ (?<field>\d\d\d)\W >+ (?<subfield>\w)\W >+ (?<content>.*)$ >+ /x ) { >+ my ($field, $subfield, $content) = ($+{field}, $+{subfield}, $+{content}); >+ push @choose_subs, sub { _match_subfield($field, $subfield, $content, @_); }; > } else { > warn "Choose method '$method' is not supported"; > } >@@ -305,6 +320,28 @@ sub _get_usage { > return 0; > } > >+sub _get_subfield { >+ my ($field, $subfield, $record) = @_; >+ if ( $record ) { >+ if ( not(defined $subfield) or $subfield eq '' ) { >+ my $f = $record->field($field); >+ return $f->data if $f; >+ } >+ else { >+ $record->subfield($field, $subfield); >+ } >+ } >+ return 0; >+} >+ >+sub _match_subfield { >+ my ($field, $subfield, $content, $record) = @_; >+ if ( $record and $record->subfield($field, $subfield) eq $content ) { >+ return 1; >+ } >+ return 0; >+} >+ > =head2 _choose_records > this function takes input of candidate record ids to merging > and returns >-- >2.34.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38693
: 175420