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

Contents of /trunk/script/bibdb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 116 - (show annotations)
Wed Jul 14 09:48:26 2004 UTC (19 years, 9 months ago) by dpavlin
File size: 4883 byte(s)
more fixes, more debug

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26