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

trunk/all2xml.pl revision 1 by dpavlin, Sun Nov 24 20:52:11 2002 UTC trunk2/all2all.pl revision 410 by dpavlin, Sun Sep 5 21:40:57 2004 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
3    =head1 NAME
4    
5    all2all.pl - basic script for all WebPAC needs
6    
7    =cut
8    
9  use strict;  use strict;
 use OpenIsis;  
 use Getopt::Std;  
10  use Data::Dumper;  use Data::Dumper;
11  use XML::Simple;  use Carp;
12    
13  my $config=XMLin();  use lib './lib';
14    use WebPAC;
15    use WebPAC::jsFind;
16    use WebPAC::Index;
17    
18  print Dumper($config);  my $webpac = new WebPAC(
19            code_page => 'ISO-8859-2',
20            limit_mfn => 100,
21    #       debug => 1,
22    ) || die;
23    
24  my %opts;  my $log = $webpac->_get_logger();
25    
26  getopts('d:m:q', \%opts);  my $index = new WebPAC::jsFind(
27            index_path => './out/index',
28            keys => 80,
29    ) || die;
30    
31  my $db_dir = $opts{d};  my $thes;
32    
33  die "usage: $0 -d [database_dir] -m [database1,database2] " if (! %opts);  $|=1;
34    
35  #--------------------------------------------------------------------  my $maxmfn = $webpac->open_isis(
36            filename => shift @ARGV || '/data/hidra/THS/THS',
37            lookup => [
38            { 'key' => 'd:v900', 'val' => 'v250^a' },
39    #       { 'eval' => '"v901^a" eq "Područje"', 'key' => 'pa:v561^4:v562^4:v461^1', 'val' => 'v900' },
40    #       { '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' },
42            { 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' },
43            { 'key' => '900_mfn:v900', 'val' => 'v000' },
44            ],
45    );
46    
47  my $last_tell=0;  $log->info("rows: $maxmfn");
48    
49  my @isis_dirs = ( '.' );        # use dirname as database name  $webpac->open_import_xml(type => 'isis_hidra_ths');
50    
51  if ($opts{m}) {  while (my $rec = $webpac->fetch_rec) {
         @isis_dirs = split(/,/,$opts{m});  
 }  
52    
53  my @isis_dbs;          my @ds = $webpac->data_structure($rec);
54    
55  foreach (@isis_dirs) {          if ($log->is_debug) {
56          if (-e "$common::isis_data/$db_dir/$_/LIBRI") {                  $log->debug("rec = ",Dumper($rec));
57                  push @isis_dbs,"$common::isis_data/$db_dir/$_/LIBRI/LIBRI";                  $log->debug("ds = ",Dumper(\@ds));
58          }          }
59          if (-e "$common::isis_data/$db_dir/$_/PERI") {  
60                  push @isis_dbs,"$common::isis_data/$db_dir/$_/PERI/PERI";          next if (! @ds);
61          }  
62          if (-e "$common::isis_data/$db_dir/$_/AMS") {          my $filename = $webpac->{'current_filename'};
63                  push @isis_dbs,"$common::isis_data/$db_dir/$_/AMS/AMS";  
64          }          if ($filename) {
65          if (-e "$common::isis_data/$db_dir/$_/ARTI") {                  open(OUT,"> $filename") || $log->logdie("can't open output '$filename': $!");
66  #               push @isis_dbs,"$common::isis_data/$db_dir/$_/ARTI/ARTI";                  print OUT $webpac->output(
67                            template => 'html.tt',
68                            data => \@ds,
69                            headline => $webpac->{'headline'},
70                    );
71                    close(OUT);
72            } else {
73                    print $webpac->output(
74                            template => 'text.tt',
75                            data => \@ds,
76                            headline => $webpac->{'headline'},
77                    );
78          }          }
 }  
79    
80  foreach my $isis_db (@isis_dbs) {          my $headline = $webpac->{'headline'};
81    
82          my $db = OpenIsis::open( "$isis_db" ) || warn "can't open '$isis_db'";          my $f = $filename;
83            $f =~ s!out/!!;
84    
85            # save into index
86            foreach my $ds (@ds) {
87                    next if (! $ds->{'swish'});
88    
89                    $index->insert(
90                            index_name => $ds->{'tag'},
91                            path => $f,
92                            headline => $headline,
93                            words => join(" ",@{$ds->{'swish'}})
94                    );
95            }
96    
97          my $max_rowid = OpenIsis::maxRowid( $db );          # save into sorted index (thesaurus)
98            foreach my $ds (@ds) {
99                    next if (! $ds->{'index'});
100    
101                    $thes->{$ds->{'tag'}} ||= new WebPAC::Index;
102    
103                    $thes->{$ds->{'tag'}}->insert(
104                            path => $f,
105                            headline => $headline,
106                    );
107            }
108    
109          my $last_pcnt = 0;  #       print Dumper(\@ds);
110    
111          for (my $row_id = 1; $row_id <= $max_rowid; $row_id++ ) {  }
                 my $row = OpenIsis::read( $db, $row_id );  
112    
113                  # output current process indicator  if ($log->is_debug) {
114                  my $pcnt = int($row->{mfn} * 100 / $max_rowid);          $log->debug("lookup hash: ",Dumper($webpac->{'lookup'}));
115                  if ($pcnt != $last_pcnt) {          $log->debug("data hash: ",Dumper($webpac->{'data'}));
116                          printf STDERR ("%5d / %5d -- %-2d %%\n",$row->{mfn},$max_rowid,$pcnt) if (! $opts{q});          foreach my $t (keys %{$thes}) {
117                          $last_pcnt = $pcnt;                  $log->debug("thesaurus $t hash: ",Dumper($thes->{$t}));
                 }  
118          }          }
119  }  }
120    
121    $index->close;
122    

Legend:
Removed from v.1  
changed lines
  Added in v.410

  ViewVC Help
Powered by ViewVC 1.1.26