-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFilter.pm
468 lines (405 loc) · 17.9 KB
/
Filter.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
package App::MARC::Filter;
use strict;
use warnings;
use Class::Utils qw(set_params);
use English;
use Error::Pure qw(err);
use Getopt::Std;
use List::MoreUtils qw(none);
use MARC::File::XML (BinaryEncoding => 'utf8', RecordFormat => 'MARC21');
use Readonly;
use Unicode::UTF8 qw(encode_utf8 decode_utf8);
Readonly::Array our @OUTPUT_FORMATS => qw(ascii xml);
our $VERSION = 0.04;
# Constructor.
sub new {
my ($class, @params) = @_;
# Create object.
my $self = bless {}, $class;
# Process parameters.
set_params($self, @params);
# Object.
return $self;
}
# Run.
sub run {
my $self = shift;
# Process arguments.
$self->{'_opts'} = {
'h' => 0,
'o' => 'xml',
'r' => 0,
};
if (! getopts('ho:r', $self->{'_opts'})
|| $self->{'_opts'}->{'h'}
|| @ARGV < 4) {
print STDERR "Usage: $0 [-h] [-o format] [-r] [--version] marc_xml_file field subfield value\n";
print STDERR "\t-h\t\tPrint help.\n";
print STDERR "\t-o format\tOutput MARC format. Possible formats are ascii, xml.\n";
print STDERR "\t-r\t\tUse value as Perl regexp.\n";
print STDERR "\t--version\tPrint version.\n";
print STDERR "\tmarc_xml_file\tMARC XML file.\n";
print STDERR "\tfield\t\tMARC field.\n";
print STDERR "\tsubfield\tMARC subfield.\n";
print STDERR "\tvalue\t\tMARC field/subfield value to filter.\n";
return 1;
}
$self->{'_marc_xml_file'} = shift @ARGV;
$self->{'_marc_field'} = shift @ARGV;
$self->{'_marc_subfield'} = shift @ARGV;
$self->{'_marc_value'} = decode_utf8(shift @ARGV);
# Check output format.
if (none { $self->{'_opts'}->{'o'} eq $_ } @OUTPUT_FORMATS) {
err "Output format '$self->{'_opts'}->{'o'}' doesn't supported.";
}
my $marc_file = MARC::File::XML->in($self->{'_marc_xml_file'});
my @ret;
my $num = 1;
my $previous_record;
while (1) {
my $record = eval {
$marc_file->next;
};
if ($EVAL_ERROR) {
print STDERR "Cannot process '$num' record. ".
(
defined $previous_record
? "Previous record is ".encode_utf8($previous_record->title)."\n"
: ''
);
print STDERR "Error: $EVAL_ERROR\n";
next;
}
if (! defined $record) {
last;
}
$previous_record = $record;
my @fields = $record->field($self->{'_marc_field'});
foreach my $field (@fields) {
my @subfield_values = $field->subfield($self->{'_marc_subfield'});
foreach my $subfield_value (@subfield_values) {
if (defined $subfield_value) {
my $match = 0;
if ($self->{'_opts'}->{'r'}) {
if ($subfield_value =~ m/$self->{'_marc_value'}/ms) {
$match = 1;
}
} else {
if ($subfield_value eq $self->{'_marc_value'}) {
$match = 1;
}
}
if ($match) {
push @ret, $record;
}
}
}
}
$num++;
}
# Print out.
$num = 0;
foreach my $ret (@ret) {
if (! $num) {
if ($self->{'_opts'}->{'o'} eq 'xml') {
print MARC::File::XML::header()."\n";
}
}
if ($self->{'_opts'}->{'o'} eq 'xml') {
print encode_utf8(MARC::File::XML::record($ret))."\n";
} elsif ($self->{'_opts'}->{'o'} eq 'ascii') {
print encode_utf8($ret->as_formatted)."\n";
}
$num++;
}
if ($num) {
if ($self->{'_opts'}->{'o'} eq 'xml') {
print MARC::File::XML::footer()."\n";
}
}
return 0;
}
1;
__END__
=pod
=encoding utf8
=head1 NAME
App::MARC::Filter - Base class for marc-count script.
=head1 SYNOPSIS
use App::MARC::Filter;
my $app = App::MARC::Filter->new;
my $exit_code = $app->run;
=head1 METHODS
=head2 C<new>
my $app = App::MARC::Filter->new;
Constructor.
Returns instance of object.
=head2 C<run>
my $exit_code = $app->run;
Run.
Returns 1 for error, 0 for success.
=head1 ERRORS
new():
From Class::Utils::set_params():
Unknown parameter '%s'.
run():
Output format '%s' doesn't supported.
=head1 EXAMPLE
use strict;
use warnings;
use App::MARC::Filter;
use IO::Barf qw(barf);
use File::Temp qw(tempfile);
use MIME::Base64;
# Content.
my $marc_xml_example = <<'END';
PD94bWwgdmVyc2lvbiA9ICIxLjAiIGVuY29kaW5nID0gIlVURi04Ij8+CiAgPGNvbGxlY3Rpb24g
eG1sbnM9Imh0dHA6Ly93d3cubG9jLmdvdi9NQVJDMjEvc2xpbSIKeG1sbnM6eHNpPSJodHRwOi8v
d3d3Lncz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ZGF0YWZpZWxkPgogIDxkYXRhZmllbGQgdGFnPSI1MDAi
IGluZDE9IiAiIGluZDI9IiAiPgogICAgPHN1YmZpZWxkIGNvZGU9ImEiPlDFmWVobC4gbGl0PC9z
dWJmaWVsZD4KICA8L2RhdGFmaWVsZD4KICA8ZGF0YWZpZWxkIHRhZz0iNTAwIiBpbmQxPSIgIiBp
bmQyPSIgIj4KICAgIDxzdWJmaWVsZCBjb2RlPSJhIj5Sb3ptbi48L3N1YmZpZWxkPgogIDwvZGF0
YWZpZWxkPgogIDxkYXRhZmllbGQgdGFnPSI1MDAiIGluZDE9IiAiIGluZDI9IiAiPgogICAgPHN1
YmZpZWxkIGNvZGU9ImEiPlBvem4uPC9zdWJmaWVsZD4KICA8L2RhdGFmaWVsZD4KICA8ZGF0YWZp
ZWxkIHRhZz0iODMwIiBpbmQxPSIgIiBpbmQyPSIwIj4KICAgIDxzdWJmaWVsZCBjb2RlPSJhIj5Q
dWJsaWthY2UgU0lWTzwvc3ViZmllbGQ+CiAgPC9kYXRhZmllbGQ+CiAgPGRhdGFmaWVsZCB0YWc9
Ijk5OCIgaW5kMT0iICIgaW5kMj0iICI+CiAgICA8c3ViZmllbGQgY29kZT0iYSI+aHR0cDovL2Fs
ZXBoLm5rcC5jei9GLz9mdW5jPWRpcmVjdCZhbXA7ZG9jX251bWJlcj0wMDAwMDAwOTgmYW1wO2xv
Y2FsX2Jhc2U9Q05CPC9zdWJmaWVsZD4KICA8L2RhdGFmaWVsZD4KPC9yZWNvcmQ+Cgo8L2NvbGxl
Y3Rpb24+Cg==
END
my ($temp_file, $temp_file_fh) = tempfile();
barf($temp_file_fh, decode_base64($marc_xml_example));
# Arguments.
@ARGV = (
$temp_file,
'015',
'a',
'cnb000000096',
);
# Run.
exit App::MARC::Filter->new->run;
# Output:
# <?xml version="1.0" encoding="UTF-8"?>
# <collection
# xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
# xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
# xmlns="http://www.loc.gov/MARC21/slim">
#
# <record>
# <leader> nam a22 4500</leader>
# <controlfield tag="001">ck8300078</controlfield>
# <controlfield tag="003">CZ PrNK</controlfield>
# <controlfield tag="005">20210309121951.0</controlfield>
# <controlfield tag="007">tu</controlfield>
# <controlfield tag="008">830304s1982 xr a u0|0 | cze</controlfield>
# <datafield tag="015" ind1=" " ind2=" ">
# <subfield code="a">cnb000000096</subfield>
# </datafield>
# <datafield tag="020" ind1=" " ind2=" ">
# <subfield code="q">(Brož.) :</subfield>
# <subfield code="c">9 Kčs</subfield>
# </datafield>
# <datafield tag="035" ind1=" " ind2=" ">
# <subfield code="a">(OCoLC)39560664</subfield>
# </datafield>
# <datafield tag="040" ind1=" " ind2=" ">
# <subfield code="a">ABA001</subfield>
# <subfield code="b">cze</subfield>
# <subfield code="d">ABA001</subfield>
# </datafield>
# <datafield tag="080" ind1=" " ind2=" ">
# <subfield code="a">352/353</subfield>
# <subfield code="2">undef</subfield>
# </datafield>
# <datafield tag="080" ind1=" " ind2=" ">
# <subfield code="a">338.46</subfield>
# <subfield code="2">undef</subfield>
# </datafield>
# <datafield tag="100" ind1="1" ind2=" ">
# <subfield code="a">Gabriel, Vladislav</subfield>
# <subfield code="7">mzk2014852723</subfield>
# <subfield code="4">aut</subfield>
# </datafield>
# <datafield tag="245" ind1="1" ind2="0">
# <subfield code="a">Služby v systému národních výborů :</subfield>
# <subfield code="b">vybrané kapitoly : určeno pro posl. fak. obchodní, obor Ekonomika služeb a cestovního ruchu /</subfield>
# <subfield code="c">Vladislav Gabriel, Ladislav Zapadlo</subfield>
# </datafield>
# <datafield tag="250" ind1=" " ind2=" ">
# <subfield code="a">1. vyd.</subfield>
# </datafield>
# <datafield tag="260" ind1=" " ind2=" ">
# <subfield code="a">Praha :</subfield>
# <subfield code="b">SPN,</subfield>
# <subfield code="c">1982</subfield>
# <subfield code="e">(Příbram :</subfield>
# <subfield code="f">TZ 66)</subfield>
# </datafield>
# <datafield tag="300" ind1=" " ind2=" ">
# <subfield code="a">192 s. :</subfield>
# <subfield code="b">schémata ;</subfield>
# <subfield code="c">30 cm</subfield>
# </datafield>
# <datafield tag="500" ind1=" " ind2=" ">
# <subfield code="a">Rozmn.</subfield>
# </datafield>
# <datafield tag="500" ind1=" " ind2=" ">
# <subfield code="a">300 výt.</subfield>
# </datafield>
# <datafield tag="500" ind1=" " ind2=" ">
# <subfield code="a">Kap. 4. naps. Růžena Dudová, kap. 8. je sest. z příspěvků růz. autorů</subfield>
# </datafield>
# <datafield tag="550" ind1=" " ind2=" ">
# <subfield code="a">Vydavatel: VŠE v Praze</subfield>
# </datafield>
# <datafield tag="655" ind1=" " ind2="7">
# <subfield code="a">učebnice vysokých škol</subfield>
# <subfield code="7">fd133772</subfield>
# <subfield code="2">czenas</subfield>
# </datafield>
# <datafield tag="700" ind1="1" ind2=" ">
# <subfield code="a">Zapadlo, Ladislav</subfield>
# <subfield code="4">aut</subfield>
# </datafield>
# <datafield tag="710" ind1="2" ind2=" ">
# <subfield code="a">Vysoká škola ekonomická v Praze</subfield>
# <subfield code="7">kn20010709403</subfield>
# </datafield>
# <datafield tag="998" ind1=" " ind2=" ">
# <subfield code="a">http://aleph.nkp.cz/F/?func=direct&doc_number=000000096&local_base=CNB</subfield>
# </datafield>
# </record>
#
# </collection>
=head1 DEPENDENCIES
L<Class::Utils>,
L<English>,
L<Error::Pure>,
L<Getopt::Std>,
L<List::MoreUtils>,
L<MARC::File::XML>,
L<Readonly>,
L<Unicode::UTF8>.
=head1 REPOSITORY
L<https://github.com/michal-josef-spacek/App-MARC-Filter>
=head1 AUTHOR
Michal Josef Špaček L<mailto:[email protected]>
L<http://skim.cz>
=head1 LICENSE AND COPYRIGHT
© 2022-2024 Michal Josef Špaček
BSD 2-Clause License
=head1 VERSION
0.04
=cut