/[pgestraier]/trunk/data/indexer.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/data/indexer.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 86 - (hide annotations)
Wed Apr 18 15:55:47 2007 UTC (17 years ago) by dpavlin
File MIME type: text/plain
File size: 1197 byte(s)
support for multiple quotes
1 dpavlin 29 #!/usr/bin/perl -w
2    
3     use strict;
4 dpavlin 52 use Search::Estraier 0.06;
5 dpavlin 83 use parse_trivia;
6 dpavlin 29
7     # score for words in title
8     my $title_rank = 3;
9    
10     open(my $t, "gzip -cd trivia.list.gz |") || die "can't open trivia.list.gz: $!";
11    
12 dpavlin 41 # open node
13 dpavlin 50 my $node = Search::Estraier::Node->new(
14     url => 'http://localhost:1978/node/trivia',
15     user => 'admin',
16     passwd => 'admin',
17 dpavlin 52 create => 1,
18 dpavlin 50 );
19 dpavlin 29
20 dpavlin 83 my $nr = 1;
21 dpavlin 86 my $max = 0; # no limit
22 dpavlin 29
23 dpavlin 83 parse_trivia($t, sub {
24 dpavlin 29
25 dpavlin 83 my $a = {@_};
26 dpavlin 29
27     # create a document object
28 dpavlin 50 my $doc = Search::Estraier::Document->new;
29 dpavlin 29
30     # add attributes to the document object
31 dpavlin 83 $doc->add_attr('@uri', "file://localhost/trivia/$nr");
32 dpavlin 30
33 dpavlin 83 $doc->add_attr('@title', $a->{title});
34 dpavlin 30 $doc->add_hidden_text(
35 dpavlin 83 (($a->{title} . ' ') x $title_rank)
36 dpavlin 30 );
37    
38 dpavlin 83 $doc->add_attr('@size', length($a->{trivia}));
39 dpavlin 29
40 dpavlin 83 $doc->add_attr('year', $a->{year}) if ($a->{year});
41     foreach my $q ( $a->{qv} ) {
42 dpavlin 86 $q = join(' ', @$q) if (ref($q) eq 'ARRAY');
43     next unless ($q);
44 dpavlin 29 $doc->add_attr('quote', $q);
45     $doc->add_hidden_text($q);
46     }
47    
48     # add the body text to the document object
49 dpavlin 83 $doc->add_text($a->{trivia});
50 dpavlin 29
51     # register the document object to the database
52 dpavlin 41 $node->put_doc($doc);
53 dpavlin 29
54 dpavlin 86 $nr++;
55     last if ($max && $nr > $max);
56    
57 dpavlin 83 });

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26