/[wait]/trunk/script/index_yow
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 /trunk/script/index_yow

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (hide annotations)
Tue May 9 11:29:44 2000 UTC (24 years ago) by ulpfr
Original Path: cvs-head/script/index_yow
File size: 3972 byte(s)
Initial revision

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

Properties

Name Value
cvs2svn:cvs-rev 1.1

  ViewVC Help
Powered by ViewVC 1.1.26