/[webpac]/trunk2/all2all.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 /trunk2/all2all.pl

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

revision 372 by dpavlin, Sat Jun 19 18:16:20 2004 UTC revision 411 by dpavlin, Sun Sep 5 22:22:37 2004 UTC
# Line 9  all2all.pl - basic script for all WebPAC Line 9  all2all.pl - basic script for all WebPAC
9  use strict;  use strict;
10  use Data::Dumper;  use Data::Dumper;
11  use Carp;  use Carp;
 use Log::Log4perl qw(get_logger :levels);  
12    
13  use lib './lib';  use lib './lib';
14  use WebPAC;  use WebPAC;
15    use WebPAC::jsFind;
16  Log::Log4perl->init('log.conf');  use WebPAC::Index;
 my $log = get_logger();  
17    
18  my $webpac = new WebPAC(  my $webpac = new WebPAC(
19          code_page => 'ISO-8859-2',          code_page => 'ISO-8859-2',
# Line 23  my $webpac = new WebPAC( Line 21  my $webpac = new WebPAC(
21  #       debug => 1,  #       debug => 1,
22  ) || die;  ) || die;
23    
24    my $log = $webpac->_get_logger();
25    
26    my $index = new WebPAC::jsFind(
27            index_path => './out/index',
28            keys => 80,
29    ) || die;
30    
31    my $thes;
32    
33  $|=1;  $|=1;
34    
35  my $maxmfn = $webpac->open_isis(  my $maxmfn = $webpac->open_isis(
# Line 33  my $maxmfn = $webpac->open_isis( Line 40  my $maxmfn = $webpac->open_isis(
40  #       { 'eval '=> '"v901^a" eq "Mikrotezaurus"', 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },  #       { 'eval '=> '"v901^a" eq "Mikrotezaurus"', 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },
41  #       { 'eval' => '"v901^a" eq "Deskriptor"', 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },  #       { 'eval' => '"v901^a" eq "Deskriptor"', 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },
42          { 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },          { 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },
43            { 'key' => '900_mfn:v900', 'val' => 'v000' },
44          ],          ],
45  );  );
46    
# Line 44  while (my $rec = $webpac->fetch_rec) { Line 52  while (my $rec = $webpac->fetch_rec) {
52    
53          my @ds = $webpac->data_structure($rec);          my @ds = $webpac->data_structure($rec);
54    
55          if ($log->is_debug) {          if (0 && $log->is_debug) {
56                  $log->debug("rec = ",Dumper($rec));                  $log->debug("rec = ",Dumper($rec));
57                  $log->debug("ds = ",Dumper(\@ds));                  $log->debug("ds = ",Dumper(\@ds));
58          }          }
59    
60          print $webpac->output(          next if (! @ds);
61                  template => 'text.tt',  
62                  data => \@ds,          my $filename = $webpac->{'current_filename'};
63          ) if (@ds);  
64            if ($filename) {
65                    $webpac->output_file(
66                            file => $filename,
67                            template => 'html.tt',
68                            data => \@ds,
69                            headline => $webpac->{'headline'},
70                    );
71            } else {
72                    print $webpac->output(
73                            template => 'text.tt',
74                            data => \@ds,
75                            headline => $webpac->{'headline'},
76                    );
77            }
78    
79            my $headline = $webpac->{'headline'};
80    
81            my $f = $filename;
82            $f =~ s!out/!!;
83    
84            # save into index
85            foreach my $ds (@ds) {
86                    next if (! $ds->{'swish'});
87    
88                    $index->insert(
89                            index_name => $ds->{'tag'},
90                            path => $f,
91                            headline => $headline,
92                            words => join(" ",@{$ds->{'swish'}})
93                    );
94            }
95    
96            # save into sorted index (thesaurus)
97            foreach my $ds (@ds) {
98                    next if (! $ds->{'index'});
99    
100                    $thes->{$ds->{'tag'}} ||= new WebPAC::Index;
101    
102                    $thes->{$ds->{'tag'}}->insert(
103                            path => $f,
104                            headline => $headline,
105                    );
106            }
107    
108    #       print Dumper(\@ds);
109    
110    }
111    
112    foreach my $t (keys %{$thes}) {
113    
114            my @e = $thes->{$t}->elements;
115            if (! @e) {
116                    $log->logwarn("no elements in sorted index $t?");
117                    next;
118            }
119    
120            $log->debug("saving sorted index $t [".scalar(@e)." elements]");
121    
122            $webpac->output_file(
123                    file => "./out/thes_$t.html",
124                    template => 'index.tt',
125                    data => \@e,
126                    index_name => $t,
127            );
128  }  }
129    
130  if ($log->is_debug) {  if (0 && $log->is_debug) {
131          $log->debug("lookup hash: ",Dumper($webpac->{'lookup'}));          $log->debug("lookup hash: ",Dumper($webpac->{'lookup'}));
132          $log->debug("data hash: ",Dumper($webpac->{'data'}));          $log->debug("data hash: ",Dumper($webpac->{'data'}));
133            foreach my $t (keys %{$thes}) {
134                    $log->debug("thesaurus $t hash: ",Dumper($thes->{$t}));
135            }
136  }  }
137    
138    $index->close;
139    

Legend:
Removed from v.372  
changed lines
  Added in v.411

  ViewVC Help
Powered by ViewVC 1.1.26