$marc->add_fields( WebPAC::Normalize:_get_marc21_fields() );
-B<TODO>: implement exceptions to magic which unrolls repeated subfields
-as new field with that subfield.
+
+
+We are using I<magic> 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<TODO>: implement exceptions to magic
=cut
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);
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 ];
}