/[wait]/cvs-head/script/index_ora
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /cvs-head/script/index_ora

Parent Directory Parent Directory | Revision Log Revision Log


Revision 59 - (hide annotations)
Fri Jan 4 14:51:53 2002 UTC (22 years, 4 months ago) by ulpfr
File size: 4056 byte(s)
Index about field and don't store a copy of 'text'

1 ulpfr 55 #!/usr/bin/perl -w
2     # -*- Mode: Perl -*-
3     # $Basename$
4 ulpfr 59 # $Revision: 1.2 $
5 ulpfr 55 # Author : Ulrich Pfeifer
6     # Created On : Mon Dec 31 13:57:11 2001
7     # Last Modified By: Ulrich Pfeifer
8 ulpfr 59 # Last Modified On: Fri Jan 4 15:47:31 2002
9 ulpfr 55 # Language : CPerl
10     #
11     # (C) Copyright 2001, UUNET Deutschland GmbH, Germany
12     #
13    
14     use strict;
15     use File::Path;
16     use DB_File;
17     use Getopt::Long;
18     use Cwd;
19    
20     require WAIT::Config;
21     require WAIT::Database;
22     require WAIT::Parse::Ora;
23     require WAIT::Document::Ora;
24     require WAIT::InvertedIndex;
25    
26    
27     $DB_BTREE->{'cachesize'} = 200_000 ;
28    
29     my %OPT = (clean => 0,
30     database => 'DB',
31     dir => $WAIT::Config->{WAIT_home} || '/tmp',
32     table => 'ora',
33     );
34    
35     GetOptions(\%OPT,
36     'clean!',
37     'database=s',
38     'dir=s',
39     'table=s',
40     ) || die "Usage: ...\n";
41    
42     if ($OPT{clean} and -d "$OPT{dir}/$OPT{database}") {
43     my $tmp = WAIT::Database->open(name => $OPT{database},
44     'directory' => $OPT{dir})
45     or die "Could not open table $OPT{table}: $@\n";
46     my $tbl = $tmp->table(name => $OPT{table});
47     $tbl->drop if $tbl;
48     rmtree("$OPT{dir}/$OPT{database}/$OPT{table}", 1, 1)
49     if -d "$OPT{dir}/$OPT{database}/$OPT{table}";
50     $tmp->close;
51     }
52    
53     my $db;
54     unless (-d "$OPT{dir}/$OPT{database}") {
55     $db = WAIT::Database->create(name => $OPT{database},
56     'directory' => $OPT{dir})
57     or die "Could not open database $OPT{database}: $@\n";
58     }
59     else {
60     $db = WAIT::Database->open(name => $OPT{database},
61     'directory' => $OPT{dir})
62     or die "Could not open table $OPT{table}: $@\n";
63     }
64    
65     my $layout = new WAIT::Parse::Ora;
66    
67     my $stem = ['isotr', 'isolc', 'split2', 'stop', 'Stem'];
68     my $text = [{
69     'prefix' => ['isotr', 'isolc'],
70     'intervall' => ['isotr', 'isolc'],
71     },
72     'isotr', 'isolc', 'split2', 'stop'];
73     my $sound = ['isotr', 'isolc', 'split2', 'Soundex'],;
74    
75     my $cwd = cwd;
76    
77     my %D;
78     my $access = tie %D, 'WAIT::Document::Ora', @ARGV,
79     or die "Couldn't tie to file: $!\n";
80    
81     my $tb = $db->create_table(name => $OPT{table},
82 ulpfr 59 attr => ['author', 'title',
83 ulpfr 55 'headline', 'docid'],
84     layout => $layout,
85     access => $access,
86     invindex =>
87     [
88     'title' => $stem,
89 ulpfr 59 'about' => $stem,
90 ulpfr 55 'text' => $text,
91     'author' => $text,
92     ]
93     );
94     die "Couldn't create table $OPT{table}: $@\n" unless $tb;
95    
96     my ($did, $value);
97     while (($did, $value) = each %D) {
98     my $record = $layout->split($value);
99     my $headline = $record->{title};
100     $headline =~ s/\s+/ /sg;
101     printf "%s\n", substr($headline,0,80);
102     $tb->insert('docid' => $did,
103     headline => $headline,
104     %{$record});
105     }
106     $tb->set(top=>1);
107     $tb->close();
108     $db->close();
109    
110     $WAIT::Config = $WAIT::Config; # make perl -w happy
111    
112    
113     __END__
114     ## ###################################################################
115     ## pod
116     ## ###################################################################
117    
118     =head1 NAME
119    
120     index_ora - generate an WAIT index for O'Reilly catalog
121    
122     =head1 SYNOPSIS
123    
124     B<index_ora>
125     [B<-clean>] [B<-noclean>]
126     [B<-database> I<dbname>]
127     [B<-dir> I<directory>]
128     [B<-table> I<table name>]
129     I<directory>
130    
131     =head1 DESCRIPTION
132    
133     =head1 OPTIONS
134    
135     =over 5
136    
137     =item B<-clean> / B<-noclean>
138    
139     Clean the table before indexing. Default is B<off>.
140    
141     =item B<-database> I<dbname>
142    
143     Specify database name. Default is F<DB>.
144    
145     =item B<-dir> I<directory>
146    
147     Alternate directory where databases are located. Default is the
148     directory specified during configuration of WAIT.
149    
150     =item B<-table> I<table name>
151    
152     Specify an alternate table name. Default is C<ora>.
153    
154     =head1 AUTHOR
155    
156     Ulrich Pfeifer E<lt>F<pfeifer@wait.de>E<gt>
157    

Properties

Name Value
cvs2svn:cvs-rev 1.2

  ViewVC Help
Powered by ViewVC 1.1.26