--- trunk/lib/WebPAC/Normalize.pm 2006/06/29 21:18:59 542 +++ trunk/lib/WebPAC/Normalize.pm 2006/06/29 21:19:08 543 @@ -152,8 +152,16 @@ $marc->add_fields( WebPAC::Normalize:_get_marc21_fields() ); -B: implement exceptions to magic which unrolls repeated subfields -as new field with that subfield. + + +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 @@ -161,19 +169,19 @@ 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 + 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 - ) ) { - $last->[3]->{ $row->[3] } = $row->[4]; - warn "## ++ added $row->[0] ^$row->[3]\n"; + ) { + push @$last, ( $row->[3] , $row->[4] ); + warn "## ++ added $row->[0] ^$row->[3] to $last->[0]\n"; next; } elsif ($last) { push @m, $last; } - push @m, $row; + $last = $row; } push @m, $last if ($last); @@ -251,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 ]; }