1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use strict; |
use strict; |
4 |
use HyperEstraier; |
use Search::Estraier 0.06; |
5 |
|
|
6 |
# score for words in title |
# score for words in title |
7 |
my $title_rank = 3; |
my $title_rank = 3; |
8 |
|
|
9 |
open(my $t, "gzip -cd trivia.list.gz |") || die "can't open trivia.list.gz: $!"; |
open(my $t, "gzip -cd trivia.list.gz |") || die "can't open trivia.list.gz: $!"; |
10 |
|
|
11 |
# open the database |
# open node |
12 |
my $db = HyperEstraier::Database->new(); |
my $node = Search::Estraier::Node->new( |
13 |
$db->open('casket', $HyperEstraier::Database::DBWRITER | $HyperEstraier::Database::DBCREAT); |
url => 'http://localhost:1978/node/trivia', |
14 |
|
user => 'admin', |
15 |
|
passwd => 'admin', |
16 |
|
create => 1, |
17 |
|
); |
18 |
|
|
19 |
|
|
20 |
my $header = 1; |
my $header = 1; |
35 |
$all_quotes->{$v}++; |
$all_quotes->{$v}++; |
36 |
return ''; |
return ''; |
37 |
} |
} |
38 |
$t =~ s#([_'])([^_']+?)\1 \(qv\)#qv_print($2)#ge; |
$t =~ s#([_'"])([^_'"]+?)\1 \(qv\)#qv_print($2)#ge; |
39 |
} |
} |
40 |
|
|
41 |
my $i = 0; |
my $i = 0; |
50 |
if (/^#\s+(.*)\s*$/) { |
if (/^#\s+(.*)\s*$/) { |
51 |
$title = $1; |
$title = $1; |
52 |
if ($title =~ m#^("*)(.*)\1\s*\((\d+)\)(:?\s*\(\w+\))*$#) { |
if ($title =~ m#^("*)(.*)\1\s*\((\d+)\)(:?\s*\(\w+\))*$#) { |
53 |
$year = $3; |
($title, $year) = ($2,$3); |
54 |
$all_titles->{$2}++; |
$all_titles->{$title}++; |
55 |
$all_years->{$3}++; |
$all_years->{$3}++; |
56 |
} else { |
} else { |
57 |
$year = undef; |
$year = undef; |
72 |
print "$i "; |
print "$i "; |
73 |
|
|
74 |
# create a document object |
# create a document object |
75 |
my $doc = HyperEstraier::Document->new; |
my $doc = Search::Estraier::Document->new; |
76 |
|
|
77 |
# add attributes to the document object |
# add attributes to the document object |
78 |
$doc->add_attr('@uri', "file://localhost/trivia/$i"); |
$doc->add_attr('@uri', "file://localhost/trivia/$i"); |
79 |
|
|
80 |
$doc->add_attr('@title', $title); |
$doc->add_attr('@title', $title); |
81 |
|
$doc->add_hidden_text( |
82 |
|
($title x $title_rank) |
83 |
|
); |
84 |
|
|
85 |
$doc->add_attr('@size', length($trivia)); |
$doc->add_attr('@size', length($trivia)); |
86 |
|
|
87 |
$doc->add_attr('year', $year) if ($year); |
$doc->add_attr('year', $year) if ($year); |
92 |
|
|
93 |
# add the body text to the document object |
# add the body text to the document object |
94 |
$doc->add_text($trivia); |
$doc->add_text($trivia); |
|
$doc->add_hidden_text( |
|
|
($title x $title_rank) |
|
|
); |
|
95 |
|
|
96 |
|
|
97 |
# register the document object to the database |
# register the document object to the database |
98 |
$db->put_doc($doc, $HyperEstraier::Database::PDCLEAN); |
$node->put_doc($doc); |
99 |
|
|
100 |
$trivia = ''; |
$trivia = ''; |
101 |
@qv = (); |
@qv = (); |
119 |
close($fh); |
close($fh); |
120 |
} |
} |
121 |
|
|
122 |
dump_data('titles.data', $all_titles); |
#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 |
|
|
|
#print "\noptimizing...\n"; |
|
|
#$db->optimize(0); |
|