7 |
_debug |
_debug |
8 |
_pack_subfields_hash |
_pack_subfields_hash |
9 |
|
|
10 |
tag 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 |
14 |
marc_duplicate marc_remove marc_count |
marc_duplicate marc_remove marc_count |
41 |
|
|
42 |
WebPAC::Normalize - describe normalisaton rules using sets |
WebPAC::Normalize - describe normalisaton rules using sets |
43 |
|
|
|
=head1 VERSION |
|
|
|
|
|
Version 0.29 |
|
|
|
|
44 |
=cut |
=cut |
45 |
|
|
46 |
our $VERSION = '0.29'; |
our $VERSION = '0.31'; |
47 |
|
|
48 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
49 |
|
|
56 |
C<perl -c normalize.pl>. |
C<perl -c normalize.pl>. |
57 |
|
|
58 |
Normalisation can generate multiple output normalized data. For now, supported output |
Normalisation can generate multiple output normalized data. For now, supported output |
59 |
types (on the left side of definition) are: C<tag>, C<display>, C<search> and |
types (on the left side of definition) are: C<search_display>, C<display>, C<search> and |
60 |
C<marc>. |
C<marc>. |
61 |
|
|
62 |
=head1 FUNCTIONS |
=head1 FUNCTIONS |
439 |
|
|
440 |
Those functions generally have to first in your normalization file. |
Those functions generally have to first in your normalization file. |
441 |
|
|
442 |
=head2 tag |
=head2 search_display |
443 |
|
|
444 |
Define new tag for I<search> and I<display>. |
Define output for L<search> and L<display> at the same time |
445 |
|
|
446 |
tag('Title', rec('200','a') ); |
search_display('Title', rec('200','a') ); |
447 |
|
|
448 |
|
|
449 |
=cut |
=cut |
450 |
|
|
451 |
sub tag { |
sub search_display { |
452 |
my $name = shift or die "tag needs name as first argument"; |
my $name = shift or die "search_display needs name as first argument"; |
453 |
my @o = grep { defined($_) && $_ ne '' } @_; |
my @o = grep { defined($_) && $_ ne '' } @_; |
454 |
return unless (@o); |
return unless (@o); |
|
$out->{$name}->{tag} = $name; |
|
455 |
$out->{$name}->{search} = \@o; |
$out->{$name}->{search} = \@o; |
456 |
$out->{$name}->{display} = \@o; |
$out->{$name}->{display} = \@o; |
457 |
} |
} |
458 |
|
|
459 |
|
=head2 tag |
460 |
|
|
461 |
|
Old name for L<search_display>, but supported |
462 |
|
|
463 |
|
=cut |
464 |
|
|
465 |
|
sub tag { |
466 |
|
search_display( @_ ); |
467 |
|
} |
468 |
|
|
469 |
=head2 display |
=head2 display |
470 |
|
|
471 |
Define tag just for I<display> |
Define output just for I<display> |
472 |
|
|
473 |
@v = display('Title', rec('200','a') ); |
@v = display('Title', rec('200','a') ); |
474 |
|
|
475 |
=cut |
=cut |
476 |
|
|
477 |
sub display { |
sub _field { |
478 |
my $name = shift or die "display needs name as first argument"; |
my $type = shift or confess "need type -- BUG?"; |
479 |
|
my $name = shift or confess "needs name as first argument"; |
480 |
my @o = grep { defined($_) && $_ ne '' } @_; |
my @o = grep { defined($_) && $_ ne '' } @_; |
481 |
return unless (@o); |
return unless (@o); |
482 |
$out->{$name}->{tag} = $name; |
$out->{$name}->{$type} = \@o; |
|
$out->{$name}->{display} = \@o; |
|
483 |
} |
} |
484 |
|
|
485 |
|
sub display { _field( 'display', @_ ) } |
486 |
|
|
487 |
=head2 search |
=head2 search |
488 |
|
|
489 |
Prepare values just for I<search> |
Prepare values just for I<search> |
492 |
|
|
493 |
=cut |
=cut |
494 |
|
|
495 |
sub search { |
sub search { _field( 'search', @_ ) } |
496 |
my $name = shift or die "search needs name as first argument"; |
|
497 |
my @o = grep { defined($_) && $_ ne '' } @_; |
=head2 sorted |
498 |
return unless (@o); |
|
499 |
$out->{$name}->{tag} = $name; |
Insert into lists which will be automatically sorted |
500 |
$out->{$name}->{search} = \@o; |
|
501 |
} |
sorted('Title', rec('200','a') ); |
502 |
|
|
503 |
|
=cut |
504 |
|
|
505 |
|
sub sorted { _field( 'sorted', @_ ) } |
506 |
|
|
507 |
|
|
508 |
=head2 marc_leader |
=head2 marc_leader |
509 |
|
|
548 |
my ($f, $pos, $val) = @_; |
my ($f, $pos, $val) = @_; |
549 |
die "need marc(field, position, value)" unless defined($f) && defined($pos); |
die "need marc(field, position, value)" unless defined($f) && defined($pos); |
550 |
|
|
551 |
|
confess "need val" unless defined $val; |
552 |
|
|
553 |
my $update = 0; |
my $update = 0; |
554 |
|
|
555 |
map { |
map { |
556 |
if ($_->[0] eq $f) { |
if ($_->[0] eq $f) { |
557 |
my $old = $_->[1]; |
my $old = $_->[1]; |
558 |
if (length($old) < $pos) { |
if (length($old) <= $pos) { |
559 |
$_->[1] .= ' ' x ( $pos - length($old) ) . $val; |
$_->[1] .= ' ' x ( $pos - length($old) ) . $val; |
560 |
warn "## marc_fixed($f,$pos,'$val') append '$old' -> '$_->[1]'\n" if ($debug > 1); |
warn "## marc_fixed($f,$pos,'$val') append '$old' -> '$_->[1]'\n" if ($debug > 1); |
561 |
} else { |
} else { |
1245 |
$database_code = config(); # use _ from hash |
$database_code = config(); # use _ from hash |
1246 |
$database_name = config('name'); |
$database_name = config('name'); |
1247 |
$database_input_name = config('input name'); |
$database_input_name = config('input name'); |
|
$tag = config('input normalize tag'); |
|
1248 |
|
|
1249 |
Up to three levels are supported. |
Up to three levels are supported. |
1250 |
|
|