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

Contents of /trunk2/all2all.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 415 - (show annotations)
Wed Sep 8 15:30:07 2004 UTC (19 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 2786 byte(s)
clean old data before generating new, create JavaScript indexes,
fix inserting into index

1 #!/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;
10 use Data::Dumper;
11 use Carp;
12
13 use lib './lib';
14 use WebPAC;
15 use WebPAC::jsFind;
16 use WebPAC::Index;
17
18 my $webpac = new WebPAC(
19 code_page => 'ISO-8859-2',
20 limit_mfn => 500,
21 # debug => 1,
22 ) || die;
23
24 my $log = $webpac->_get_logger();
25
26 my $index = new WebPAC::jsFind(
27 index_path => './out/index',
28 keys => 10,
29 ) || die;
30
31 my $thes;
32
33 $|=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 $log->info("rows: $maxmfn");
48
49 $webpac->open_import_xml(type => 'isis_hidra_ths');
50
51 while (my $rec = $webpac->fetch_rec) {
52
53 my @ds = $webpac->data_structure($rec);
54
55 if (0 && $log->is_debug) {
56 $log->debug("rec = ",Dumper($rec));
57 $log->debug("ds = ",Dumper(\@ds));
58 }
59
60 next if (! @ds);
61
62 my $filename = $webpac->{'current_filename'};
63
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 foreach my $h (@{$ds->{'index'}}) {
103 $thes->{$ds->{'tag'}}->insert(
104 path => $f,
105 headline => $h,
106 );
107 }
108 }
109
110 # print Dumper(\@ds);
111
112 }
113
114 foreach my $t (keys %{$thes}) {
115
116 my @e = $thes->{$t}->elements;
117 if (! @e) {
118 $log->logwarn("no elements in sorted index $t?");
119 next;
120 }
121
122 my $file = "./out/bfilter/$t.txt";
123 $log->info("saving sorted index $t to '$file' [".scalar(@e)." elements]");
124
125 $webpac->output_file(
126 file => $file,
127 template => 'index.tt',
128 data => \@e,
129 index_name => $t,
130 );
131 }
132
133 if (0 && $log->is_debug) {
134 $log->debug("lookup hash: ",Dumper($webpac->{'lookup'}));
135 $log->debug("data hash: ",Dumper($webpac->{'data'}));
136 foreach my $t (keys %{$thes}) {
137 $log->debug("thesaurus $t hash: ",Dumper($thes->{$t}));
138 }
139 }
140
141 $index->close;
142

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26