9 |
|
|
10 |
use WebPAC::Lookup; |
use WebPAC::Lookup; |
11 |
use WebPAC::Input::ISIS; |
use WebPAC::Input::ISIS; |
12 |
use WebPAC::DB; |
use WebPAC::Store 0.03; |
13 |
use WebPAC::Normalize::XML; |
use WebPAC::Normalize::XML; |
14 |
use WebPAC::Output::TT; |
use WebPAC::Output::TT; |
15 |
use WebPAC::Output::Estraier; |
use WebPAC::Output::Estraier; |
16 |
|
use YAML qw/LoadFile/; |
17 |
|
|
18 |
my $limit = shift @ARGV; |
my $limit = shift @ARGV; |
19 |
|
|
20 |
|
my $config = LoadFile('conf/config.yml'); |
21 |
|
|
22 |
|
print "config = ",Dumper($config); |
23 |
|
|
24 |
|
my $type = lc($config->{input}->{type}); |
25 |
|
|
26 |
|
die "I know only how to handle input type isis, not '$type'!\n" unless ($type eq 'isis'); |
27 |
|
|
28 |
my $abs_path = abs_path($0); |
my $abs_path = abs_path($0); |
29 |
$abs_path =~ s#/[^/]*$#/#; |
$abs_path =~ s#/[^/]*$#/#; |
30 |
|
|
|
my $isis_file = '/data/isis_data/ps/LIBRI/LIBRI'; |
|
|
|
|
31 |
my $lookup = new WebPAC::Lookup( |
my $lookup = new WebPAC::Lookup( |
32 |
lookup_file => "$abs_path/conf/lookup/isis.pm", |
lookup_file => $config->{input}->{lookup}, |
33 |
); |
); |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
my $isis = new WebPAC::Input::ISIS( |
my $isis = new WebPAC::Input::ISIS( |
38 |
code_page => 'ISO-8859-2', # application encoding |
code_page => $config->{webpac}->{webpac_encoding}, |
39 |
limit_mfn => $limit, |
limit_mfn => $config->{input}->{limit}, |
40 |
); |
); |
41 |
|
|
42 |
my $maxmfn = $isis->open( |
my $maxmfn = $isis->open( |
43 |
filename => $isis_file, |
filename => $config->{input}->{path}, |
44 |
code_page => '852', # database encoding |
code_page => $config->{input}->{encoding}, # database encoding |
45 |
); |
); |
46 |
|
|
47 |
my $path = './db/'; |
my $path = './db/'; |
48 |
|
|
49 |
my $db = new WebPAC::DB( |
my $db = new WebPAC::Store( |
50 |
path => $path, |
path => $config->{webpac}->{db_path}, |
51 |
); |
); |
52 |
|
|
53 |
my $n = new WebPAC::Normalize::XML( |
my $n = new WebPAC::Normalize::XML( |
58 |
); |
); |
59 |
|
|
60 |
$n->open( |
$n->open( |
61 |
tag => 'isis', |
tag => $config->{normalize}->{tag}, |
62 |
xml_file => "$abs_path/conf/normalize/isis_ffzg.xml", |
xml_file => $config->{normalize}->{path}, |
63 |
); |
); |
64 |
|
|
65 |
my $out = new WebPAC::Output::TT( |
my $out = new WebPAC::Output::TT( |
66 |
include_path => "$abs_path/conf/output/tt", |
include_path => $config->{webpac}->{template_path}, |
67 |
filters => { foo => sub { shift } }, |
filters => { foo => sub { shift } }, |
68 |
); |
); |
69 |
|
|
70 |
my $est = new WebPAC::Output::Estraier( |
my $est = new WebPAC::Output::Estraier( |
71 |
url => 'http://localhost:1978/node/webpac2', |
%{ $config->{hyperestraier} } |
|
user => 'admin', |
|
|
passwd => 'admin', |
|
|
database => 'ps', |
|
72 |
); |
); |
73 |
|
|
74 |
while (my $row = $isis->fetch) { |
my $total_rows = 0; |
75 |
|
|
76 |
|
for ( 0 ... $isis->size ) { |
77 |
|
|
78 |
|
my $row = $isis->fetch || next; |
79 |
|
|
80 |
my $mfn = $row->{'000'}->[0] || die "can't find MFN"; |
my $mfn = $row->{'000'}->[0] || die "can't find MFN"; |
81 |
|
|
83 |
|
|
84 |
# print STDERR Dumper($row, $ds); |
# print STDERR Dumper($row, $ds); |
85 |
|
|
86 |
my $html = $out->apply( |
# my $html = $out->apply( |
87 |
template => 'html_ffzg.tt', |
# template => 'html_ffzg.tt', |
88 |
data => $ds, |
# data => $ds, |
89 |
); |
# ); |
90 |
|
# |
91 |
# create test output |
# # create test output |
92 |
|
# |
93 |
my $file = sprintf('out/%02d.html', $mfn ); |
# my $file = sprintf('out/%02d.html', $mfn ); |
94 |
open(my $fh, '>', $file) or die "can't open $file: $!"; |
# open(my $fh, '>', $file) or die "can't open $file: $!"; |
95 |
print $fh $html; |
# print $fh $html; |
96 |
close($fh); |
# close($fh); |
97 |
|
# |
98 |
$html =~ s#\s*[\n\r]+\s*##gs; |
# $html =~ s#\s*[\n\r]+\s*##gs; |
99 |
|
# |
100 |
# print STDERR $html; |
# print STDERR $html; |
101 |
|
|
102 |
$est->add( |
$est->add( |
103 |
id => $mfn, |
id => $mfn, |
104 |
ds => $ds, |
ds => $ds, |
105 |
type => 'search', |
type => $config->{hyperestraier}->{type}, |
106 |
); |
); |
107 |
|
|
108 |
|
$total_rows++; |
109 |
|
|
110 |
}; |
}; |
111 |
|
|
112 |
|
my $log = $lookup->_get_logger; |
113 |
|
|
114 |
|
$log->info("$total_rows records indexed"); |