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 |
|
|
158 |
=cut |
=cut |
159 |
|
|
160 |
sub _get_marc21_fields { |
sub _get_marc21_fields { |
161 |
return @{$marc21}; |
my @m; |
162 |
|
my $last; |
163 |
|
foreach my $row (@{ $marc21 }) { |
164 |
|
if ($last && ( |
165 |
|
$last->[0] eq $row->[0] || # check if field is same |
166 |
|
$last->[1] eq $row->[1] || # check for i1 |
167 |
|
$last->[2] eq $row->[2] # and for i2 |
168 |
|
) ) { |
169 |
|
$last->[3]->{ $row->[3] } = $row->[4]; |
170 |
|
warn "## ++ added $row->[0] ^$row->[3]\n"; |
171 |
|
next; |
172 |
|
} elsif ($last) { |
173 |
|
push @m, $last; |
174 |
|
} |
175 |
|
|
176 |
|
push @m, $row; |
177 |
|
} |
178 |
|
|
179 |
|
push @m, $last if ($last); |
180 |
|
|
181 |
|
return @m; |
182 |
} |
} |
183 |
|
|
184 |
=head1 Functions to create C<data_structure> |
=head1 Functions to create C<data_structure> |