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; |
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; |
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; |
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); |
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 = (); |
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); |