/[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

Contents of /trunk/run.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 210 - (show annotations)
Mon Dec 5 17:47:04 2005 UTC (18 years, 4 months ago) by dpavlin
File MIME type: text/plain
File size: 2713 byte(s)
 r11519@llin:  dpavlin | 2005-12-05 00:20:06 +0100
 partial changes to support multiple databases

1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use Cwd qw/abs_path/;
6 use File::Temp qw/tempdir/;
7 use Data::Dumper;
8 use lib './lib';
9
10 use WebPAC::Lookup;
11 use WebPAC::Input::ISIS;
12 use WebPAC::Store 0.03;
13 use WebPAC::Normalize::XML;
14 use WebPAC::Output::TT;
15 use WebPAC::Output::Estraier 0.02;
16 use YAML qw/LoadFile/;
17 use LWP::Simple;
18
19 my $limit = shift @ARGV;
20
21 my $config = LoadFile('conf/config.yml');
22
23 print "config = ",Dumper($config);
24
25 die "no databases in config file!\n" unless ($config->{databases});
26
27 while (my ($database, $db_config) = each %{ $config->{databases} }) {
28
29 my $type = lc($db_config->{input}->{type});
30
31 die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis');
32
33 my $abs_path = abs_path($0);
34 $abs_path =~ s#/[^/]*$#/#;
35
36 my $lookup = new WebPAC::Lookup(
37 lookup_file => $db_config->{input}->{lookup},
38 );
39
40 my $db_path = $config->{webpac}->{db_path} . '/' . $database;
41
42
43 my $log = $lookup->_get_logger;
44 $log->info("working on $database in $db_path");
45
46 my $isis = new WebPAC::Input::ISIS(
47 code_page => $config->{webpac}->{webpac_encoding},
48 limit_mfn => $db_config->{input}->{limit},
49 );
50
51 my $maxmfn = $isis->open(
52 filename => $db_config->{input}->{path},
53 code_page => $db_config->{input}->{encoding}, # database encoding
54 );
55
56 my $path = './db/';
57
58 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 $n->open(
70 tag => $db_config->{normalize}->{tag},
71 xml_file => $db_config->{normalize}->{path},
72 );
73
74 my $out = new WebPAC::Output::TT(
75 include_path => $config->{webpac}->{template_path},
76 filters => { foo => sub { shift } },
77 );
78
79 my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");
80 $est_config->{database} = $database;
81
82 $log->info("using HyperEstraier URL $est_config->{url}");
83
84 my $est = new WebPAC::Output::Estraier(
85 %{ $est_config },
86 );
87
88 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 $log->info("$total_rows records indexed");
127 }
128

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26