1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
# -*- Mode: Perl -*- |
# -*- Mode: Perl -*- |
3 |
# $Basename$ |
# $Basename$ |
4 |
# $Revision: 1.5 $ |
# $Revision: 1.7 $ |
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 |
11 |
# (C) Copyright 2001, UUNET Deutschland GmbH, Germany |
# (C) Copyright 2001, UUNET Deutschland GmbH, Germany |
12 |
# |
# |
13 |
|
|
14 |
|
use 5.007; |
15 |
|
|
16 |
use strict; |
use strict; |
17 |
|
|
18 |
use File::Path; |
use File::Path; |
19 |
use DB_File; |
use DB_File; |
20 |
use Getopt::Long; |
use Getopt::Long; |
21 |
use Cwd; |
use Cwd; |
22 |
|
|
23 |
require WAIT::Config; |
BEGIN {require WAIT::Config;} |
24 |
require WAIT::Database; |
use WAIT::Database; |
25 |
require WAIT::Parse::Ora; |
use WAIT::Parse::Ora; |
26 |
require WAIT::Document::Ora; |
use WAIT::Document::Ora; |
27 |
require WAIT::InvertedIndex; |
use WAIT::InvertedIndex; |
28 |
|
|
29 |
|
|
30 |
$DB_BTREE->{'cachesize'} = 200_000 ; |
$DB_BTREE->{'cachesize'} = 200_000 ; |
41 |
'table=s', |
'table=s', |
42 |
) || die "Usage: ...\n"; |
) || die "Usage: ...\n"; |
43 |
|
|
44 |
my $db; |
my @localtime = localtime; |
45 |
unless (-d "$OPT{dir}/$OPT{database}") { |
$localtime[5] += 1900; |
46 |
$db = WAIT::Database->create(name => $OPT{database}, |
$localtime[4]++; |
47 |
'directory' => $OPT{dir}) |
my $jobid = sprintf "%04s-%02s-%02s_%02s:%02s_%d", @localtime[5,4,3,2,1], $$; |
48 |
or die "Could not open database $OPT{database}: $@\n"; |
my $db = WAIT::Database->create(name => "$OPT{database}-$jobid", |
49 |
} |
directory => $OPT{dir}) |
50 |
else { |
or die "Could not create database $OPT{database}: $@\n"; |
|
$db = WAIT::Database->open(name => $OPT{database}, |
|
|
'directory' => $OPT{dir}) |
|
|
or die "Could not open table $OPT{table}: $@\n"; |
|
|
} |
|
51 |
|
|
52 |
my $layout = new WAIT::Parse::Ora; |
my $layout = new WAIT::Parse::Ora; |
53 |
|
|
54 |
my $stem = ['isotr', 'isolc', 'split2', 'stop', 'Stem']; |
use lib "/usr/local/apache/lib"; |
55 |
|
use oreilly_de_catalog::wait_handler; |
56 |
|
|
57 |
|
my $stem = ['OR_tr_20020124', 'OR_lc_20020124', 'split2', 'stop', 'Stem']; |
58 |
my $text = [{ |
my $text = [{ |
59 |
'prefix' => ['isotr', 'isolc'], |
'prefix' => ['OR_tr_20020124', 'OR_lc_20020124'], |
60 |
'intervall' => ['isotr', 'isolc'], |
'intervall' => ['OR_tr_20020124', 'OR_lc_20020124'], |
61 |
}, |
}, |
62 |
'isotr', 'isolc', 'split2', 'stop']; |
'OR_tr_20020124', 'OR_lc_20020124', 'split2', 'stop']; |
63 |
my $sound = ['isotr', 'isolc', 'split2', 'Soundex'],; |
my $sound = ['OR_tr_20020124', 'OR_lc_20020124', 'split2', 'Soundex'],; |
64 |
|
|
65 |
my $cwd = cwd; |
my $cwd = cwd; |
66 |
|
|
87 |
die "Couldn't create table $OPT{table}: $@\n" unless $tb; |
die "Couldn't create table $OPT{table}: $@\n" unless $tb; |
88 |
|
|
89 |
my ($did, $value); |
my ($did, $value); |
90 |
|
binmode STDOUT, ":utf8"; |
91 |
while (($did, $value) = each %D) { |
while (($did, $value) = each %D) { |
92 |
my $record = $layout->split($value); |
my $record = $layout->split($value); |
93 |
my $headline = $record->{title}; |
my $headline = $record->{title}; |
101 |
$tb->close(); |
$tb->close(); |
102 |
$db->close(); |
$db->close(); |
103 |
|
|
104 |
|
# Now we have a new database with a very long name and we want that |
105 |
|
# database to be accessible with the $OPT{database} name |
106 |
|
|
107 |
|
use File::Spec; |
108 |
|
my $long_dir = "$OPT{database}-$jobid"; |
109 |
|
my $want_dir = File::Spec->catdir($OPT{dir}, $OPT{database}); |
110 |
|
my $prel_slink = File::Spec->catdir($OPT{dir}, "$OPT{database}-$$"); |
111 |
|
unlink $prel_slink; # may fail |
112 |
|
symlink $long_dir, $prel_slink or die "Could not symlink $long_dir, $prel_slink: $!"; |
113 |
|
rename $prel_slink, $want_dir or die "Could not rename $prel_slink, $want_dir: $!"; |
114 |
|
|
115 |
$WAIT::Config = $WAIT::Config; # make perl -w happy |
$WAIT::Config = $WAIT::Config; # make perl -w happy |
116 |
|
|
117 |
|
|