/[webpac2]/trunk/lib/WebPAC/Normalize/MARC.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Normalize/MARC.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1038 by dpavlin, Mon Nov 12 11:57:00 2007 UTC revision 1039 by dpavlin, Mon Nov 12 12:13:57 2007 UTC
# Line 58  Returns number of records produced. Line 58  Returns number of records produced.
58    
59  =cut  =cut
60    
61    my $created_with_marc_template;
62    
63  sub marc_template {  sub marc_template {
64          my $args = {@_};          my $args = {@_};
65          warn "## marc_template(",dump($args),")",$/ if $debug;          warn "## marc_template(",dump($args),")",$/ if $debug;
# Line 134  sub marc_template { Line 136  sub marc_template {
136    
137                  my $i1 = $r->{i1} || ' ';                  my $i1 = $r->{i1} || ' ';
138                  my $i2 = $r->{i2} || ' ';                  my $i2 = $r->{i2} || ' ';
139                  $m = [ $args->{to}, $i1, $i2 ];                  my $to = $args->{to};
140                    $m = [ $to, $i1, $i2 ];
141    
142                    $created_with_marc_template->{ $to }++;
143    
144                  warn "### r = ",dump( $r ),$/ if $debug;                  warn "### r = ",dump( $r ),$/ if $debug;
145    
# Line 610  sub marc_count { Line 615  sub marc_count {
615          return $#{ $marc_record };          return $#{ $marc_record };
616  }  }
617    
618    =head1 PRIVATE FUNCTIONS
619    
620  =head2 _marc_push  =head2 _marc_push
621    
622   _marc_push( $marc );   _marc_push( $marc );
# Line 621  sub _marc_push { Line 628  sub _marc_push {
628          push @{ $marc_record->[ $marc_record_offset ] }, $marc;          push @{ $marc_record->[ $marc_record_offset ] }, $marc;
629  }  }
630    
 =head1 PRIVATE FUNCTIONS  
   
631  =head2 _clean  =head2 _clean
632    
633  Clean internal structures  Clean internal structures
# Line 630  Clean internal structures Line 635  Clean internal structures
635  =cut  =cut
636    
637  sub _clean {  sub _clean {
638          ($marc_record, $marc_encoding, $marc_repeatable_subfield, $marc_indicators, $marc_leader) = ();          ($marc_record, $marc_encoding, $marc_repeatable_subfield, $marc_indicators, $marc_leader, $created_with_marc_template) = ();
639          ($marc_record_offset, $marc_fetch_offset) = (0,0);          ($marc_record_offset, $marc_fetch_offset) = (0,0);
640  }  }
641    
# Line 644  Get all fields defined by calls to C<mar Line 649  Get all fields defined by calls to C<mar
649  We are using I<magic> which detect repeatable fields only from  We are using I<magic> which detect repeatable fields only from
650  sequence of field/subfield data generated by normalization.  sequence of field/subfield data generated by normalization.
651    
652    This magic is disabled for all records created with C<marc_template>.
653    
654  Repeatable field is created when there is second occurence of same subfield or  Repeatable field is created when there is second occurence of same subfield or
655  if any of indicators are different.  if any of indicators are different.
656    
# Line 715  sub _get_marc_fields { Line 722  sub _get_marc_fields {
722    
723          # first, sort all existing fields          # first, sort all existing fields
724          # XXX might not be needed, but modern perl might randomize elements in hash          # XXX might not be needed, but modern perl might randomize elements in hash
725          my @sorted_marc_record = sort {  #       my @sorted_marc_record = sort {
726                  $a->[0] . ( $a->[3] || '' ) cmp $b->[0] . ( $b->[3] || '')  #               $a->[0] . ( $a->[3] || '' ) cmp $b->[0] . ( $b->[3] || '')
727          } @{ $marc_rec };  #       } @{ $marc_rec };
728    
729          @sorted_marc_record = @{ $marc_rec };   ### FIXME disable sorting          @sorted_marc_record = @{ $marc_rec };   ### FIXME disable sorting
730                    
# Line 752  sub _get_marc_fields { Line 759  sub _get_marc_fields {
759    
760                  my $row = dclone( $sorted_marc_record[$i] );                  my $row = dclone( $sorted_marc_record[$i] );
761    
762                    if ( $created_with_marc_template->{ $row->[0] } ) {
763                            push @m, $row;
764                            warn "## copied marc_template created ", dump( $row ),$/ if $debug;
765                            next;
766                    }
767                  # field and subfield which is key for                  # field and subfield which is key for
768                  # marc_repeatable_subfield and u                  # marc_repeatable_subfield and u
769                  my $fsf = $row->[0] . ( $row->[3] || '' );                  my $fsf = $row->[0] . ( $row->[3] || '' );

Legend:
Removed from v.1038  
changed lines
  Added in v.1039

  ViewVC Help
Powered by ViewVC 1.1.26