/[wait]/branches/CPAN/script/bibdb.PL
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 /branches/CPAN/script/bibdb.PL

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (hide annotations)
Fri Apr 28 15:40:52 2000 UTC (24 years ago) by ulpfr
Original Path: cvs-head/script/bibdb.PL
File MIME type: text/plain
File size: 5499 byte(s)
Initial revision

1 ulpfr 10 #!/bin/sh -- # -*- perl -*- -w
2     eval 'exec perl -S $0 "$@"'
3     if 0;
4    
5     use strict;
6    
7     use Config;
8     use File::Basename qw(fileparse);
9    
10     my($file, $path) = fileparse($0);
11     $file =~ s!\.PL$!!i;
12     chdir($path) or die "Couldn't chdir to `$path': $!\n";
13    
14     print "Extracting $file\n";
15    
16     open(OUT, "> $file") or die "Couldn't create `$file': $!\n";
17     print OUT "$Config{'startperl'} -w\n";
18     while (<DATA>) {
19     print OUT
20     }
21     close(OUT) or die "Couldn't close `$file': $!\n";
22    
23     chmod(0755, $file) or die "Couldn't chmod 744 on `$file': $!\n";
24    
25     exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
26    
27     __END__
28     ######################### -*- Mode: Perl -*- #########################
29     ##
30     ## $Basename: bibdb.PL $
31     ## $Revision: 1.4 $
32     ##
33     ## Author : Ulrich Pfeifer
34     ## Created On : Mon Sep 2 12:57:12 1996
35     ##
36     ## Last Modified By : Ulrich Pfeifer
37     ## Last Modified On : Sun Nov 22 18:44:36 1998
38     ##
39     ## Copyright (c) 1996-1997, Ulrich Pfeifer
40     ##
41     ##
42     ######################################################################
43    
44     eval 'exec perl -S $0 "$@"'
45     if 0;
46    
47    
48     use strict;
49    
50     use File::Path;
51     use DB_File;
52     use Getopt::Long;
53     use Cwd;
54    
55     require WAIT::Config;
56     require WAIT::Database;
57     require WAIT::Parse::Bibdb;
58     require WAIT::Document::Split;
59     require WAIT::InvertedIndex;
60    
61    
62     $DB_BTREE->{'cachesize'} = 200_000 ;
63    
64     my %OPT = (clean => 0,
65     database => 'DB',
66     dir => $WAIT::Config->{WAIT_home} || '/tmp',
67     table => 'bibdb',
68     );
69    
70     GetOptions(\%OPT,
71     'clean!',
72     'database=s',
73     'dir=s',
74     'table=s',
75     ) || die "Usage: ...\n";
76    
77     if ($OPT{clean} and -d "$OPT{dir}/$OPT{database}") {
78     my $tmp = WAIT::Database->open(name => $OPT{database},
79     'directory' => $OPT{dir})
80     or die "Could not open table $OPT{table}: $@\n";
81     my $tbl = $tmp->table(name => $OPT{table});
82     $tbl->drop if $tbl;
83     rmtree("$OPT{dir}/$OPT{database}/$OPT{table}", 1, 1)
84     if -d "$OPT{dir}/$OPT{database}/$OPT{table}";
85     $tmp->close;
86     }
87    
88     my $db;
89     unless (-d "$OPT{dir}/$OPT{database}") {
90     $db = WAIT::Database->create(name => $OPT{database},
91     'directory' => $OPT{dir})
92     or die "Could not open database $OPT{database}: $@\n";
93     }
94     else {
95     $db = WAIT::Database->open(name => $OPT{database},
96     'directory' => $OPT{dir})
97     or die "Could not open table $OPT{table}: $@\n";
98     }
99    
100     my $layout = new WAIT::Parse::Bibdb;
101    
102     my $stem = ['detex', 'isotr', 'isolc', 'split2', 'stop', 'Stem'];
103     my $text = [{
104     'prefix' => ['detex', 'isotr', 'isolc'],
105     'intervall' => ['detex', 'isotr', 'isolc'],
106     },
107     'detex', 'isotr', 'isolc', 'split2', 'stop'];
108     my $sound = ['detex', 'isotr', 'isolc', 'split2', 'Soundex'],;
109    
110     my $cwd = cwd;
111     my($file) = grep -e $_, @ARGV, "$cwd/t/test.ste", '/usr/local/ls6/tex/bib/bibdb.ste';
112    
113     my %D;
114     my $access = tie %D, 'WAIT::Document::Split', 'sep', '\f', $file
115     or die "Couldn't tie to $file: $!\n";
116    
117     my $tb = $db->create_table(name => $OPT{table},
118     attr => ['docid', 'headline'],
119     layout => $layout,
120     access => $access,
121     invindex =>
122     [
123     'ti' => $stem, 'ti' => $text,
124     'jt' => $stem, 'jt' => $text,
125     'bt' => $stem, 'bt' => $text,
126     'sd' => $stem, 'sd' => $text,
127     'ft' => $stem, 'ft' => $text,
128     'ab' => $stem,
129     'au' => $text, 'au' => $sound,
130     'pn' => $text, 'pn' => $sound,
131     'cc' => [{'prefix' => ['cctr', 'isolc']},
132     'cctr', 'isolc', 'split3'],
133     'ed' => [{'intervall' => 1}, 'split6'],
134     'py' => [{'intervall' => 1}, 'split4'],
135     ]
136     );
137     die "Couldn't create table $OPT{table}: $@\n" unless $tb;
138    
139     my ($did, $value);
140     while (($did, $value) = each %D) {
141     my $record = $layout->split($value);
142     my $headline = sprintf("%-20s %s", ($record->{ck}||''), $record->{ti});
143     printf "%s\n", substr($headline,0,80);
144     $tb->insert('docid' => $did,
145     headline => $headline,
146     %{$record});
147     }
148    
149     $db->close();
150    
151     $WAIT::Config = $WAIT::Config; # make perl -w happy
152    
153    
154     __END__
155     ## ###################################################################
156     ## pod
157     ## ###################################################################
158    
159     =head1 NAME
160    
161     bibdb - generate an WAIT index for bibdb records
162    
163     =head1 SYNOPSIS
164    
165     B<bibdb>
166     [B<-clean>] [B<-noclean>]
167     [B<-database> I<dbname>]
168     [B<-dir> I<directory>]
169     [B<-table> I<table name>]
170    
171     =head1 DESCRIPTION
172    
173     Either indexes F<$WAIT/t/test.ste> (if called from directory F<$WAIT>)
174     or F</usr/local/ls6/tex/bib/bibdb.ste>.
175    
176     =head1 OPTIONS
177    
178     =over 5
179    
180     =item B<-clean> / B<-noclean>
181    
182     Clean the table befor indexing. Default is B<off>.
183    
184     =item B<-database> I<dbname>
185    
186     Specify database name. Default is F<DB>.
187    
188     =item B<-dir> I<directory>
189    
190     Alternate directory were databases are located. Default is the
191     directory specified during configuration of WAIT.
192    
193     =item B<-table> I<table name>
194    
195     Specify an alternate table name. Default is C<bibdb>.
196    
197     =head1 AUTHOR
198    
199     Ulrich Pfeifer E<lt>F<pfeifer@ls6.informatik.uni-dortumund.de>E<gt>

Properties

Name Value
cvs2svn:cvs-rev 1.1
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26