5 |
_get_ds _clean_ds |
_get_ds _clean_ds |
6 |
|
|
7 |
tag search display |
tag search display |
8 |
|
marc21 |
9 |
|
|
10 |
rec1 rec2 rec |
rec1 rec2 rec |
11 |
regex prefix suffix surround |
regex prefix suffix surround |
12 |
first lookup join_with |
first lookup join_with |
41 |
C<perl -c normalize.pl>. |
C<perl -c normalize.pl>. |
42 |
|
|
43 |
Normalisation can generate multiple output normalized data. For now, supported output |
Normalisation can generate multiple output normalized data. For now, supported output |
44 |
types (on the left side of definition) are: C<tag>, C<display> and C<search>. |
types (on the left side of definition) are: C<tag>, C<display>, C<search> and |
45 |
|
C<marc21>. |
46 |
|
|
47 |
=head1 FUNCTIONS |
=head1 FUNCTIONS |
48 |
|
|
59 |
rules => $normalize_pl_config, |
rules => $normalize_pl_config, |
60 |
); |
); |
61 |
|
|
62 |
|
Options C<lookup>, C<row>, C<rules> and C<log> are mandatory while all |
63 |
|
other are optional. |
64 |
|
|
65 |
This function will B<die> if normalizastion can't be evaled. |
This function will B<die> if normalizastion can't be evaled. |
66 |
|
|
67 |
Since this function isn't exported you have to call it with |
Since this function isn't exported you have to call it with |
79 |
_set_lookup( $arg->{lookup} ); |
_set_lookup( $arg->{lookup} ); |
80 |
_set_rec( $arg->{row} ); |
_set_rec( $arg->{row} ); |
81 |
_clean_ds(); |
_clean_ds(); |
82 |
|
|
83 |
eval "$arg->{rules}"; |
eval "$arg->{rules}"; |
84 |
die "error evaling $arg->{rules}: $@\n" if ($@); |
die "error evaling $arg->{rules}: $@\n" if ($@); |
85 |
|
|
86 |
return _get_ds(); |
return _get_ds(); |
87 |
} |
} |
88 |
|
|
109 |
=cut |
=cut |
110 |
|
|
111 |
my $out; |
my $out; |
112 |
|
my $marc21; |
113 |
|
|
114 |
sub _get_ds { |
sub _get_ds { |
115 |
return $out; |
return $out; |
125 |
|
|
126 |
sub _clean_ds { |
sub _clean_ds { |
127 |
$out = undef; |
$out = undef; |
128 |
|
$marc21 = undef; |
129 |
} |
} |
130 |
|
|
131 |
=head2 _set_lookup |
=head2 _set_lookup |
142 |
$lookup = shift; |
$lookup = shift; |
143 |
} |
} |
144 |
|
|
145 |
|
=head2 _get_marc21_fields |
146 |
|
|
147 |
|
Get all fields defined by calls to C<marc21> |
148 |
|
|
149 |
|
$marc->add_fields( WebPAC::Normalize:_get_marc21_fields() ); |
150 |
|
|
151 |
|
=cut |
152 |
|
|
153 |
|
sub _get_marc21_fields { |
154 |
|
return @{$marc21}; |
155 |
|
} |
156 |
|
|
157 |
|
=head1 Functions to create C<data_structure> |
158 |
|
|
159 |
|
Those functions generally have to first in your normalization file. |
160 |
|
|
161 |
=head2 tag |
=head2 tag |
162 |
|
|
163 |
Define new tag for I<search> and I<display>. |
Define new tag for I<search> and I<display>. |
208 |
$out->{$name}->{search} = \@o; |
$out->{$name}->{search} = \@o; |
209 |
} |
} |
210 |
|
|
211 |
|
=head2 marc21 |
212 |
|
|
213 |
|
Save value for MARC field |
214 |
|
|
215 |
|
marc21('900','a', rec('200','a') ); |
216 |
|
|
217 |
|
=cut |
218 |
|
|
219 |
|
sub marc21 { |
220 |
|
my $f = shift or die "marc21 needs field"; |
221 |
|
die "marc21 field must be numer" unless ($f =~ /^\d+$/); |
222 |
|
|
223 |
|
my $sf = shift or die "marc21 needs subfield"; |
224 |
|
|
225 |
|
foreach my $v (@_) { |
226 |
|
push @{ $marc21 }, [ $f, ' ', ' ', $sf => $v ]; |
227 |
|
} |
228 |
|
} |
229 |
|
|
230 |
|
=head1 Functions to extract data from input |
231 |
|
|
232 |
|
This function should be used inside functions to create C<data_structure> described |
233 |
|
above. |
234 |
|
|
235 |
=head2 rec1 |
=head2 rec1 |
236 |
|
|
237 |
Return all values in some field |
Return all values in some field |