1 |
package WebPAC::Normalize; |
package WebPAC::Normalize; |
2 |
use Exporter 'import'; |
use Exporter 'import'; |
3 |
@EXPORT = qw/ |
our @EXPORT = qw/ |
4 |
_set_rec _set_lookup |
_set_rec _set_lookup |
5 |
_set_load_row |
_set_load_row |
6 |
_get_ds _clean_ds |
_get_ds _clean_ds |
7 |
_debug |
_debug |
8 |
_pack_subfields_hash |
_pack_subfields_hash |
9 |
|
|
10 |
search_display search display |
search_display search display sorted |
11 |
|
|
12 |
marc marc_indicators marc_repeatable_subfield |
marc marc_indicators marc_repeatable_subfield |
13 |
marc_compose marc_leader marc_fixed |
marc_compose marc_leader marc_fixed |
15 |
marc_original_order |
marc_original_order |
16 |
|
|
17 |
rec1 rec2 rec |
rec1 rec2 rec |
18 |
|
frec |
19 |
regex prefix suffix surround |
regex prefix suffix surround |
20 |
first lookup join_with |
first lookup join_with |
21 |
save_into_lookup |
save_into_lookup |
24 |
|
|
25 |
get set |
get set |
26 |
count |
count |
27 |
|
|
28 |
/; |
/; |
29 |
|
|
30 |
use warnings; |
use warnings; |
38 |
# debugging warn(s) |
# debugging warn(s) |
39 |
my $debug = 0; |
my $debug = 0; |
40 |
|
|
41 |
|
use WebPAC::Normalize::ISBN; |
42 |
|
push @EXPORT, ( 'isbn_10', 'isbn_13' ); |
43 |
|
|
44 |
=head1 NAME |
=head1 NAME |
45 |
|
|
46 |
WebPAC::Normalize - describe normalisaton rules using sets |
WebPAC::Normalize - describe normalisaton rules using sets |
47 |
|
|
|
=head1 VERSION |
|
|
|
|
|
Version 0.30 |
|
|
|
|
48 |
=cut |
=cut |
49 |
|
|
50 |
our $VERSION = '0.30'; |
our $VERSION = '0.31'; |
51 |
|
|
52 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
53 |
|
|
79 |
marc_encoding => 'utf-8', |
marc_encoding => 'utf-8', |
80 |
config => $config, |
config => $config, |
81 |
load_row_coderef => sub { |
load_row_coderef => sub { |
82 |
my ($database,$input,$mfn) = shift; |
my ($database,$input,$mfn) = @_; |
83 |
$store->load_row( database => $database, input => $input, id => $mfn ); |
$store->load_row( database => $database, input => $input, id => $mfn ); |
84 |
}, |
}, |
85 |
); |
); |
172 |
my ($marc_record_offset, $marc_fetch_offset) = (0, 0); |
my ($marc_record_offset, $marc_fetch_offset) = (0, 0); |
173 |
|
|
174 |
sub _get_ds { |
sub _get_ds { |
175 |
|
#warn "## out = ",dump($out); |
176 |
return $out; |
return $out; |
177 |
} |
} |
178 |
|
|
461 |
$out->{$name}->{display} = \@o; |
$out->{$name}->{display} = \@o; |
462 |
} |
} |
463 |
|
|
464 |
|
=head2 tag |
465 |
|
|
466 |
|
Old name for L<search_display>, but supported |
467 |
|
|
468 |
|
=cut |
469 |
|
|
470 |
|
sub tag { |
471 |
|
search_display( @_ ); |
472 |
|
} |
473 |
|
|
474 |
=head2 display |
=head2 display |
475 |
|
|
476 |
Define output just for I<display> |
Define output just for I<display> |
479 |
|
|
480 |
=cut |
=cut |
481 |
|
|
482 |
sub display { |
sub _field { |
483 |
my $name = shift or die "display needs name as first argument"; |
my $type = shift or confess "need type -- BUG?"; |
484 |
|
my $name = shift or confess "needs name as first argument"; |
485 |
my @o = grep { defined($_) && $_ ne '' } @_; |
my @o = grep { defined($_) && $_ ne '' } @_; |
486 |
return unless (@o); |
return unless (@o); |
487 |
$out->{$name}->{display} = \@o; |
$out->{$name}->{$type} = \@o; |
488 |
} |
} |
489 |
|
|
490 |
|
sub display { _field( 'display', @_ ) } |
491 |
|
|
492 |
=head2 search |
=head2 search |
493 |
|
|
494 |
Prepare values just for I<search> |
Prepare values just for I<search> |
497 |
|
|
498 |
=cut |
=cut |
499 |
|
|
500 |
sub search { |
sub search { _field( 'search', @_ ) } |
501 |
my $name = shift or die "search needs name as first argument"; |
|
502 |
my @o = grep { defined($_) && $_ ne '' } @_; |
=head2 sorted |
503 |
return unless (@o); |
|
504 |
$out->{$name}->{search} = \@o; |
Insert into lists which will be automatically sorted |
505 |
} |
|
506 |
|
sorted('Title', rec('200','a') ); |
507 |
|
|
508 |
|
=cut |
509 |
|
|
510 |
|
sub sorted { _field( 'sorted', @_ ) } |
511 |
|
|
512 |
|
|
513 |
=head2 marc_leader |
=head2 marc_leader |
514 |
|
|
999 |
|
|
1000 |
=cut |
=cut |
1001 |
|
|
1002 |
|
sub frec { |
1003 |
|
my @out = rec(@_); |
1004 |
|
warn "rec(",dump(@_),") has more than one return value, ignoring\n" if $#out > 0; |
1005 |
|
return shift @out; |
1006 |
|
} |
1007 |
|
|
1008 |
sub rec { |
sub rec { |
1009 |
my @out; |
my @out; |
1010 |
if ($#_ == 0) { |
if ($#_ == 0) { |