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

Annotation of /trunk/script/search_mail

Parent Directory Parent Directory | Revision Log Revision Log


Revision 49 - (hide annotations)
Fri Dec 29 16:57:55 2000 UTC (23 years, 4 months ago) by ulpfr
Original Path: cvs-head/script/search_mail
File size: 2471 byte(s)
Works with modified nnir.el.

1 ulpfr 49 #!/usr/bin/perl -w
2     # -*- Mode: Perl -*-
3     # $Basename: sman $
4     # $Revision: 1.1 $
5     # Author : Ulrich Pfeifer
6     # Created On : Fri Aug 30 15:52:25 1996
7     # Last Modified By: Ulrich Pfeifer
8     # Last Modified On: Fri Dec 29 17:46:52 2000
9     # Language : CPerl
10     #
11     # (C) Copyright 1996-2000, Ulrich Pfeifer
12     #
13    
14     use strict;
15    
16     use Getopt::Long;
17     use Fcntl;
18     use Config;
19    
20     require WAIT::Config;
21     require WAIT::Database;
22     require WAIT::Query::Base;
23     require WAIT::Query::Wais;
24    
25     my %OPT = (database => 'DB',
26     dir => $WAIT::Config->{WAIT_home} || '/tmp',
27     table => 'mail',
28     pager => $WAIT::Config->{'pager'} || 'more',
29     filter => 0,
30     max => 15,
31     );
32    
33     GetOptions(\%OPT,
34     'database=s',
35     'dir=s',
36     'table=s',
37     'filter=i',
38     'max=i',
39     'pager:s') || die "Usage: ...\n";
40    
41     my $db = WAIT::Database->open(name => $OPT{database},
42     mode => O_RDONLY,
43     directory => $OPT{dir})
44     or die "Could not open database $OPT{database}: $@";
45    
46     my $tb = $db->table(name => $OPT{table})
47     or die "Could not open table $OPT{table}: $@";
48    
49     # not used: my $layout = $tb->layout; # a WAIT::Parse::Nroff object
50    
51     my($query, @did);
52    
53     my(%hits, $query_text);
54     $query_text = join ' ',@ARGV;
55     eval {$query = WAIT::Query::Wais::query($tb, $query_text)};
56     if ($@ ne '') {
57     print "$_ => $query\n\$\@='$@'\n";
58     } elsif (ref($query)) {
59     %hits = $query->execute(top => $OPT{max}, picky => 1);
60     # the hash %hits has as keys document numbers and as values
61     # quality figures. The doc numbers are not what we have as docid
62     # to find the item in the access class, they are WAIT's private
63     # numbers.
64     }
65    
66     exit 1 unless %hits;
67     my $no = 1; # numbering the hits for the result table that is
68     # presented to the user
69    
70     for my $did (sort {$hits{$b} <=> $hits{$a}} keys %hits) {
71    
72     my %tattr = $tb->fetch($did);
73     # the hash %tattr contains several attributes of the item we are
74     # referring to, namely the attributes that we named in the "attr"
75     # argument of the create_table statement in smakewhatis
76    
77     #printf "%2d %6.3f %s\n", $no, $hits{$did},
78     # substr($tattr{headline} ||'',0,68);
79     #$did[$no] = $did;
80     $tattr{docid} =~ /(.*)\/.overview \d+ \d+$/;
81     printf "Score: %d '%d %s/'\n",
82     $hits{$did} * 100, $tattr{article}, $1;
83     last if $no++ >= $OPT{max};
84     }
85    
86    
87     $tb->close;
88     $db->close;
89    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26