Lines 28-35
dedup_authorities.pl [ -h ] [ -where="authid < 5000" ] -c [ -v ] [ -m d ] [ -a P
Link Here
|
28 |
Options: |
28 |
Options: |
29 |
-h --help display usage statement |
29 |
-h --help display usage statement |
30 |
-v --verbose increase verbosity, can be repeated for greater verbosity |
30 |
-v --verbose increase verbosity, can be repeated for greater verbosity |
31 |
-m --method method for choosing the reference authority, can be: date, used, or ppn (UNIMARC) |
31 |
-m --method method for choosing the reference authority, can be: date, used, get-subfield, |
32 |
can be repeated |
32 |
match-subfield or ppn (UNIMARC). Can be repeated |
33 |
-w --where a SQL WHERE statement to limit the authority records checked |
33 |
-w --where a SQL WHERE statement to limit the authority records checked |
34 |
-c --confirm without this parameter no changes will be made, script will run in test mode |
34 |
-c --confirm without this parameter no changes will be made, script will run in test mode |
35 |
-a --authtypecode check only specified auth type, repeatable |
35 |
-a --authtypecode check only specified auth type, repeatable |
Lines 47-57
and in which order.
Link Here
|
47 |
Letters can be: |
47 |
Letters can be: |
48 |
date: keep the most recent authority (based on 005 field) |
48 |
date: keep the most recent authority (based on 005 field) |
49 |
used: keep the most used authority |
49 |
used: keep the most used authority |
|
|
50 |
get-subfield: keep the authority that has a bigger sort value from the given subfield |
51 |
match-subfield: keep the authority that exactly matches the subfield's content |
50 |
ppn: PPN (UNIMARC only), keep the authority with a ppn (when some |
52 |
ppn: PPN (UNIMARC only), keep the authority with a ppn (when some |
51 |
authorities don't have one, based on 009 field) |
53 |
authorities don't have one, based on 009 field) |
52 |
|
54 |
|
53 |
Example: |
55 |
Example: |
54 |
-m ppn -m date -m used |
56 |
-m ppn -m date -m used -m "match-subfield=040.a=FI-NL" -m "get-subfield=001" |
55 |
Among the authorities that have a PPN, keep the most recent, |
57 |
Among the authorities that have a PPN, keep the most recent, |
56 |
and if two (or more) have the same date in 005, keep the |
58 |
and if two (or more) have the same date in 005, keep the |
57 |
most used. |
59 |
most used. |
Lines 113-118
foreach my $method (@methods) {
Link Here
|
113 |
push @choose_subs, \&_has_ppn; |
115 |
push @choose_subs, \&_has_ppn; |
114 |
} elsif ( $method eq 'used' ) { |
116 |
} elsif ( $method eq 'used' ) { |
115 |
push @choose_subs, \&_get_usage; |
117 |
push @choose_subs, \&_get_usage; |
|
|
118 |
} elsif ( $method =~ /^get-subfield\W |
119 |
(?<field>\d\d\d)\W? |
120 |
(?<subfield>\w)?$ |
121 |
/x ) { |
122 |
my ($field, $subfield) = ($+{field}, $+{subfield}); |
123 |
push @choose_subs, sub { _get_subfield($field, $subfield, @_); }; |
124 |
} elsif ( $method =~ /^match-subfield\W |
125 |
(?<field>\d\d\d)\W |
126 |
(?<subfield>\w)\W |
127 |
(?<content>.*)$ |
128 |
/x ) { |
129 |
my ($field, $subfield, $content) = ($+{field}, $+{subfield}, $+{content}); |
130 |
push @choose_subs, sub { _match_subfield($field, $subfield, $content, @_); }; |
116 |
} else { |
131 |
} else { |
117 |
warn "Choose method '$method' is not supported"; |
132 |
warn "Choose method '$method' is not supported"; |
118 |
} |
133 |
} |
Lines 305-310
sub _get_usage {
Link Here
|
305 |
return 0; |
320 |
return 0; |
306 |
} |
321 |
} |
307 |
|
322 |
|
|
|
323 |
sub _get_subfield { |
324 |
my ($field, $subfield, $record) = @_; |
325 |
if ( $record ) { |
326 |
if ( not(defined $subfield) or $subfield eq '' ) { |
327 |
my $f = $record->field($field); |
328 |
return $f->data if $f; |
329 |
} |
330 |
else { |
331 |
$record->subfield($field, $subfield); |
332 |
} |
333 |
} |
334 |
return 0; |
335 |
} |
336 |
|
337 |
sub _match_subfield { |
338 |
my ($field, $subfield, $content, $record) = @_; |
339 |
if ( $record and $record->subfield($field, $subfield) eq $content ) { |
340 |
return 1; |
341 |
} |
342 |
return 0; |
343 |
} |
344 |
|
308 |
=head2 _choose_records |
345 |
=head2 _choose_records |
309 |
this function takes input of candidate record ids to merging |
346 |
this function takes input of candidate record ids to merging |
310 |
and returns |
347 |
and returns |
311 |
- |
|
|