/[mws]/trunk/mbox2index.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 /trunk/mbox2index.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Mon May 3 20:40:40 2004 UTC (20 years ago) by dpavlin
File MIME type: text/plain
File size: 1034 byte(s)
initial import of MailBox Web Search project
(working primitive indexing and command-line sarching)

1 dpavlin 1 #!/usr/bin/perl -w
2    
3     use Mail::Box::Manager;
4     use Plucene::Simple;
5     use Data::Dumper;
6    
7     my $mbox="test";
8     my $index = Plucene::Simple->open( "index" ) || die "can't open index: $!";
9    
10     my $mgr = Mail::Box::Manager->new;
11     my $folder = $mgr->open($mbox);
12     foreach my $message ($folder->messages) {
13    
14     my $id = $message->messageId;
15     print "## $id\n";
16    
17     my $document = {
18     id => $id,
19     folder => $mbox,
20     };
21    
22    
23    
24     foreach my $direction (qw(to from cc bcc)) {
25     foreach my $f ($message->$direction) {
26     print "$direction: ";
27     foreach my $part (qw(phrase address comment)) {
28     next if (! $f->$part);
29     print "[$part]",$f->$part," ";
30     $document->{$direction.'_'.$part} .= $f->$part."\n";
31     }
32     print "\n";
33     # push @{$document->$d.'_phrase'}, $f->phrase,
34     # push @{$document->$d.'_address'}, $f->address,
35     ## push @{$document->$d.'_comment'}, $f->comment,
36     }
37     }
38    
39     $document->{'subject'} = $message->get('Subject') || 'no subject';
40    
41     print Dumper($document);
42     $index->add("$mbox $id" => $document);
43    
44     }
45    
46     $folder->close;
47     $index->optimize;

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26