/[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

Diff of /trunk/data/indexer.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 29 by dpavlin, Wed Jul 6 11:47:56 2005 UTC revision 41 by dpavlin, Sat Sep 10 20:35:09 2005 UTC
# Line 11  open(my $t, "gzip -cd trivia.list.gz |") Line 11  open(my $t, "gzip -cd trivia.list.gz |")
11  # open the database  # open the database
12  my $db = HyperEstraier::Database->new();  my $db = HyperEstraier::Database->new();
13  $db->open('casket', $HyperEstraier::Database::DBWRITER | $HyperEstraier::Database::DBCREAT);  $db->open('casket', $HyperEstraier::Database::DBWRITER | $HyperEstraier::Database::DBCREAT);
14    # open node
15    my $node = HyperEstraier::Node->new("http://localhost:1978/node/trivia");
16    $node->set_auth('admin', 'admin');
17    
18    
19  my $header = 1;  my $header = 1;
# Line 31  sub qv { Line 34  sub qv {
34                  $all_quotes->{$v}++;                  $all_quotes->{$v}++;
35                  return '';                  return '';
36          }          }
37          $t =~ s#([_'])([^_']+?)\1 \(qv\)#qv_print($2)#ge;          $t =~ s#([_'"])([^_'"]+?)\1 \(qv\)#qv_print($2)#ge;
38  }  }
39    
40  my $i = 0;  my $i = 0;
# Line 46  while(<$t>) { Line 49  while(<$t>) {
49          if (/^#\s+(.*)\s*$/) {          if (/^#\s+(.*)\s*$/) {
50                  $title = $1;                  $title = $1;
51                  if ($title =~ m#^("*)(.*)\1\s*\((\d+)\)(:?\s*\(\w+\))*$#) {                  if ($title =~ m#^("*)(.*)\1\s*\((\d+)\)(:?\s*\(\w+\))*$#) {
52                          $year = $3;                          ($title, $year) = ($2,$3);
53                          $all_titles->{$2}++;                          $all_titles->{$title}++;
54                          $all_years->{$3}++;                          $all_years->{$3}++;
55                  } else {                  } else {
56                          $year = undef;                          $year = undef;
# Line 72  while(<$t>) { Line 75  while(<$t>) {
75    
76                  # add attributes to the document object                  # add attributes to the document object
77                  $doc->add_attr('@uri', "file://localhost/trivia/$i");                  $doc->add_attr('@uri', "file://localhost/trivia/$i");
78    
79                  $doc->add_attr('@title', $title);                  $doc->add_attr('@title', $title);
80                    $doc->add_hidden_text(
81                            ($title x $title_rank)
82                    );
83    
84                  $doc->add_attr('@size', length($trivia));                  $doc->add_attr('@size', length($trivia));
85    
86                  $doc->add_attr('year', $year) if ($year);                  $doc->add_attr('year', $year) if ($year);
# Line 83  while(<$t>) { Line 91  while(<$t>) {
91    
92                  # add the body text to the document object                  # add the body text to the document object
93                  $doc->add_text($trivia);                  $doc->add_text($trivia);
                 $doc->add_hidden_text(  
                         ($title x $title_rank)  
                 );  
94    
95    
96                  # register the document object to the database                  # register the document object to the database
97                  $db->put_doc($doc, $HyperEstraier::Database::PDCLEAN);                  $db->put_doc($doc, $HyperEstraier::Database::PDCLEAN);
98                    $node->put_doc($doc);
99    
100                  $trivia = '';                  $trivia = '';
101                  @qv = ();                  @qv = ();
# Line 117  dump_data('titles.data', $all_titles); Line 123  dump_data('titles.data', $all_titles);
123  dump_data('quotes.data', $all_quotes);  dump_data('quotes.data', $all_quotes);
124  dump_data('years.data', $all_years);  dump_data('years.data', $all_years);
125    
126    $db->sync();
127    
128  #print "\noptimizing...\n";  #print "\noptimizing...\n";
129  #$db->optimize(0);  #$db->optimize(0);

Legend:
Removed from v.29  
changed lines
  Added in v.41

  ViewVC Help
Powered by ViewVC 1.1.26