/[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

Diff of /cvs-head/script/index_ora

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 59 by ulpfr, Fri Jan 4 14:51:53 2002 UTC revision 67 by laperla, Thu Jan 24 00:40:43 2002 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2  #                              -*- Mode: Perl -*-  #                              -*- Mode: Perl -*-
3  # $Basename$  # $Basename$
4  # $Revision: 1.2 $  # $Revision: 1.5 $
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
8  # Last Modified On: Fri Jan  4 15:47:31 2002  # Last Modified On: Fri Jan  4 15:59:20 2002
9  # Language        : CPerl  # Language        : CPerl
10  #  #
11  # (C) Copyright 2001, UUNET Deutschland GmbH, Germany  # (C) Copyright 2001, UUNET Deutschland GmbH, Germany
# Line 26  require WAIT::InvertedIndex; Line 26  require WAIT::InvertedIndex;
26    
27  $DB_BTREE->{'cachesize'} = 200_000 ;  $DB_BTREE->{'cachesize'} = 200_000 ;
28    
29  my %OPT = (clean    => 0,  my %OPT = (
30             database => 'DB',             database => 'DB',
31             dir      => $WAIT::Config->{WAIT_home} || '/tmp',             dir      => $WAIT::Config->{WAIT_home} || '/tmp',
32             table    => 'ora',             table    => 'ora',
33            );            );
34    
35  GetOptions(\%OPT,  GetOptions(\%OPT,
            'clean!',  
36             'database=s',             'database=s',
37             'dir=s',             'dir=s',
38             'table=s',             'table=s',
39            ) || die "Usage: ...\n";            ) || die "Usage: ...\n";
40    
 if ($OPT{clean} and -d "$OPT{dir}/$OPT{database}") {  
   my $tmp = WAIT::Database->open(name        => $OPT{database},  
                                  'directory' => $OPT{dir})  
     or die "Could not open table $OPT{table}: $@\n";  
   my $tbl = $tmp->table(name => $OPT{table});  
   $tbl->drop if $tbl;  
   rmtree("$OPT{dir}/$OPT{database}/$OPT{table}", 1, 1)  
     if -d "$OPT{dir}/$OPT{database}/$OPT{table}";  
   $tmp->close;  
 }  
   
41  my $db;  my $db;
42  unless (-d "$OPT{dir}/$OPT{database}") {  unless (-d "$OPT{dir}/$OPT{database}") {
43    $db = WAIT::Database->create(name       => $OPT{database},    $db = WAIT::Database->create(name       => $OPT{database},
# Line 79  my $access = tie %D, 'WAIT::Document::Or Line 67  my $access = tie %D, 'WAIT::Document::Or
67    or die "Couldn't tie to file: $!\n";    or die "Couldn't tie to file: $!\n";
68    
69  my $tb = $db->create_table(name     => $OPT{table},  my $tb = $db->create_table(name     => $OPT{table},
70                             attr     => ['author', 'title',                             attr     => ['author', 'isbn', 'title',
71                                          'headline', 'docid'],                                          'headline', 'docid'],
72                             layout   => $layout,                             layout   => $layout,
73                             access   => $access,                             access   => $access,
# Line 89  my $tb = $db->create_table(name     => $ Line 77  my $tb = $db->create_table(name     => $
77                              'about'  => $stem,                              'about'  => $stem,
78                              'text'   => $text,                              'text'   => $text,
79                              'author' => $text,                              'author' => $text,
80                                'colophon' => $text,
81                                'author' => $sound,
82                                'isbn'   => $text,
83                             ]                             ]
84                            );                            );
85  die "Couldn't create table $OPT{table}: $@\n" unless $tb;  die "Couldn't create table $OPT{table}: $@\n" unless $tb;
# Line 98  while (($did, $value) = each %D) { Line 89  while (($did, $value) = each %D) {
89    my $record   = $layout->split($value);    my $record   = $layout->split($value);
90    my $headline = $record->{title};    my $headline = $record->{title};
91    $headline =~ s/\s+/ /sg;    $headline =~ s/\s+/ /sg;
92    printf "%s\n", substr($headline,0,80);    printf "%15s %s\n", $record->{isbn}, substr($headline,0,60);
93    $tb->insert('docid'  => $did,    $tb->insert('docid'  => $did,
94                headline => $headline,                headline => $headline,
95                %{$record});                %{$record});
# Line 122  index_ora - generate an WAIT index for O Line 113  index_ora - generate an WAIT index for O
113  =head1 SYNOPSIS  =head1 SYNOPSIS
114    
115  B<index_ora>  B<index_ora>
 [B<-clean>] [B<-noclean>]  
116  [B<-database> I<dbname>]  [B<-database> I<dbname>]
117  [B<-dir> I<directory>]  [B<-dir> I<directory>]
118  [B<-table> I<table name>]  [B<-table> I<table name>]
# Line 134  I<directory> Line 124  I<directory>
124    
125  =over 5  =over 5
126    
 =item B<-clean> / B<-noclean>  
   
 Clean the table before indexing. Default is B<off>.  
   
127  =item B<-database> I<dbname>  =item B<-database> I<dbname>
128    
129  Specify database name. Default is F<DB>.  Specify database name. Default is F<DB>.

Legend:
Removed from v.59  
changed lines
  Added in v.67

  ViewVC Help
Powered by ViewVC 1.1.26