--- trunk/run.pl 2005/12/05 17:46:57 209 +++ trunk/run.pl 2005/12/05 17:47:04 210 @@ -12,8 +12,9 @@ use WebPAC::Store 0.03; use WebPAC::Normalize::XML; use WebPAC::Output::TT; -use WebPAC::Output::Estraier; +use WebPAC::Output::Estraier 0.02; use YAML qw/LoadFile/; +use LWP::Simple; my $limit = shift @ARGV; @@ -21,94 +22,107 @@ print "config = ",Dumper($config); -my $type = lc($config->{input}->{type}); +die "no databases in config file!\n" unless ($config->{databases}); -die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis'); +while (my ($database, $db_config) = each %{ $config->{databases} }) { -my $abs_path = abs_path($0); -$abs_path =~ s#/[^/]*$#/#; + my $type = lc($db_config->{input}->{type}); -my $lookup = new WebPAC::Lookup( - lookup_file => $config->{input}->{lookup}, -); + die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis'); + my $abs_path = abs_path($0); + $abs_path =~ s#/[^/]*$#/#; + my $lookup = new WebPAC::Lookup( + lookup_file => $db_config->{input}->{lookup}, + ); -my $isis = new WebPAC::Input::ISIS( - code_page => $config->{webpac}->{webpac_encoding}, - limit_mfn => $config->{input}->{limit}, -); + my $db_path = $config->{webpac}->{db_path} . '/' . $database; -my $maxmfn = $isis->open( - filename => $config->{input}->{path}, - code_page => $config->{input}->{encoding}, # database encoding -); -my $path = './db/'; + my $log = $lookup->_get_logger; + $log->info("working on $database in $db_path"); -my $db = new WebPAC::Store( - path => $config->{webpac}->{db_path}, -); + my $isis = new WebPAC::Input::ISIS( + code_page => $config->{webpac}->{webpac_encoding}, + limit_mfn => $db_config->{input}->{limit}, + ); -my $n = new WebPAC::Normalize::XML( -# filter => { 'foo' => sub { shift } }, - db => $db, - lookup_regex => $lookup->regex, - lookup => $lookup, -); + my $maxmfn = $isis->open( + filename => $db_config->{input}->{path}, + code_page => $db_config->{input}->{encoding}, # database encoding + ); -$n->open( - tag => $config->{normalize}->{tag}, - xml_file => $config->{normalize}->{path}, -); + my $path = './db/'; -my $out = new WebPAC::Output::TT( - include_path => $config->{webpac}->{template_path}, - filters => { foo => sub { shift } }, -); + my $db = new WebPAC::Store( + path => $db_path, + ); -my $est = new WebPAC::Output::Estraier( - %{ $config->{hyperestraier} } -); + my $n = new WebPAC::Normalize::XML( + # filter => { 'foo' => sub { shift } }, + db => $db, + lookup_regex => $lookup->regex, + lookup => $lookup, + ); -my $total_rows = 0; + $n->open( + tag => $db_config->{normalize}->{tag}, + xml_file => $db_config->{normalize}->{path}, + ); -for ( 0 ... $isis->size ) { + my $out = new WebPAC::Output::TT( + include_path => $config->{webpac}->{template_path}, + filters => { foo => sub { shift } }, + ); - my $row = $isis->fetch || next; + my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration"); + $est_config->{database} = $database; - my $mfn = $row->{'000'}->[0] || die "can't find MFN"; + $log->info("using HyperEstraier URL $est_config->{url}"); - my $ds = $n->data_structure($row); + my $est = new WebPAC::Output::Estraier( + %{ $est_config }, + ); -# print STDERR Dumper($row, $ds); + my $total_rows = 0; -# my $html = $out->apply( -# template => 'html_ffzg.tt', -# data => $ds, -# ); -# -# # create test output -# -# my $file = sprintf('out/%02d.html', $mfn ); -# open(my $fh, '>', $file) or die "can't open $file: $!"; -# print $fh $html; -# close($fh); -# -# $html =~ s#\s*[\n\r]+\s*##gs; -# -# print STDERR $html; + for ( 0 ... $isis->size ) { - $est->add( - id => $mfn, - ds => $ds, - type => $config->{hyperestraier}->{type}, - ); + my $row = $isis->fetch || next; + + my $mfn = $row->{'000'}->[0] || die "can't find MFN"; + + my $ds = $n->data_structure($row); + + # print STDERR Dumper($row, $ds); + + # my $html = $out->apply( + # template => 'html_ffzg.tt', + # data => $ds, + # ); + # + # # create test output + # + # my $file = sprintf('out/%02d.html', $mfn ); + # open(my $fh, '>', $file) or die "can't open $file: $!"; + # print $fh $html; + # close($fh); + # + # $html =~ s#\s*[\n\r]+\s*##gs; + # + # print STDERR $html; + + $est->add( + id => $mfn, + ds => $ds, + type => $config->{hyperestraier}->{type}, + ); - $total_rows++; + $total_rows++; -}; + }; -my $log = $lookup->_get_logger; + $log->info("$total_rows records indexed"); +} -$log->info("$total_rows records indexed");