/[wait]/cvs-head/script/index_mail
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 /cvs-head/script/index_mail

Parent Directory Parent Directory | Revision Log Revision Log


Revision 47 - (show annotations)
Fri Dec 29 15:33:06 2000 UTC (23 years, 4 months ago) by ulpfr
File size: 4100 byte(s)
First steps towards a mail indexer

1 # -*- Mode: Perl -*-
2 # $Basename: index_mail $
3 # $Revision: 1.1 $
4 # Author : Ulrich Pfeifer
5 # Created On : Fri Apr 7 13:45:50 2000
6 # Last Modified By: Ulrich Pfeifer
7 # Last Modified On: Fri Dec 29 16:07:43 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::Overview;
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 => 'mail',
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::Overview;
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', 'end', '$', @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 'subject' => $stem, 'subject' => $text,
87 'to' => $text,
88 'from' => $text,
89 ]
90 );
91 die "Couldn't create table $OPT{table}: $@\n" unless $tb;
92
93 my ($did, $value);
94 while (($did, $value) = each %D) {
95 my $record = $layout->split($value);
96 my $headline = $record->{subject};
97 $headline =~ s/\s+/ /sg;
98 printf "%s\n", substr($headline,0,80);
99 $tb->insert('docid' => $did,
100 headline => $headline,
101 %{$record});
102 }
103 $tb->set(top=>1);
104 $tb->close();
105 $db->close();
106
107 $WAIT::Config = $WAIT::Config; # make perl -w happy
108
109
110 __END__
111 ## ###################################################################
112 ## pod
113 ## ###################################################################
114
115 =head1 NAME
116
117 index_mail - generate an WAIT index for .overview files
118
119 =head1 SYNOPSIS
120
121 B<index_mail>
122 [B<-clean>] [B<-noclean>]
123 [B<-database> I<dbname>]
124 [B<-dir> I<directory>]
125 [B<-table> I<table name>]
126
127 =head1 DESCRIPTION
128
129 Either indexes F<$WAIT/t/test.ste> (if called from directory F<$WAIT>)
130 or F</usr/local/ls6/tex/bib/bibdb.ste>.
131
132 =head1 OPTIONS
133
134 =over 5
135
136 =item B<-clean> / B<-noclean>
137
138 Clean the table before indexing. Default is B<off>.
139
140 =item B<-database> I<dbname>
141
142 Specify database name. Default is F<DB>.
143
144 =item B<-dir> I<directory>
145
146 Alternate directory where databases are located. Default is the
147 directory specified during configuration of WAIT.
148
149 =item B<-table> I<table name>
150
151 Specify an alternate table name. Default is C<bibdb>.
152
153 =head1 AUTHOR
154
155 Ulrich Pfeifer E<lt>F<pfeifer@wait.de>E<gt>
156

Properties

Name Value
cvs2svn:cvs-rev 1.1

  ViewVC Help
Powered by ViewVC 1.1.26