/[webpac2]/trunk/run.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/run.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 736 by dpavlin, Thu Oct 5 12:57:51 2006 UTC revision 762 by dpavlin, Wed Oct 25 18:54:45 2006 UTC
# Line 7  use File::Temp qw/tempdir/; Line 7  use File::Temp qw/tempdir/;
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.08;
11  use WebPAC::Input 0.13;  use WebPAC::Input 0.14;
12  use WebPAC::Store 0.11;  use WebPAC::Store 0.14;
13  use WebPAC::Normalize 0.22;  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;
# Line 67  and subfield usage for each input Line 67  and subfield usage for each input
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
# Line 110  my $debug = 0; Line 102  my $debug = 0;
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;
# Line 129  GetOptions( Line 120  GetOptions(
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,
# Line 171  if ($stats) { Line 160  if ($stats) {
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 );
# Line 212  while (my ($database, $db_config) = each Line 198  while (my ($database, $db_config) = each
198          }          }
199    
200          my $indexer;          my $indexer;
201          if ($use_indexer) {          if ($use_indexer && $parser->have_rules( 'search', $database )) {
202    
203                  my $cfg_name = $use_indexer;                  my $cfg_name = $use_indexer;
204                  $cfg_name =~ s/\-.*$//;                  $cfg_name =~ s/\-.*$//;
# Line 364  while (my ($database, $db_config) = each Line 350  while (my ($database, $db_config) = each
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    
                                 $store->save_row(  
                                         database => $database,  
                                         input => $input_name,  
                                         id => $mfn,  
                                         row => $rec,  
                                 );  
   
353                                  WebPAC::Normalize::data_structure(                                  WebPAC::Normalize::data_structure(
354                                          row => $rec,                                          row => $rec,
355                                          rules => $rules,                                          rules => $rules,
# Line 394  while (my ($database, $db_config) = each Line 373  while (my ($database, $db_config) = each
373                          lookup_coderef => $lookup_coderef,                          lookup_coderef => $lookup_coderef,
374                          lookup => $lookup_jar,                          lookup => $lookup_jar,
375                          %{ $input },                          %{ $input },
376                            load_row => sub {
377                                    my $a = shift;
378                                    return $store->load_row(
379                                            database => $database,
380                                            input => $input_name,
381                                            id => $a->{id},
382                                    );
383                            },
384                            save_row => sub {
385                                    my $a = shift;
386                                    return $store->save_row(
387                                            database => $database,
388                                            input => $input_name,
389                                            id => $a->{id},
390                                            row => $a->{row},
391                                    );
392                            },
393    
394                  );                  );
395    
396                  my $lookup_data = WebPAC::Normalize::_get_lookup();                  my $lookup_data = WebPAC::Normalize::_get_lookup();
# Line 422  while (my ($database, $db_config) = each Line 419  while (my ($database, $db_config) = each
419                  }                  }
420    
421                  my $marc;                  my $marc;
422                  if ($marc_normalize) {                  if ($parser->have_rules( 'marc', $database, $input_name )) {
423                          $marc = new WebPAC::Output::MARC(                          $marc = new WebPAC::Output::MARC(
424                                  path => $marc_output || "out/marc/${database}-${input_name}.marc",                                  path => "out/marc/${database}-${input_name}.marc",
425                                  lint => $marc_lint,                                  lint => $marc_lint,
426                                  dump => $marc_dump,                                  dump => $marc_dump,
427                          );                          );
# Line 450  while (my ($database, $db_config) = each Line 447  while (my ($database, $db_config) = each
447                          foreach my $db (keys %$depends) {                          foreach my $db (keys %$depends) {
448                                  foreach my $i (keys %{$depends->{$db}}) {                                  foreach my $i (keys %{$depends->{$db}}) {
449                                          foreach my $k (keys %{$depends->{$db}->{$i}}) {                                          foreach my $k (keys %{$depends->{$db}->{$i}}) {
450                                                    my $t = time();
451                                                  $log->debug("loading lookup $db/$i");                                                  $log->debug("loading lookup $db/$i");
452                                                  $lookup_hash->{$db}->{$i}->{$k} = $store->load_lookup(                                                  $lookup_hash->{$db}->{$i}->{$k} = $store->load_lookup(
453                                                          database => $db,                                                          database => $db,
454                                                          input => $i,                                                          input => $i,
455                                                          key => $k,                                                          key => $k,
456                                                  );                                                  );
457                                                    $log->debug(sprintf("lookup $db/$i took %.2fs", time() - $t));
458                                          }                                          }
459                                  }                                  }
460                          }                          }
461    
462                          $log->debug("lookup_hash = ", dump( $lookup_hash ));                          $log->debug("lookup_hash = ", sub { dump( $lookup_hash ) });
463                  }                  }
464    
465    
# Line 501  while (my ($database, $db_config) = each Line 500  while (my ($database, $db_config) = each
500                                  },                                  },
501                          );                          );
502    
503                          $log->debug("ds = ",dump($ds));                          $log->debug("ds = ",dump($ds)) if ($ds);
504    
505                          $store->save_ds(                          $store->save_ds(
506                                  database => $database,                                  database => $database,

Legend:
Removed from v.736  
changed lines
  Added in v.762

  ViewVC Help
Powered by ViewVC 1.1.26