1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
# -*- Mode: Perl -*- |
# -*- Mode: Perl -*- |
3 |
# $Basename$ |
# $Basename$ |
4 |
# $Revision: 1.10 $ |
# $Revision: 1.11 $ |
5 |
# Author : Ulrich Pfeifer |
# Author : Ulrich Pfeifer |
6 |
# Created On : Mon Dec 31 13:57:11 2001 |
# Created On : Mon Dec 31 13:57:11 2001 |
7 |
# Last Modified By: Ulrich Pfeifer |
# Last Modified By: Ulrich Pfeifer |
26 |
use WAIT::Parse::Ora; |
use WAIT::Parse::Ora; |
27 |
use WAIT::Document::Ora; |
use WAIT::Document::Ora; |
28 |
use WAIT::InvertedIndex; |
use WAIT::InvertedIndex; |
29 |
|
use Data::Dumper; |
30 |
|
|
31 |
|
|
32 |
$DB_BTREE->{'cachesize'} = 200_000 ; |
$DB_BTREE->{'cachesize'} = 200_000 ; |
54 |
my $layout = new WAIT::Parse::Ora; |
my $layout = new WAIT::Parse::Ora; |
55 |
|
|
56 |
use lib "/usr/local/apache/lib"; |
use lib "/usr/local/apache/lib"; |
57 |
use oreilly_de_catalog::wait_handler; |
use oreilly_de_catalog::wait_filter; |
58 |
|
|
59 |
my $stem = ['OR_tr_20020124', 'OR_lc_20020124', 'split2', 'stop', 'Stem']; |
my $stem = ['OR_tr_20020124', 'OR_lc_20020125', 'split2', 'stop', 'Stem']; |
60 |
my $text = [{ |
my $text = ['OR_tr_20020124', 'OR_lc_20020125', 'split2', 'stop']; |
61 |
'prefix' => ['OR_tr_20020124', 'OR_lc_20020124'], |
my $wplus = ['split2', 'OR_lc_20020125', 'OR_mixedonly_20020221']; |
62 |
'intervall' => ['OR_tr_20020124', 'OR_lc_20020124'], |
my $sound = ['OR_tr_20020124', 'OR_lc_20020125', 'split2', 'Soundex']; |
63 |
}, |
my $trigr = ['OR_lc_20020125', 'OR_trigrams_20020125']; |
|
'OR_tr_20020124', 'OR_lc_20020124', 'split2', 'stop']; |
|
|
my $wplus = ['split2', 'OR_lc_20020124', 'OR_mixedonly_20020221']; |
|
|
my $sound = ['OR_tr_20020124', 'OR_lc_20020124', 'split2', 'Soundex']; |
|
|
my $trigr = ['OR_lc_20020124', 'OR_trigrams_20020125']; |
|
64 |
# split6 is better than split13 or split10: it allows them to enter |
# split6 is better than split13 or split10: it allows them to enter |
65 |
# shorter sequences when searching. |
# shorter sequences when searching. |
66 |
my $isbn = ['split6', 'OR_isbn_20020127']; |
my $isbn = ['split6', 'OR_isbn_20020127']; |
80 |
access => $access, |
access => $access, |
81 |
invindex => |
invindex => |
82 |
[ |
[ |
|
'title' => $text, |
|
|
'title' => $wplus, |
|
|
# 'title' => $stem, |
|
83 |
'aboutauthor' => $text, |
'aboutauthor' => $text, |
84 |
'aboutauthor' => $wplus, |
'aboutauthor' => $wplus, |
85 |
# 'aboutauthor' => $stem, |
'abouttranslator' => $text, |
86 |
'desc' => $text, |
'abouttranslator' => $wplus, |
|
'desc' => $wplus, |
|
87 |
'abstract' => $text, |
'abstract' => $text, |
88 |
'abstract' => $wplus, |
'abstract' => $wplus, |
89 |
'author' => $text, |
'author' => $text, |
|
# 'author' => $sound, |
|
90 |
'colophon' => $text, |
'colophon' => $text, |
91 |
'colophon' => $wplus, |
'colophon' => $wplus, |
92 |
|
'desc' => $text, |
93 |
|
'desc' => $wplus, |
94 |
|
'inx' => $text, |
95 |
|
'inx' => $wplus, |
96 |
'isbn' => $isbn, |
'isbn' => $isbn, |
97 |
|
'subtitle' => $text, |
98 |
|
'subtitle' => $wplus, |
99 |
|
'title' => $text, |
100 |
|
'title' => $wplus, |
101 |
|
'title_orig' => $text, |
102 |
|
'title_orig' => $wplus, |
103 |
|
'toc' => $text, |
104 |
|
'toc' => $wplus, |
105 |
|
'translator' => $text, |
106 |
|
'translator' => $wplus, |
107 |
] |
] |
108 |
); |
); |
109 |
die "Couldn't create table $OPT{table}: $@\n" unless $tb; |
die "Couldn't create table $OPT{table}: $@\n" unless $tb; |
110 |
|
|
111 |
my ($did, $value); |
my ($did, $value); |
112 |
binmode STDOUT, ":utf8"; |
binmode STDOUT, ":utf8"; |
113 |
while (($did, $value) = each %D) { |
my $ALL; |
114 |
|
my $traceALL = 0; # expensive |
115 |
|
my $done = 0; |
116 |
|
my $todo = keys %D; |
117 |
|
my $lasttimeround = my $starttime = time; |
118 |
|
|
119 |
|
DOC: while (($did, $value) = each %D) { |
120 |
my $record = $layout->split($value); |
my $record = $layout->split($value); |
121 |
my $headline = $record->{title}; |
my $headline = $record->{title}; |
122 |
$headline =~ s/\s+/ /sg; |
$headline =~ s/\s+/ /sg; |
123 |
printf "%15s %s\n", $record->{isbn}, substr($headline,0,60); |
# printf "%15s %s\n", $record->{isbn}, substr($headline,0,60); |
124 |
|
printf "%15s %s...\n", $did, substr($headline,0,60); |
125 |
$tb->insert('docid' => $did, |
$tb->insert('docid' => $did, |
126 |
headline => $headline, |
headline => $headline, |
127 |
%{$record}); |
%{$record}); |
128 |
|
$done++; |
129 |
|
my $spenttime = time - $starttime; |
130 |
|
my $averagetime = $spenttime/$done; |
131 |
|
my $left = $todo-$done; |
132 |
|
printf("%2d secs, %3d done, %3d left, %4d s done, %5.1f s avg, %4d s left\n", |
133 |
|
time - $lasttimeround, |
134 |
|
$done, |
135 |
|
$left, |
136 |
|
$spenttime, |
137 |
|
$averagetime, |
138 |
|
$left*$averagetime, |
139 |
|
); |
140 |
|
$lasttimeround = time; |
141 |
|
if ($traceALL) { # costs a lot when reaching the 100th file or so |
142 |
|
$ALL->{$did} = $record; |
143 |
|
open F, ">:utf8", "$OPT{dir}/$OPT{database}-$jobid/debug.dump" or die; |
144 |
|
print F Data::Dumper::Dumper($ALL); |
145 |
|
close F; |
146 |
|
} |
147 |
} |
} |
148 |
|
undef $ALL; |
149 |
$tb->set(top=>1); |
$tb->set(top=>1); |
150 |
|
|
151 |
my $tritb = $db->create_table( |
my $tritb = $db->create_table( |
183 |
$db->close(); |
$db->close(); |
184 |
|
|
185 |
# Atomically relinking symlink: now we have a new database with a very |
# Atomically relinking symlink: now we have a new database with a very |
186 |
# long name like oreilly_de_catalog-2002-01-28_16:12_16467 and we want |
# long name "$OPT{database}-$jobid" (e.g. |
187 |
# that database to be accessible with the oreilly_de_catalog name. |
# oreilly_de_catalog-2002-01-28_16:12_16467) and we want that database |
188 |
|
# to be accessible with the oreilly_de_catalog name. |
189 |
|
|
190 |
use File::Spec; |
use File::Spec; |
191 |
|
chdir $OPT{dir} or die; |
192 |
my $dir = "$OPT{database}-$jobid"; |
my $dir = "$OPT{database}-$jobid"; |
193 |
my $slwant = File::Spec->catdir($OPT{dir}, $OPT{database}); |
my $slwant = File::Spec->catdir($OPT{dir}, $OPT{database}); |
194 |
my $sltmp = File::Spec->catdir($OPT{dir}, "$OPT{database}-$$"); |
my $sltmp = File::Spec->catdir($OPT{dir}, "$OPT{database}-$$"); |