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

Annotation of /trunk/run.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 214 - (hide annotations)
Mon Dec 5 17:47:29 2005 UTC (18 years, 4 months ago) by dpavlin
File MIME type: text/plain
File size: 2508 byte(s)
 r11527@llin:  dpavlin | 2005-12-05 02:29:24 +0100
 unused var

1 dpavlin 74 #!/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 dpavlin 209 use WebPAC::Store 0.03;
13 dpavlin 74 use WebPAC::Normalize::XML;
14     use WebPAC::Output::TT;
15 dpavlin 210 use WebPAC::Output::Estraier 0.02;
16 dpavlin 141 use YAML qw/LoadFile/;
17 dpavlin 210 use LWP::Simple;
18 dpavlin 74
19 dpavlin 76 my $limit = shift @ARGV;
20    
21 dpavlin 141 my $config = LoadFile('conf/config.yml');
22    
23     print "config = ",Dumper($config);
24    
25 dpavlin 210 die "no databases in config file!\n" unless ($config->{databases});
26 dpavlin 141
27 dpavlin 213 my $total_rows = 0;
28    
29 dpavlin 210 while (my ($database, $db_config) = each %{ $config->{databases} }) {
30 dpavlin 141
31 dpavlin 210 my $type = lc($db_config->{input}->{type});
32 dpavlin 74
33 dpavlin 210 die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis');
34 dpavlin 74
35 dpavlin 210 my $abs_path = abs_path($0);
36     $abs_path =~ s#/[^/]*$#/#;
37 dpavlin 141
38 dpavlin 210 my $lookup = new WebPAC::Lookup(
39     lookup_file => $db_config->{input}->{lookup},
40     );
41 dpavlin 141
42 dpavlin 210 my $db_path = $config->{webpac}->{db_path} . '/' . $database;
43 dpavlin 74
44    
45 dpavlin 210 my $log = $lookup->_get_logger;
46     $log->info("working on $database in $db_path");
47 dpavlin 74
48 dpavlin 210 my $db = new WebPAC::Store(
49     path => $db_path,
50     );
51 dpavlin 74
52 dpavlin 210 my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");
53     $est_config->{database} = $database;
54 dpavlin 113
55 dpavlin 213 $log->info("using HyperEstraier URL $est_config->{masterurl}");
56 dpavlin 74
57 dpavlin 210 my $est = new WebPAC::Output::Estraier(
58     %{ $est_config },
59     );
60 dpavlin 74
61 dpavlin 213 #
62     # now, iterate through input formats
63     #
64 dpavlin 74
65 dpavlin 213 my @inputs;
66     if (ref($db_config->{input}) eq 'ARRAY') {
67     @inputs = @{ $db_config->{input} };
68     } else {
69     push @inputs, $db_config->{input};
70     }
71 dpavlin 74
72 dpavlin 213 foreach my $input (@inputs) {
73     $log->info("working on input $input->{path} [$input->{type}]");
74 dpavlin 74
75 dpavlin 213 my $isis = new WebPAC::Input::ISIS(
76     code_page => $config->{webpac}->{webpac_encoding},
77     limit_mfn => $input->{limit},
78     );
79 dpavlin 113
80 dpavlin 213 my $maxmfn = $isis->open(
81     filename => $input->{path},
82     code_page => $input->{encoding}, # database encoding
83     );
84 dpavlin 113
85 dpavlin 213 my $n = new WebPAC::Normalize::XML(
86     # filter => { 'foo' => sub { shift } },
87     db => $db,
88     lookup_regex => $lookup->regex,
89     lookup => $lookup,
90     );
91 dpavlin 113
92 dpavlin 213 $n->open(
93     tag => $input->{normalize}->{tag},
94     xml_file => $input->{normalize}->{path},
95 dpavlin 210 );
96    
97 dpavlin 213 for ( 0 ... $isis->size ) {
98 dpavlin 210
99 dpavlin 213 my $row = $isis->fetch || next;
100    
101     my $mfn = $row->{'000'}->[0] || die "can't find MFN";
102    
103     my $ds = $n->data_structure($row);
104    
105     $est->add(
106     id => $input->{name} . "#" . $mfn,
107     ds => $ds,
108     type => $config->{hyperestraier}->{type},
109     );
110    
111     $total_rows++;
112     }
113    
114 dpavlin 210 };
115    
116     $log->info("$total_rows records indexed");
117     }
118    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26