/[webpac2]/trunk/lib/WebPAC/Normalize.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.pm

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

revision 542 by dpavlin, Thu Jun 29 21:18:59 2006 UTC revision 543 by dpavlin, Thu Jun 29 21:19:08 2006 UTC
# Line 152  Get all fields defined by calls to C<mar Line 152  Get all fields defined by calls to C<mar
152    
153          $marc->add_fields( WebPAC::Normalize:_get_marc21_fields() );          $marc->add_fields( WebPAC::Normalize:_get_marc21_fields() );
154    
155  B<TODO>: implement exceptions to magic which unrolls repeated subfields  
156  as new field with that subfield.  
157    We are using I<magic> which detect repeatable fields only from
158    sequence of field/subfield data generated by normalization.
159    
160    Repeatable field is created if there is second occurence of same subfield or
161    if any of indicators are different. This is sane for most cases except for
162    non-repeatable fields with repeatable subfields.
163    
164    B<TODO>: implement exceptions to magic
165    
166  =cut  =cut
167    
# Line 161  sub _get_marc21_fields { Line 169  sub _get_marc21_fields {
169          my @m;          my @m;
170          my $last;          my $last;
171          foreach my $row (@{ $marc21 }) {          foreach my $row (@{ $marc21 }) {
172                  if ($last && (                  if ($last &&
173                          $last->[0] eq $row->[0] ||              # check if field is same                          $last->[0] eq $row->[0] &&              # check if field is same
174                          $last->[1] eq $row->[1] ||              # check for i1                          $last->[1] eq $row->[1] &&              # check for i1
175                          $last->[2] eq $row->[2]                 # and for i2                          $last->[2] eq $row->[2]                 # and for i2
176                  ) ) {                  ) {
177                          $last->[3]->{ $row->[3] } = $row->[4];                          push @$last, ( $row->[3] , $row->[4] );
178                          warn "## ++ added $row->[0] ^$row->[3]\n";                          warn "## ++ added $row->[0] ^$row->[3] to $last->[0]\n";
179                          next;                          next;
180                  } elsif ($last) {                  } elsif ($last) {
181                          push @m, $last;                          push @m, $last;
182                  }                  }
183    
184                  push @m, $row;                  $last = $row;
185          }          }
186    
187          push @m, $last if ($last);          push @m, $last if ($last);
# Line 251  sub marc21 { Line 259  sub marc21 {
259    
260          foreach (@_) {          foreach (@_) {
261                  my $v = $_;             # make var read-write for Encode                  my $v = $_;             # make var read-write for Encode
262                  next unless (defined($v) && $v !~ /^\s+$/);                  next unless (defined($v) && $v !~ /^\s*$/);
263                  from_to($v, 'iso-8859-2', $marc_encoding) if ($marc_encoding);                  from_to($v, 'iso-8859-2', $marc_encoding) if ($marc_encoding);
264                  push @{ $marc21 }, [ $f, ' ', ' ', $sf => $v ];                  push @{ $marc21 }, [ $f, ' ', ' ', $sf => $v ];
265          }          }

Legend:
Removed from v.542  
changed lines
  Added in v.543

  ViewVC Help
Powered by ViewVC 1.1.26