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 |
|
17 |
my $webpac = new WebPAC( |
18 |
code_page => 'ISO-8859-2', |
19 |
limit_mfn => 100, |
20 |
# debug => 1, |
21 |
) || die; |
22 |
|
23 |
my $log = $webpac->_get_logger(); |
24 |
|
25 |
my $index = new WebPAC::jsFind( |
26 |
index_path => './out/index', |
27 |
) || die; |
28 |
|
29 |
$|=1; |
30 |
|
31 |
my $maxmfn = $webpac->open_isis( |
32 |
filename => shift @ARGV || '/data/hidra/THS/THS', |
33 |
lookup => [ |
34 |
{ 'key' => 'd:v900', 'val' => 'v250^a' }, |
35 |
# { 'eval' => '"v901^a" eq "Podruèje"', 'key' => 'pa:v561^4:v562^4:v461^1', 'val' => 'v900' }, |
36 |
# { 'eval '=> '"v901^a" eq "Mikrotezaurus"', 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' }, |
37 |
# { 'eval' => '"v901^a" eq "Deskriptor"', 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' }, |
38 |
{ 'key' => 'a:v561^4:v562^4:v461^1', 'val' => 'v900' }, |
39 |
{ 'key' => '900_mfn:v900', 'val' => 'v000' }, |
40 |
], |
41 |
); |
42 |
|
43 |
$log->info("rows: $maxmfn"); |
44 |
|
45 |
$webpac->open_import_xml(type => 'isis_hidra_ths'); |
46 |
|
47 |
while (my $rec = $webpac->fetch_rec) { |
48 |
|
49 |
my @ds = $webpac->data_structure($rec); |
50 |
|
51 |
if ($log->is_debug) { |
52 |
$log->debug("rec = ",Dumper($rec)); |
53 |
$log->debug("ds = ",Dumper(\@ds)); |
54 |
} |
55 |
|
56 |
next if (! @ds); |
57 |
|
58 |
my $filename = $webpac->{'current_filename'}; |
59 |
|
60 |
if ($filename) { |
61 |
open(OUT,"> $filename") || $log->logdie("can't open output '$filename': $!"); |
62 |
print OUT $webpac->output( |
63 |
template => 'html.tt', |
64 |
data => \@ds, |
65 |
); |
66 |
close(OUT); |
67 |
} else { |
68 |
print $webpac->output( |
69 |
template => 'text.tt', |
70 |
data => \@ds, |
71 |
); |
72 |
} |
73 |
|
74 |
my $headline; |
75 |
foreach my $ds (@ds) { |
76 |
if ($ds->{'tag'} eq 'headline') { |
77 |
$headline = join(" ",@{$ds->{'display'}}); |
78 |
last; |
79 |
} |
80 |
} |
81 |
|
82 |
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 |
# print Dumper(\@ds); |
98 |
|
99 |
} |
100 |
|
101 |
if ($log->is_debug) { |
102 |
$log->debug("lookup hash: ",Dumper($webpac->{'lookup'})); |
103 |
$log->debug("data hash: ",Dumper($webpac->{'data'})); |
104 |
} |
105 |
|
106 |
$index->close; |
107 |
|