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 |
|
|
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); |
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 |
} |
} |