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

Annotation of /trunk2/all2all.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 410 - (hide annotations)
Sun Sep 5 21:40:57 2004 UTC (15 years, 1 month ago) by dpavlin
File MIME type: text/plain
File size: 2451 byte(s)
added sorted index using WebPAC::Index module

1 dpavlin 1 #!/usr/bin/perl -w
2    
3 dpavlin 348 =head1 NAME
4    
5 dpavlin 354 all2all.pl - basic script for all WebPAC needs
6 dpavlin 348
7     =cut
8    
9 dpavlin 1 use strict;
10     use Data::Dumper;
11 dpavlin 352 use Carp;
12 dpavlin 1
13 dpavlin 352 use lib './lib';
14 dpavlin 354 use WebPAC;
15 dpavlin 390 use WebPAC::jsFind;
16 dpavlin 410 use WebPAC::Index;
17 dpavlin 348
18 dpavlin 354 my $webpac = new WebPAC(
19 dpavlin 352 code_page => 'ISO-8859-2',
20 dpavlin 410 limit_mfn => 100,
21 dpavlin 372 # debug => 1,
22 dpavlin 352 ) || die;
23    
24 dpavlin 373 my $log = $webpac->_get_logger();
25    
26 dpavlin 390 my $index = new WebPAC::jsFind(
27     index_path => './out/index',
28 dpavlin 407 keys => 80,
29 dpavlin 390 ) || die;
30    
31 dpavlin 410 my $thes;
32    
33 dpavlin 10 $|=1;
34 dpavlin 9
35 dpavlin 352 my $maxmfn = $webpac->open_isis(
36 dpavlin 357 filename => shift @ARGV || '/data/hidra/THS/THS',
37 dpavlin 352 lookup => [
38 dpavlin 348 { 'key' => 'd:v900', 'val' => 'v250^a' },
39 dpavlin 352 # { '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 dpavlin 374 { 'key' => '900_mfn:v900', 'val' => 'v000' },
44 dpavlin 352 ],
45 dpavlin 54 );
46 dpavlin 3
47 dpavlin 372 $log->info("rows: $maxmfn");
48 dpavlin 170
49 dpavlin 363 $webpac->open_import_xml(type => 'isis_hidra_ths');
50    
51 dpavlin 362 while (my $rec = $webpac->fetch_rec) {
52 dpavlin 358
53 dpavlin 370 my @ds = $webpac->data_structure($rec);
54 dpavlin 366
55 dpavlin 372 if ($log->is_debug) {
56     $log->debug("rec = ",Dumper($rec));
57     $log->debug("ds = ",Dumper(\@ds));
58     }
59    
60 dpavlin 374 next if (! @ds);
61 dpavlin 366
62 dpavlin 374 my $filename = $webpac->{'current_filename'};
63    
64     if ($filename) {
65     open(OUT,"> $filename") || $log->logdie("can't open output '$filename': $!");
66     print OUT $webpac->output(
67     template => 'html.tt',
68     data => \@ds,
69 dpavlin 398 headline => $webpac->{'headline'},
70 dpavlin 374 );
71     close(OUT);
72     } else {
73     print $webpac->output(
74     template => 'text.tt',
75     data => \@ds,
76 dpavlin 398 headline => $webpac->{'headline'},
77 dpavlin 374 );
78     }
79    
80 dpavlin 398 my $headline = $webpac->{'headline'};
81 dpavlin 390
82 dpavlin 392 my $f = $filename;
83     $f =~ s!out/!!;
84    
85 dpavlin 390 # save into index
86     foreach my $ds (@ds) {
87     next if (! $ds->{'swish'});
88    
89     $index->insert(
90     index_name => $ds->{'tag'},
91 dpavlin 392 path => $f,
92 dpavlin 390 headline => $headline,
93     words => join(" ",@{$ds->{'swish'}})
94     );
95     }
96    
97 dpavlin 410 # 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 dpavlin 390 # print Dumper(\@ds);
110    
111 dpavlin 3 }
112    
113 dpavlin 372 if ($log->is_debug) {
114     $log->debug("lookup hash: ",Dumper($webpac->{'lookup'}));
115     $log->debug("data hash: ",Dumper($webpac->{'data'}));
116 dpavlin 410 foreach my $t (keys %{$thes}) {
117     $log->debug("thesaurus $t hash: ",Dumper($thes->{$t}));
118     }
119 dpavlin 372 }
120 dpavlin 390
121     $index->close;
122    

Properties

Name Value
cvs2svn:cvs-rev 1.64
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26