/[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 113 by dpavlin, Wed Nov 23 00:14:05 2005 UTC revision 210 by dpavlin, Mon Dec 5 17:47:04 2005 UTC
# Line 9  use lib './lib'; Line 9  use lib './lib';
9    
10  use WebPAC::Lookup;  use WebPAC::Lookup;
11  use WebPAC::Input::ISIS;  use WebPAC::Input::ISIS;
12  use WebPAC::DB;  use WebPAC::Store 0.03;
13  use WebPAC::Normalize::XML;  use WebPAC::Normalize::XML;
14  use WebPAC::Output::TT;  use WebPAC::Output::TT;
15  use WebPAC::Output::Estraier;  use WebPAC::Output::Estraier 0.02;
16    use YAML qw/LoadFile/;
17    use LWP::Simple;
18    
19  my $limit = shift @ARGV;  my $limit = shift @ARGV;
20    
21  my $abs_path = abs_path($0);  my $config = LoadFile('conf/config.yml');
 $abs_path =~ s#/[^/]*$#/#;  
22    
23  my $isis_file = '/data/isis_data/ps/LIBRI/LIBRI';  print "config = ",Dumper($config);
24    
25  my $lookup = new WebPAC::Lookup(  die "no databases in config file!\n" unless ($config->{databases});
         lookup_file => "$abs_path/conf/lookup/isis.pm",  
 );  
26    
27  my $isis = new WebPAC::Input::ISIS(  while (my ($database, $db_config) = each %{ $config->{databases} }) {
         code_page => 'ISO-8859-2',      # application encoding  
         limit_mfn => $limit,  
 );  
28    
29  my $maxmfn = $isis->open(          my $type = lc($db_config->{input}->{type});
         filename => $isis_file,  
         code_page => '852',             # database encoding  
 );  
30    
31  my $path = './db/';          die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis');
32    
33  my $db = new WebPAC::DB(          my $abs_path = abs_path($0);
34          path => $path,          $abs_path =~ s#/[^/]*$#/#;
 );  
35    
36  my $n = new WebPAC::Normalize::XML(          my $lookup = new WebPAC::Lookup(
37  #       filter => { 'foo' => sub { shift } },                  lookup_file => $db_config->{input}->{lookup},
38          db => $db,          );
39          lookup_regex => $lookup->regex,  
40          lookup => $lookup,          my $db_path = $config->{webpac}->{db_path} . '/' . $database;
 );  
41    
 $n->open(  
         tag => 'isis',  
         xml_file => "$abs_path/conf/normalize/isis_ffzg.xml",  
 );  
42    
43  my $out = new WebPAC::Output::TT(          my $log = $lookup->_get_logger;
44          include_path => "$abs_path/conf/output/tt",          $log->info("working on $database in $db_path");
         filters => { foo => sub { shift } },  
 );  
45    
46  my $est = new WebPAC::Output::Estraier(          my $isis = new WebPAC::Input::ISIS(
47          url => 'http://localhost:1978/node/webpac2',                  code_page => $config->{webpac}->{webpac_encoding},
48          user => 'admin',                  limit_mfn => $db_config->{input}->{limit},
49          passwd => 'admin',          );
         database => 'ps',  
 );  
50    
51  my $total_rows = 0;          my $maxmfn = $isis->open(
52                    filename => $db_config->{input}->{path},
53                    code_page => $db_config->{input}->{encoding},   # database encoding
54            );
55    
56  for ( 0 ... $isis->size ) {          my $path = './db/';
57    
58          my $row = $isis->fetch || next;          my $db = new WebPAC::Store(
59                    path => $db_path,
60            );
61    
62            my $n = new WebPAC::Normalize::XML(
63            #       filter => { 'foo' => sub { shift } },
64                    db => $db,
65                    lookup_regex => $lookup->regex,
66                    lookup => $lookup,
67            );
68    
69          my $mfn = $row->{'000'}->[0] || die "can't find MFN";          $n->open(
70                    tag => $db_config->{normalize}->{tag},
71                    xml_file => $db_config->{normalize}->{path},
72            );
73    
74          my $ds = $n->data_structure($row);          my $out = new WebPAC::Output::TT(
75                    include_path => $config->{webpac}->{template_path},
76                    filters => { foo => sub { shift } },
77            );
78    
79  #       print STDERR Dumper($row, $ds);          my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");
80            $est_config->{database} = $database;
81    
82  #       my $html = $out->apply(          $log->info("using HyperEstraier URL $est_config->{url}");
 #               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;  
83    
84          $est->add(          my $est = new WebPAC::Output::Estraier(
85                  id => $mfn,                  %{ $est_config },
                 ds => $ds,  
                 type => 'search',  
86          );          );
87    
88          $total_rows++;          my $total_rows = 0;
89    
90            for ( 0 ... $isis->size ) {
91    
92                    my $row = $isis->fetch || next;
93    
94                    my $mfn = $row->{'000'}->[0] || die "can't find MFN";
95    
96                    my $ds = $n->data_structure($row);
97    
98            #       print STDERR Dumper($row, $ds);
99    
100            #       my $html = $out->apply(
101            #               template => 'html_ffzg.tt',
102            #               data => $ds,
103            #       );
104            #
105            #       # create test output
106            #
107            #       my $file = sprintf('out/%02d.html', $mfn );
108            #       open(my $fh, '>', $file) or die "can't open $file: $!";
109            #       print $fh $html;
110            #       close($fh);
111            #
112            #       $html =~ s#\s*[\n\r]+\s*##gs;
113            #
114            #       print STDERR $html;
115    
116                    $est->add(
117                            id => $mfn,
118                            ds => $ds,
119                            type => $config->{hyperestraier}->{type},
120                    );
121    
122                    $total_rows++;
123    
124  };          };
125    
126  my $log = $lookup->_get_logger;          $log->info("$total_rows records indexed");
127    }
128    
 $log->info("$total_rows records indexed");  

Legend:
Removed from v.113  
changed lines
  Added in v.210

  ViewVC Help
Powered by ViewVC 1.1.26