--- trunk/lib/WebPAC/Normalize.pm 2006/06/29 21:18:50 541 +++ trunk/lib/WebPAC/Normalize.pm 2006/06/29 21:19:08 543 @@ -152,10 +152,41 @@ $marc->add_fields( WebPAC::Normalize:_get_marc21_fields() ); + + +We are using I which detect repeatable fields only from +sequence of field/subfield data generated by normalization. + +Repeatable field is created if there is second occurence of same subfield or +if any of indicators are different. This is sane for most cases except for +non-repeatable fields with repeatable subfields. + +B: implement exceptions to magic + =cut sub _get_marc21_fields { - return @{$marc21}; + my @m; + my $last; + foreach my $row (@{ $marc21 }) { + if ($last && + $last->[0] eq $row->[0] && # check if field is same + $last->[1] eq $row->[1] && # check for i1 + $last->[2] eq $row->[2] # and for i2 + ) { + push @$last, ( $row->[3] , $row->[4] ); + warn "## ++ added $row->[0] ^$row->[3] to $last->[0]\n"; + next; + } elsif ($last) { + push @m, $last; + } + + $last = $row; + } + + push @m, $last if ($last); + + return @m; } =head1 Functions to create C @@ -228,7 +259,7 @@ foreach (@_) { my $v = $_; # make var read-write for Encode - next unless (defined($v) && $v !~ /^\s+$/); + next unless (defined($v) && $v !~ /^\s*$/); from_to($v, 'iso-8859-2', $marc_encoding) if ($marc_encoding); push @{ $marc21 }, [ $f, ' ', ' ', $sf => $v ]; }