7 |
use lib './lib'; |
use lib './lib'; |
8 |
|
|
9 |
use WebPAC::Common 0.02; |
use WebPAC::Common 0.02; |
10 |
use WebPAC::Parser 0.04; |
use WebPAC::Parser 0.07; |
11 |
use WebPAC::Input 0.13; |
use WebPAC::Input 0.13; |
12 |
use WebPAC::Store 0.11; |
use WebPAC::Store 0.11; |
13 |
use WebPAC::Normalize 0.21; |
use WebPAC::Normalize 0.22; |
14 |
use WebPAC::Output::TT; |
use WebPAC::Output::TT; |
15 |
use WebPAC::Validate 0.06; |
use WebPAC::Validate 0.06; |
16 |
use WebPAC::Output::MARC; |
use WebPAC::Output::MARC; |
67 |
|
|
68 |
turn on extra validation of imput records, see L<WebPAC::Validation> |
turn on extra validation of imput records, see L<WebPAC::Validation> |
69 |
|
|
|
=item --marc-normalize conf/normalize/mapping.pl |
|
|
|
|
|
This option specifies normalisation file for MARC creation |
|
|
|
|
|
=item --marc-output out/marc/test.marc |
|
|
|
|
|
Optional path to output file |
|
|
|
|
70 |
=item --marc-lint |
=item --marc-lint |
71 |
|
|
72 |
By default turned on if C<--marc-normalize> is used. You can disable lint |
By default turned on if normalisation file has C<marc*> directives. You can disable lint |
73 |
messages with C<--no-marc-lint>. |
messages with C<--no-marc-lint>. |
74 |
|
|
75 |
=item --marc-dump |
=item --marc-dump |
102 |
my $only_filter; |
my $only_filter; |
103 |
my $stats = 0; |
my $stats = 0; |
104 |
my $validate_path; |
my $validate_path; |
|
my ($marc_normalize, $marc_output); |
|
105 |
my $marc_lint = 1; |
my $marc_lint = 1; |
106 |
my $marc_dump = 0; |
my $marc_dump = 0; |
107 |
my $parallel = 0; |
my $parallel = 0; |
120 |
"debug+" => \$debug, |
"debug+" => \$debug, |
121 |
"stats" => \$stats, |
"stats" => \$stats, |
122 |
"validate=s" => \$validate_path, |
"validate=s" => \$validate_path, |
|
"marc-normalize=s" => \$marc_normalize, |
|
|
"marc-output=s" => \$marc_output, |
|
123 |
"marc-lint!" => \$marc_lint, |
"marc-lint!" => \$marc_lint, |
124 |
"marc-dump!" => \$marc_dump, |
"marc-dump!" => \$marc_dump, |
125 |
"parallel=i" => \$parallel, |
"parallel=i" => \$parallel, |
160 |
$log->info("using $use_indexer indexing engine..."); |
$log->info("using $use_indexer indexing engine..."); |
161 |
} |
} |
162 |
|
|
|
# disable indexing when creating marc |
|
|
$use_indexer = undef if ($marc_normalize); |
|
|
|
|
163 |
# parse normalize files and create source files for lookup and normalization |
# parse normalize files and create source files for lookup and normalization |
164 |
|
|
165 |
my $parser = new WebPAC::Parser( config => $config ); |
my $parser = new WebPAC::Parser( config => $config ); |
350 |
my $rec = shift || die "need rec!"; |
my $rec = shift || die "need rec!"; |
351 |
my $mfn = $rec->{'000'}->[0] || die "need mfn in 000"; |
my $mfn = $rec->{'000'}->[0] || die "need mfn in 000"; |
352 |
|
|
353 |
|
$store->save_row( |
354 |
|
database => $database, |
355 |
|
input => $input_name, |
356 |
|
id => $mfn, |
357 |
|
row => $rec, |
358 |
|
); |
359 |
|
|
360 |
WebPAC::Normalize::data_structure( |
WebPAC::Normalize::data_structure( |
361 |
row => $rec, |
row => $rec, |
362 |
rules => "_debug(2); $rules _debug(0)", |
rules => $rules, |
363 |
config => create_ds_config( $db_config, $database, $input, $mfn ), |
config => create_ds_config( $db_config, $database, $input, $mfn ), |
364 |
); |
); |
365 |
|
|
366 |
warn "current lookup: ", dump(WebPAC::Normalize::_get_lookup()); |
#warn "current lookup: ", dump(WebPAC::Normalize::_get_lookup()); |
367 |
}; |
}; |
368 |
|
|
369 |
WebPAC::Normalize::_set_lookup( undef ); |
WebPAC::Normalize::_set_lookup( undef ); |
408 |
} |
} |
409 |
|
|
410 |
my $marc; |
my $marc; |
411 |
if ($marc_normalize) { |
if ($parser->generate_marc( $database, $input_name )) { |
412 |
$marc = new WebPAC::Output::MARC( |
$marc = new WebPAC::Output::MARC( |
413 |
path => $marc_output || "out/marc/${database}-${input_name}.marc", |
path => "out/marc/${database}-${input_name}.marc", |
414 |
lint => $marc_lint, |
lint => $marc_lint, |
415 |
dump => $marc_dump, |
dump => $marc_dump, |
416 |
); |
); |
477 |
lookup => $lookup_hash, |
lookup => $lookup_hash, |
478 |
config => create_ds_config( $db_config, $database, $input, $mfn ), |
config => create_ds_config( $db_config, $database, $input, $mfn ), |
479 |
marc_encoding => 'utf-8', |
marc_encoding => 'utf-8', |
480 |
load_ds_coderef => sub { |
load_row_coderef => sub { |
481 |
my ($database,$input,$mfn) = @_; |
my ($database,$input,$mfn) = @_; |
482 |
return $store->load_ds( |
return $store->load_row( |
483 |
database => $database, |
database => $database, |
484 |
input => $input, |
input => $input, |
485 |
id => $mfn, |
id => $mfn, |
487 |
}, |
}, |
488 |
); |
); |
489 |
|
|
490 |
|
$log->debug("ds = ",dump($ds)) if ($ds); |
491 |
|
|
492 |
$store->save_ds( |
$store->save_ds( |
493 |
database => $database, |
database => $database, |
494 |
input => $input_name, |
input => $input_name, |