1 | ###########################################################################
|
---|
2 | #
|
---|
3 | # mgppbuilder.pm -- MGBuilder object
|
---|
4 | # A component of the Greenstone digital library software
|
---|
5 | # from the New Zealand Digital Library Project at the
|
---|
6 | # University of Waikato, New Zealand.
|
---|
7 | #
|
---|
8 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
9 | #
|
---|
10 | # This program is free software; you can redistribute it and/or modify
|
---|
11 | # it under the terms of the GNU General Public License as published by
|
---|
12 | # the Free Software Foundation; either version 2 of the License, or
|
---|
13 | # (at your option) any later version.
|
---|
14 | #
|
---|
15 | # This program is distributed in the hope that it will be useful,
|
---|
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | # GNU General Public License for more details.
|
---|
19 | #
|
---|
20 | # You should have received a copy of the GNU General Public License
|
---|
21 | # along with this program; if not, write to the Free Software
|
---|
22 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
23 | #
|
---|
24 | ###########################################################################
|
---|
25 |
|
---|
26 | package mgppbuilder;
|
---|
27 |
|
---|
28 | use basebuilder;
|
---|
29 | use classify;
|
---|
30 | use cfgread;
|
---|
31 | use colcfg;
|
---|
32 | use plugin;
|
---|
33 | use util;
|
---|
34 | use FileHandle;
|
---|
35 |
|
---|
36 | sub BEGIN {
|
---|
37 | @mgppbuilder::ISA = ('basebuilder');
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 | our %level_map = ('document'=>'Doc',
|
---|
43 | 'section'=>'Sec',
|
---|
44 | 'paragraph'=>'Para',
|
---|
45 | 'Doc'=>'_textdocument_',
|
---|
46 | 'Sec'=>'_textsection_',
|
---|
47 | 'Para'=>'_textparagraph_');
|
---|
48 |
|
---|
49 | #$doc_level = "Doc";
|
---|
50 | #$sec_level = "Sec";
|
---|
51 | #$para_level = "Para";
|
---|
52 |
|
---|
53 | our %wanted_index_files = ('td'=>1,
|
---|
54 | 't'=>1,
|
---|
55 | 'tl'=>1,
|
---|
56 | 'ti'=>1,
|
---|
57 | 'idb'=>1,
|
---|
58 | 'ib1'=>1,
|
---|
59 | 'ib2'=>1,
|
---|
60 | 'ib3'=>1,
|
---|
61 | 'i'=>1,
|
---|
62 | 'il'=>1,
|
---|
63 | 'w'=>1,
|
---|
64 | 'wa'=>1);
|
---|
65 |
|
---|
66 | # change this so a user can add their own ones in via a file or cfg
|
---|
67 | #add AND, OR, NOT NEAR to this list - these cannot be used as field names
|
---|
68 | #also add the level names (Doc, Sec, Para)
|
---|
69 | our %static_indexfield_map = ('Title'=>'TI',
|
---|
70 | 'TI'=>1,
|
---|
71 | 'Subject'=>'SU',
|
---|
72 | 'SU'=>1,
|
---|
73 | 'Creator'=>'CR',
|
---|
74 | 'CR'=>1,
|
---|
75 | 'Organization'=>'ORG',
|
---|
76 | 'ORG'=>1,
|
---|
77 | 'Source'=>'SO',
|
---|
78 | 'SO'=>1,
|
---|
79 | 'Howto'=>'HT',
|
---|
80 | 'HT'=>1,
|
---|
81 | 'ItemTitle'=>'IT',
|
---|
82 | 'IT'=>1,
|
---|
83 | 'ProgNumber'=>'PN',
|
---|
84 | 'PN'=>1,
|
---|
85 | 'People'=>'PE',
|
---|
86 | 'PE'=>1,
|
---|
87 | 'Coverage'=>'CO',
|
---|
88 | 'CO'=>1,
|
---|
89 | 'allfields'=>'ZZ',
|
---|
90 | 'ZZ'=>1,
|
---|
91 | 'text'=>'TX',
|
---|
92 | 'TX'=>1,
|
---|
93 | 'AND'=>1,
|
---|
94 | 'OR'=>1,
|
---|
95 | 'NOT'=>1,
|
---|
96 | 'NEAR'=>1,
|
---|
97 | 'Doc'=>1,
|
---|
98 | 'Sec'=>1,
|
---|
99 | 'Para'=>1);
|
---|
100 |
|
---|
101 | my $maxdocsize = $basebuilder::maxdocsize;
|
---|
102 |
|
---|
103 | sub new {
|
---|
104 | my $class = shift(@_);
|
---|
105 |
|
---|
106 | my ($collection, $source_dir, $build_dir, $verbosity,
|
---|
107 | $maxdocs, $debug, $keepold, $remove_empty_classifications,
|
---|
108 | $outhandle, $no_text, $failhandle, $gli) = @_;
|
---|
109 |
|
---|
110 | my $self = new basebuilder (@_);
|
---|
111 | $self = bless $self, $class;
|
---|
112 |
|
---|
113 | $self->{'indexfieldmap'} = \%static_indexfield_map;
|
---|
114 |
|
---|
115 | # get the levels (Section, Paragraph) for indexing and compression
|
---|
116 | $self->{'levels'} = {};
|
---|
117 | $self->{'levelorder'} = ();
|
---|
118 | if (defined $self->{'collect_cfg'}->{'levels'}) {
|
---|
119 | foreach my $level ( @{$self->{'collect_cfg'}->{'levels'}} ){
|
---|
120 | $level =~ tr/A-Z/a-z/;
|
---|
121 | $self->{'levels'}->{$level} = 1;
|
---|
122 | push (@{$self->{'levelorder'}}, $level);
|
---|
123 | }
|
---|
124 | } else { # default to document
|
---|
125 | $self->{'levels'}->{'document'} = 1;
|
---|
126 | push (@{$self->{'levelorder'}}, 'document');
|
---|
127 | }
|
---|
128 |
|
---|
129 | $self->{'doc_level'} = "document";
|
---|
130 | if (! $self->{'levels'}->{'document'}) {
|
---|
131 | if ($self->{'levels'}->{'section'}) {
|
---|
132 | $self->{'doc_level'} = "section";
|
---|
133 | } else {
|
---|
134 | die "you must have either document or section level specified!!\n";
|
---|
135 | }
|
---|
136 | }
|
---|
137 |
|
---|
138 | $self->{'buildtype'} = "mgpp";
|
---|
139 |
|
---|
140 | return $self;
|
---|
141 | }
|
---|
142 |
|
---|
143 | sub generate_index_list {
|
---|
144 | my $self = shift (@_);
|
---|
145 |
|
---|
146 | # sort out the indexes
|
---|
147 | #indexes are specified with spaces, but we put them into one index
|
---|
148 | my $indexes = $self->{'collect_cfg'}->{'indexes'};
|
---|
149 | $self->{'collect_cfg'}->{'indexes'} = [];
|
---|
150 | push (@{$self->{'collect_cfg'}->{'indexes'}}, join(',', @$indexes));
|
---|
151 | }
|
---|
152 |
|
---|
153 | sub default_buildproc {
|
---|
154 | my $self = shift (@_);
|
---|
155 |
|
---|
156 | return "mgppbuildproc";
|
---|
157 | }
|
---|
158 |
|
---|
159 | sub compress_text {
|
---|
160 |
|
---|
161 | my $self = shift (@_);
|
---|
162 | my ($textindex) = @_;
|
---|
163 |
|
---|
164 | my $exedir = "$ENV{'GSDLHOME'}/bin/$ENV{'GSDLOS'}";
|
---|
165 | my $exe = &util::get_os_exe ();
|
---|
166 | my $mgpp_passes_exe = &util::filename_cat($exedir, "mgpp_passes$exe");
|
---|
167 | my $mgpp_compression_dict_exe = &util::filename_cat($exedir, "mgpp_compression_dict$exe");
|
---|
168 | my $outhandle = $self->{'outhandle'};
|
---|
169 |
|
---|
170 | &util::mk_all_dir (&util::filename_cat($self->{'build_dir'}, "text"));
|
---|
171 |
|
---|
172 | my $basefilename = "text/$self->{'collection'}";
|
---|
173 | my $fulltextprefix = &util::filename_cat ($self->{'build_dir'}, $basefilename);
|
---|
174 |
|
---|
175 | my $osextra = "";
|
---|
176 | if ($ENV{'GSDLOS'} =~ /^windows$/i) {
|
---|
177 | $fulltextprefix =~ s@/@\\@g;
|
---|
178 | }
|
---|
179 | else {
|
---|
180 | $osextra = " -d /";
|
---|
181 | }
|
---|
182 |
|
---|
183 |
|
---|
184 | # define the section names and possibly the doc name for mgpasses
|
---|
185 | # the compressor doesn't need to know about paragraphs - never want to
|
---|
186 | # retrieve them
|
---|
187 | my $mgpp_passes_sections = "";
|
---|
188 | my ($doc_level) = $self->{'doc_level'};
|
---|
189 | $mgpp_passes_sections .= "-J " . $level_map{$doc_level} . " ";
|
---|
190 | foreach my $level (keys %{$self->{'levels'}}) {
|
---|
191 | if ($level ne $doc_level && $level ne "paragraph") {
|
---|
192 | $mgpp_passes_sections .= "-K " . $level_map{$level} . " ";
|
---|
193 | }
|
---|
194 | }
|
---|
195 | $mgpp_passes_sections .= "-K SENT ";
|
---|
196 | print $outhandle "\n*** creating the compressed text\n" if ($self->{'verbosity'} >= 1);
|
---|
197 | print STDERR "<Stage name='CompressText'>\n" if $self->{'gli'};
|
---|
198 |
|
---|
199 | # collect the statistics for the text
|
---|
200 | # -b $maxdocsize sets the maximum document size to be 12 meg
|
---|
201 | print $outhandle "\n collecting text statistics (mgpp_passes -T1)\n" if ($self->{'verbosity'} >= 1);
|
---|
202 | print STDERR "<Phase name='CollectTextStats'/>\n" if $self->{'gli'};
|
---|
203 |
|
---|
204 | my ($handle);
|
---|
205 | if ($self->{'debug'}) {
|
---|
206 | $handle = STDOUT;
|
---|
207 | } else {
|
---|
208 | #print $outhandle "trying to run (compress 1) mgpp_passes$exe $mgpp_passes_sections -f \"$fulltextprefix\" -T1 $osextra\n";
|
---|
209 | if (!-e "$mgpp_passes_exe" ||
|
---|
210 | !open (PIPEOUT, "| mgpp_passes$exe $mgpp_passes_sections -f \"$fulltextprefix\" -T1 $osextra")) {
|
---|
211 | print STDERR "<FatalError name='NoRunMGPasses'>\n</Stage>\n" if $self->{'gli'};
|
---|
212 | die "mgppbuilder::compress_text - couldn't run $mgpp_passes_exe\n";
|
---|
213 | }
|
---|
214 | $handle = mgppbuilder::PIPEOUT;
|
---|
215 | }
|
---|
216 |
|
---|
217 | # gdbm_level
|
---|
218 | my $gdbm_level = "document";
|
---|
219 | if ($self->{'levels'}->{'section'}) {
|
---|
220 | $gdbm_level = "section";
|
---|
221 | }
|
---|
222 |
|
---|
223 | $self->{'buildproc'}->set_output_handle ($handle);
|
---|
224 | $self->{'buildproc'}->set_mode ('text');
|
---|
225 | $self->{'buildproc'}->set_index ($textindex);
|
---|
226 | $self->{'buildproc'}->set_indexing_text (0);
|
---|
227 | if ($self->{'no_text'}) {
|
---|
228 | $self->{'buildproc'}->set_store_text(0);
|
---|
229 | } else {
|
---|
230 | $self->{'buildproc'}->set_store_text(1);
|
---|
231 | }
|
---|
232 | $self->{'buildproc'}->set_indexfieldmap ($self->{'indexfieldmap'});
|
---|
233 | $self->{'buildproc'}->set_levels ($self->{'levels'});
|
---|
234 | $self->{'buildproc'}->set_gdbm_level ($gdbm_level);
|
---|
235 | $self->{'buildproc'}->reset();
|
---|
236 | &plugin::begin($self->{'pluginfo'}, $self->{'source_dir'},
|
---|
237 | $self->{'buildproc'}, $self->{'maxdocs'});
|
---|
238 | &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
|
---|
239 | "", {}, $self->{'buildproc'}, $self->{'maxdocs'}, 0, $self->{'gli'});
|
---|
240 | &plugin::end($self->{'pluginfo'});
|
---|
241 | close (PIPEOUT);
|
---|
242 |
|
---|
243 | close ($handle) unless $self->{'debug'};
|
---|
244 |
|
---|
245 | $self->print_stats();
|
---|
246 |
|
---|
247 | # create the compression dictionary
|
---|
248 | # the compression dictionary is built by assuming the stats are from a seed
|
---|
249 | # dictionary (-S), if a novel word is encountered it is spelled out (-H),
|
---|
250 | # and the resulting dictionary must be less than 5 meg with the most
|
---|
251 | # frequent words being put into the dictionary first (-2 -k 5120)
|
---|
252 | # note: these options are left over from mg version
|
---|
253 | if (!$self->{'debug'}) {
|
---|
254 | print $outhandle "\n creating the compression dictionary\n" if ($self->{'verbosity'} >= 1);
|
---|
255 | print STDERR "<Phase name='CreatingCompress'/>\n" if $self->{'gli'};
|
---|
256 | if (!-e "$mgpp_compression_dict_exe") {
|
---|
257 | print STDERR "<FatalError name='NoRunMGCompress'/>\n</Stage>\n" if $self->{'gli'};
|
---|
258 | die "mgppbuilder::compress_text - couldn't run $mgpp_compression_dict_exe\n";
|
---|
259 | }
|
---|
260 | system ("mgpp_compression_dict$exe -f \"$fulltextprefix\" -S -H -2 -k 5120 $osextra");
|
---|
261 |
|
---|
262 | if (!$self->{'debug'}) {
|
---|
263 | #print $outhandle "trying to run (compress 2) mgpp_passes$exe $mgpp_passes_sections -f \"$fulltextprefix\" -T2 $osextra\n";
|
---|
264 | if (!-e "$mgpp_passes_exe" ||
|
---|
265 | !open ($handle, "| mgpp_passes$exe $mgpp_passes_sections -f \"$fulltextprefix\" -T2 $osextra")) {
|
---|
266 | print STDERR "<FatalError name='NoRunMGPasses'/>\n</Stage>\n" if $self->{'gli'};
|
---|
267 | die "mgppbuilder::compress_text - couldn't run $mgpp_passes_exe\n";
|
---|
268 | }
|
---|
269 | }
|
---|
270 | }
|
---|
271 | else {
|
---|
272 | print STDERR "<Phase name='SkipCreatingComp'/>\n" if $self->{'gli'};
|
---|
273 | }
|
---|
274 |
|
---|
275 | $self->{'buildproc'}->reset();
|
---|
276 | # compress the text
|
---|
277 | print $outhandle "\n compressing the text (mgpp_passes -T2)\n" if ($self->{'verbosity'} >= 1);
|
---|
278 | print STDERR "<Phase name='CompressingText'/>\n" if $self->{'gli'};
|
---|
279 |
|
---|
280 | &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
|
---|
281 | "", {}, $self->{'buildproc'}, $self->{'maxdocs'}, 0, $self->{'gli'});
|
---|
282 | close ($handle) unless $self->{'debug'};
|
---|
283 |
|
---|
284 | $self->print_stats();
|
---|
285 | print STDERR "</Stage>\n" if $self->{'gli'};
|
---|
286 | }
|
---|
287 |
|
---|
288 |
|
---|
289 | sub build_indexes_extra {
|
---|
290 | my $self = shift(@_);
|
---|
291 | #define the final field lists
|
---|
292 | $self->make_final_field_list();
|
---|
293 | }
|
---|
294 |
|
---|
295 | # creates directory names for each of the index descriptions
|
---|
296 | sub create_index_mapping {
|
---|
297 | my $self = shift (@_);
|
---|
298 | my ($indexes) = @_;
|
---|
299 |
|
---|
300 | my %mapping = ();
|
---|
301 |
|
---|
302 | $mapping{'indexmaporder'} = [];
|
---|
303 | $mapping{'subcollectionmaporder'} = [];
|
---|
304 | $mapping{'languagemaporder'} = [];
|
---|
305 |
|
---|
306 | # dirnames is used to check for collisions. Start this off
|
---|
307 | # with the manditory directory names
|
---|
308 | my %dirnames = ('text'=>'text',
|
---|
309 | 'extra'=>'extra');
|
---|
310 | my %pnames = ('index' => {}, 'subcollection' => {}, 'languages' => {});
|
---|
311 |
|
---|
312 | foreach my $index (@$indexes) {
|
---|
313 | my ($fields, $subcollection, $languages) = split (":", $index);
|
---|
314 | # the directory name starts with a processed version of index fields
|
---|
315 | #my ($pindex) = $self->process_field($fields);
|
---|
316 | #$pindex = lc ($pindex);
|
---|
317 | # now we only ever have one index, and its called 'idx'
|
---|
318 | my $pindex = 'idx';
|
---|
319 |
|
---|
320 | # next comes a processed version of the subcollection if there is one.
|
---|
321 | my $psub = $self->process_field ($subcollection);
|
---|
322 | $psub = lc ($psub);
|
---|
323 |
|
---|
324 | # next comes a processed version of the language if there is one.
|
---|
325 | my $plang = $self->process_field ($languages);
|
---|
326 | $plang = lc ($plang);
|
---|
327 |
|
---|
328 | my $dirname = $pindex . $psub . $plang;
|
---|
329 |
|
---|
330 | # check to be sure all index names are unique
|
---|
331 | while (defined ($dirnames{$dirname})) {
|
---|
332 | $dirname = $self->make_unique (\%pnames, $index, \$pindex, \$psub, \$plang);
|
---|
333 | }
|
---|
334 |
|
---|
335 | $mapping{$index} = $dirname;
|
---|
336 |
|
---|
337 | # store the mapping orders as well as the maps
|
---|
338 | # also put index, subcollection and language fields into the mapping thing -
|
---|
339 | # (the full index name (eg text:subcol:lang) is not used on
|
---|
340 | # the query page) -these are used for collectionmeta later on
|
---|
341 | if (!defined $mapping{'indexmap'}{"$fields"}) {
|
---|
342 | $mapping{'indexmap'}{"$fields"} = $pindex;
|
---|
343 | push (@{$mapping{'indexmaporder'}}, "$fields");
|
---|
344 | if (!defined $mapping{"$fields"}) {
|
---|
345 | $mapping{"$fields"} = $pindex;
|
---|
346 | }
|
---|
347 | }
|
---|
348 | if ($psub =~ /\w/ && !defined ($mapping{'subcollectionmap'}{$subcollection})) {
|
---|
349 | $mapping{'subcollectionmap'}{$subcollection} = $psub;
|
---|
350 | push (@{$mapping{'subcollectionmaporder'}}, $subcollection);
|
---|
351 | $mapping{$subcollection} = $psub;
|
---|
352 | }
|
---|
353 | if ($plang =~ /\w/ && !defined ($mapping{'languagemap'}{$languages})) {
|
---|
354 | $mapping{'languagemap'}{$languages} = $plang;
|
---|
355 | push (@{$mapping{'languagemaporder'}}, $languages);
|
---|
356 | $mapping{$languages} = $plang;
|
---|
357 | }
|
---|
358 | $dirnames{$dirname} = $index;
|
---|
359 | $pnames{'index'}->{$pindex} = "$fields";
|
---|
360 | $pnames{'subcollection'}->{$psub} = $subcollection;
|
---|
361 | $pnames{'languages'}->{$plang} = $languages;
|
---|
362 | }
|
---|
363 |
|
---|
364 | return \%mapping;
|
---|
365 | }
|
---|
366 |
|
---|
367 | sub make_unique {
|
---|
368 | my $self = shift (@_);
|
---|
369 | my ($namehash, $index, $indexref, $subref, $langref) = @_;
|
---|
370 | my ($fields, $subcollection, $languages) = split (":", $index);
|
---|
371 |
|
---|
372 | if ($namehash->{'index'}->{$$indexref} ne "$fields") {
|
---|
373 | $self->get_next_version ($indexref);
|
---|
374 | } elsif ($namehash->{'subcollection'}->{$$subref} ne $subcollection) {
|
---|
375 | $self->get_next_version ($subref);
|
---|
376 | } elsif ($namehash->{'languages'}->{$$langref} ne $languages) {
|
---|
377 | $self->get_next_version ($langref);
|
---|
378 | }
|
---|
379 | return "$$indexref$$subref$$langref";
|
---|
380 | }
|
---|
381 |
|
---|
382 |
|
---|
383 | sub build_index {
|
---|
384 | my $self = shift (@_);
|
---|
385 | my ($index) = @_;
|
---|
386 | my $outhandle = $self->{'outhandle'};
|
---|
387 |
|
---|
388 | # get the full index directory path and make sure it exists
|
---|
389 | my $indexdir = $self->{'index_mapping'}->{$index};
|
---|
390 | &util::mk_all_dir (&util::filename_cat($self->{'build_dir'}, $indexdir));
|
---|
391 | my $fullindexprefix = &util::filename_cat ($self->{'build_dir'},
|
---|
392 | $indexdir,
|
---|
393 | $self->{'collection'});
|
---|
394 | my $fulltextprefix = &util::filename_cat ($self->{'build_dir'}, "text",
|
---|
395 | $self->{'collection'});
|
---|
396 |
|
---|
397 | # get any os specific stuff
|
---|
398 | my $exedir = "$ENV{'GSDLHOME'}/bin/$ENV{'GSDLOS'}";
|
---|
399 |
|
---|
400 | my $exe = &util::get_os_exe ();
|
---|
401 | my $mgpp_passes_exe = &util::filename_cat($exedir, "mgpp_passes$exe");
|
---|
402 |
|
---|
403 | # define the section names for mgpasses
|
---|
404 | # define the section names and possibly the doc name for mgpasses
|
---|
405 | my $mgpp_passes_sections = "";
|
---|
406 | my ($doc_level) = $self->{'doc_level'};
|
---|
407 | $mgpp_passes_sections .= "-J " . $level_map{$doc_level} ." ";
|
---|
408 |
|
---|
409 | foreach my $level (keys %{$self->{'levels'}}) {
|
---|
410 | if ($level ne $doc_level) {
|
---|
411 | $mgpp_passes_sections .= "-K " . $level_map{$level}. " ";
|
---|
412 | }
|
---|
413 | }
|
---|
414 |
|
---|
415 | my $mgpp_perf_hash_build_exe =
|
---|
416 | &util::filename_cat($exedir, "mgpp_perf_hash_build$exe");
|
---|
417 | my $mgpp_weights_build_exe =
|
---|
418 | &util::filename_cat ($exedir, "mgpp_weights_build$exe");
|
---|
419 | my $mgpp_invf_dict_exe =
|
---|
420 | &util::filename_cat ($exedir, "mgpp_invf_dict$exe");
|
---|
421 | my $mgpp_stem_idx_exe =
|
---|
422 | &util::filename_cat ($exedir, "mgpp_stem_idx$exe");
|
---|
423 |
|
---|
424 | my $osextra = "";
|
---|
425 | if ($ENV{'GSDLOS'} =~ /^windows$/i) {
|
---|
426 | $fullindexprefix =~ s@/@\\@g;
|
---|
427 | } else {
|
---|
428 | $osextra = " -d /";
|
---|
429 | if ($outhandle ne "STDERR") {
|
---|
430 | # so mgpp_passes doesn't print to stderr if we redirect output
|
---|
431 | $osextra .= " 2>/dev/null";
|
---|
432 | }
|
---|
433 | }
|
---|
434 |
|
---|
435 | # get the index expression if this index belongs
|
---|
436 | # to a subcollection
|
---|
437 | my $indexexparr = [];
|
---|
438 | my $langarr = [];
|
---|
439 | # there may be subcollection info, and language info.
|
---|
440 | my ($fields, $subcollection, $language) = split (":", $index);
|
---|
441 | my @subcollections = ();
|
---|
442 | @subcollections = split /,/, $subcollection if (defined $subcollection);
|
---|
443 |
|
---|
444 | foreach $subcollection (@subcollections) {
|
---|
445 | if (defined ($self->{'collect_cfg'}->{'subcollection'}->{$subcollection})) {
|
---|
446 | push (@$indexexparr, $self->{'collect_cfg'}->{'subcollection'}->{$subcollection});
|
---|
447 | }
|
---|
448 | }
|
---|
449 |
|
---|
450 | # add expressions for languages if this index belongs to
|
---|
451 | # a language subcollection - only put languages expressions for the
|
---|
452 | # ones we want in the index
|
---|
453 |
|
---|
454 | my @languages = ();
|
---|
455 | my $language_metadata = "Language";
|
---|
456 | if (defined ($self->{'collect_cfg'}->{'language_metadata'})) {
|
---|
457 | $language_metadata = $self->{'collect_cfg'}->{'language_metadata'};
|
---|
458 | }
|
---|
459 | @languages = split /,/, $language if (defined $language);
|
---|
460 | foreach my $language (@languages) {
|
---|
461 | my $not=0;
|
---|
462 | if ($language =~ s/^\!//) {
|
---|
463 | $not = 1;
|
---|
464 | }
|
---|
465 | if($not) {
|
---|
466 | push (@$langarr, "!$language");
|
---|
467 | } else {
|
---|
468 | push (@$langarr, "$language");
|
---|
469 | }
|
---|
470 | }
|
---|
471 |
|
---|
472 | # Build index dictionary. Uses verbatim stem method
|
---|
473 | print $outhandle "\n creating index dictionary (mgpp_passes -I1)\n" if ($self->{'verbosity'} >= 1);
|
---|
474 | print STDERR "<Phase name='CreatingIndexDic'/>\n" if $self->{'gli'};
|
---|
475 | my ($handle);
|
---|
476 | if ($self->{'debug'}) {
|
---|
477 | $handle = STDOUT;
|
---|
478 | } else {
|
---|
479 | if (!-e "$mgpp_passes_exe" ||
|
---|
480 | !open (PIPEOUT, "| mgpp_passes$exe $mgpp_passes_sections -f \"$fullindexprefix\" -I1 $osextra")) {
|
---|
481 | print STDERR "<FatalError name='NoRunMGPasses'/>\n</Stage>\n" if $self->{'gli'};
|
---|
482 | die "mgppbuilder::build_index - couldn't run $mgpp_passes_exe\n";
|
---|
483 | }
|
---|
484 | $handle = mgppbuilder::PIPEOUT;
|
---|
485 | }
|
---|
486 |
|
---|
487 | # gdbm_level
|
---|
488 | my $gdbm_level = "document";
|
---|
489 | if ($self->{'levels'}->{'section'}) {
|
---|
490 | $gdbm_level = "section";
|
---|
491 | }
|
---|
492 |
|
---|
493 | # set up the document processr
|
---|
494 | $self->{'buildproc'}->set_output_handle ($handle);
|
---|
495 | $self->{'buildproc'}->set_mode ('text');
|
---|
496 | $self->{'buildproc'}->set_index ($index, $indexexparr);
|
---|
497 | $self->{'buildproc'}->set_index_languages ($language_metadata, $langarr) if (defined $language);
|
---|
498 | $self->{'buildproc'}->set_indexing_text (1);
|
---|
499 | $self->{'buildproc'}->set_store_text(1);
|
---|
500 | $self->{'buildproc'}->set_indexfieldmap ($self->{'indexfieldmap'});
|
---|
501 | $self->{'buildproc'}->set_levels ($self->{'levels'});
|
---|
502 | $self->{'buildproc'}->set_gdbm_level ($gdbm_level);
|
---|
503 |
|
---|
504 | $self->{'buildproc'}->reset();
|
---|
505 | &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
|
---|
506 | "", {}, $self->{'buildproc'}, $self->{'maxdocs'}, 0, $self->{'gli'});
|
---|
507 | close ($handle) unless $self->{'debug'};
|
---|
508 |
|
---|
509 | $self->print_stats();
|
---|
510 |
|
---|
511 | # now we check to see if the required files have been produced - if not we quit building this index so the whole process doesn't crap out.
|
---|
512 | # we check on the .id file - index dictionary
|
---|
513 | my $dict_file = "$fullindexprefix.id";
|
---|
514 | if (!-e $dict_file) {
|
---|
515 | print $outhandle "mgppbuilder::build_index - Couldn't create index $index\n";
|
---|
516 | print STDERR "<Warning name='NoIndex'/>\n</Stage>\n" if $self->{'gli'};
|
---|
517 | $self->{'notbuilt'}->{$index}=1;
|
---|
518 | return;
|
---|
519 | }
|
---|
520 |
|
---|
521 | if (!$self->{'debug'}) {
|
---|
522 | # create the perfect hash function
|
---|
523 | if (!-e "$mgpp_perf_hash_build_exe") {
|
---|
524 | print STDERR "<FatalError name='NoRunMGHash'/>\n</Stage>\n" if $self->{'gli'};
|
---|
525 | die "mgppbuilder::build_index - couldn't run $mgpp_perf_hash_build_exe\n";
|
---|
526 | }
|
---|
527 | system ("mgpp_perf_hash_build$exe -f \"$fullindexprefix\" $osextra");
|
---|
528 |
|
---|
529 | if (!-e "$mgpp_passes_exe" ||
|
---|
530 | !open ($handle, "| mgpp_passes$exe $mgpp_passes_sections -f \"$fullindexprefix\" -I2 $osextra")) {
|
---|
531 | print STDERR "<FatalError name='NoRunMGPasses'/>\n</Stage>\n" if $self->{'gli'};
|
---|
532 | die "mgppbuilder::build_index - couldn't run $mgpp_passes_exe\n";
|
---|
533 | }
|
---|
534 | }
|
---|
535 |
|
---|
536 | # invert the text
|
---|
537 | print $outhandle "\n inverting the text (mgpp_passes -I2)\n" if ($self->{'verbosity'} >= 1);
|
---|
538 | print STDERR "<Phase name='InvertingText'/>\n" if $self->{'gli'};
|
---|
539 | $self->{'buildproc'}->reset();
|
---|
540 | &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
|
---|
541 | "", {}, $self->{'buildproc'}, $self->{'maxdocs'}, 0, $self->{'gli'});
|
---|
542 |
|
---|
543 | $self->print_stats ();
|
---|
544 |
|
---|
545 | if (!$self->{'debug'}) {
|
---|
546 |
|
---|
547 | close ($handle);
|
---|
548 |
|
---|
549 | # create the weights file
|
---|
550 | print $outhandle "\n create the weights file\n" if ($self->{'verbosity'} >= 1);
|
---|
551 | print STDERR "<Phase name='CreateTheWeights'/>\n" if $self->{'gli'};
|
---|
552 | if (!-e "$mgpp_weights_build_exe") {
|
---|
553 | print STDERR "<FatalError name='NoRunMGWeights'/>\n</Stage>\n" if $self->{'gli'};
|
---|
554 | die "mgppbuilder::build_index - couldn't run $mgpp_weights_build_exe\n";
|
---|
555 | }
|
---|
556 | system ("mgpp_weights_build$exe -f \"$fullindexprefix\" $osextra");
|
---|
557 |
|
---|
558 | # create 'on-disk' stemmed dictionary
|
---|
559 | print $outhandle "\n creating 'on-disk' stemmed dictionary\n" if ($self->{'verbosity'} >= 1);
|
---|
560 | if (!-e "$mgpp_invf_dict_exe") {
|
---|
561 | print STDERR "<FatalError name='NoRunMGInvf'/>\n</Stage>\n" if $self->{'gli'};
|
---|
562 | die "mgppbuilder::build_index - couldn't run $mgpp_invf_dict_exe\n";
|
---|
563 | }
|
---|
564 | system ("mgpp_invf_dict$exe -f \"$fullindexprefix\" $osextra" );
|
---|
565 |
|
---|
566 |
|
---|
567 | # creates stem index files for the various stemming methods
|
---|
568 | print $outhandle "\n creating stem indexes\n" if ($self->{'verbosity'} >= 1);
|
---|
569 | print STDERR "<Phase name='CreatingStemIndx'/>\n" if $self->{'gli'};
|
---|
570 | if (!-e "$mgpp_stem_idx_exe") {
|
---|
571 | print STDERR "<FatalError name='NoRunMGStem'/>\n</Stage>\n" if $self->{'gli'};
|
---|
572 | die "mgppbuilder::build_index - couldn't run $mgpp_stem_idx_exe\n";
|
---|
573 | }
|
---|
574 | system ("mgpp_stem_idx$exe -b 4096 -s1 -f \"$fullindexprefix\" $osextra");
|
---|
575 | system ("mgpp_stem_idx$exe -b 4096 -s2 -f \"$fullindexprefix\" $osextra");
|
---|
576 | system ("mgpp_stem_idx$exe -b 4096 -s3 -f \"$fullindexprefix\" $osextra");
|
---|
577 |
|
---|
578 | # remove unwanted files
|
---|
579 | my $tmpdir = &util::filename_cat ($self->{'build_dir'}, $indexdir);
|
---|
580 | opendir (DIR, $tmpdir) || die
|
---|
581 | "mgppbuilder::build_index - couldn't read directory $tmpdir\n";
|
---|
582 | foreach my $file (readdir(DIR)) {
|
---|
583 | next if $file =~ /^\./;
|
---|
584 | my ($suffix) = $file =~ /\.([^\.]+)$/;
|
---|
585 | if (defined $suffix && !defined $wanted_index_files{$suffix}) {
|
---|
586 | # delete it!
|
---|
587 | print $outhandle "deleting $file\n" if $self->{'verbosity'} > 2;
|
---|
588 | #&util::rm (&util::filename_cat ($tmpdir, $file));
|
---|
589 | }
|
---|
590 | }
|
---|
591 | closedir (DIR);
|
---|
592 | }
|
---|
593 | print STDERR "</Stage>\n" if $self->{'gli'};
|
---|
594 | }
|
---|
595 |
|
---|
596 |
|
---|
597 | sub output_collection_meta {
|
---|
598 | my $self = shift(@_);
|
---|
599 | my ($handle) = @_;
|
---|
600 |
|
---|
601 | # define the indexed field mapping if not already done so (ie if infodb called separately from build_index)
|
---|
602 | if (!defined $self->{'build_cfg'}) {
|
---|
603 | $self->read_final_field_list();
|
---|
604 | }
|
---|
605 |
|
---|
606 | # do the collection info
|
---|
607 | print $handle "[collection]\n";
|
---|
608 |
|
---|
609 | # first do the collection meta stuff - everything without a dot
|
---|
610 | my $collmetadefined = 0;
|
---|
611 | my $metadata_entry;
|
---|
612 | if (defined $self->{'collect_cfg'}->{'collectionmeta'}) {
|
---|
613 | $collmetadefined = 1;
|
---|
614 | foreach my $cmeta (keys (%{$self->{'collect_cfg'}->{'collectionmeta'}})) {
|
---|
615 | next if ($cmeta =~ /^\./); # for now, ignore ones with dots
|
---|
616 | $metadata_entry = $self->create_language_db_map($cmeta, $cmeta);
|
---|
617 | #write the entry to the file
|
---|
618 | print $handle $metadata_entry;
|
---|
619 |
|
---|
620 | } # foreach collmeta key
|
---|
621 | }
|
---|
622 | #add the index field macros to [collection]
|
---|
623 | # eg <TI>Title
|
---|
624 | # <SU>Subject
|
---|
625 | # these now come from collection meta. if that is not defined, usses the metadata name
|
---|
626 | my $field_entry="";
|
---|
627 | my $collmeta = "";
|
---|
628 | foreach my $longfield (@{$self->{'build_cfg'}->{'indexfields'}}){
|
---|
629 | my $shortfield = $self->{'buildproc'}->{'indexfieldmap'}->{$longfield};
|
---|
630 | next if $shortfield eq 1;
|
---|
631 |
|
---|
632 | # we need to check if some coll meta has been defined
|
---|
633 | $collmeta = ".$longfield";
|
---|
634 | if ($collmetadefined && defined $self->{'collect_cfg'}->{'collectionmeta'}->{$collmeta}) {
|
---|
635 | $metadata_entry = $self->create_language_db_map($collmeta, $shortfield);
|
---|
636 | $field_entry .= $metadata_entry;
|
---|
637 | } else { #use the metadata names, or the text macros for allfields and textonly
|
---|
638 | if ($longfield eq "allfields") {
|
---|
639 | $field_entry .= "<$shortfield>_query:textallfields_\n";
|
---|
640 | } elsif ($longfield eq "text") {
|
---|
641 | $field_entry .= "<$shortfield>_query:texttextonly_\n";
|
---|
642 | } else {
|
---|
643 | $field_entry .= "<$shortfield>$longfield\n";
|
---|
644 | }
|
---|
645 | }
|
---|
646 | }
|
---|
647 | print $handle $field_entry;
|
---|
648 |
|
---|
649 | # now add the level names
|
---|
650 | my $level_entry = "";
|
---|
651 | foreach my $level (@{$self->{'collect_cfg'}->{'levels'}}) {
|
---|
652 | $collmeta = ".$level"; # based on the original specification
|
---|
653 | $level =~ tr/A-Z/a-z/; # make it lower case
|
---|
654 | my $levelid = $level_map{$level}; # find the actual value we used in the index
|
---|
655 | if ($collmetadefined && defined $self->{'collect_cfg'}->{'collectionmeta'}->{$collmeta}) {
|
---|
656 | $metadata_entry = $self->create_language_db_map($collmeta, $levelid);
|
---|
657 | $level_entry .= $metadata_entry;
|
---|
658 | } else {
|
---|
659 | # use the default macro
|
---|
660 | $level_entry .= "<$levelid>" . $level_map{$levelid} . "\n";
|
---|
661 | }
|
---|
662 | }
|
---|
663 | print $handle $level_entry;
|
---|
664 |
|
---|
665 | # now add subcoll meta
|
---|
666 | my $subcoll_entry = "";
|
---|
667 | my $shortname = "";
|
---|
668 | my $one_entry = "";
|
---|
669 | foreach my $subcoll (@{$self->{'index_mapping'}->{'subcollectionmaporder'}}) {
|
---|
670 | if (defined $self->{'collect_cfg'}->{'collectionmeta'}->{".$subcoll"}) {
|
---|
671 | $shortname = $self->{'index_mapping'}->{$subcoll};
|
---|
672 | $one_entry = $self->create_language_db_map(".$subcoll", $shortname);
|
---|
673 | $subcoll_entry .= $one_entry;
|
---|
674 | } else {
|
---|
675 | $subcoll_entry .= "<$shortname>$subcoll\n";
|
---|
676 | }
|
---|
677 | }
|
---|
678 | print $handle $subcoll_entry;
|
---|
679 |
|
---|
680 | # now add language meta
|
---|
681 | my $lang_entry = "";
|
---|
682 | foreach my $lang (@{$self->{'index_mapping'}->{'languagemaporder'}}) {
|
---|
683 | if (defined $self->{'collect_cfg'}->{'collectionmeta'}->{".$lang"}) {
|
---|
684 | $shortname = $self->{'index_mapping'}->{$lang};
|
---|
685 | $one_entry = $self->create_language_db_map(".$lang", $shortname);
|
---|
686 | $lang_entry .= $one_entry;
|
---|
687 | } else {
|
---|
688 | $lang_entry .= "<$shortname>$lang\n";
|
---|
689 | }
|
---|
690 | }
|
---|
691 | print $handle $lang_entry;
|
---|
692 | # end the collection entry
|
---|
693 | print $handle "\n" . ('-' x 70) . "\n";
|
---|
694 |
|
---|
695 |
|
---|
696 | }
|
---|
697 | sub create_language_db_map {
|
---|
698 | my $self = shift (@_);
|
---|
699 | my ($metaname, $mapname) = @_;
|
---|
700 | my $outhandle = $self->{'outhandle'};
|
---|
701 | my $defaultfound=0;
|
---|
702 | my $first=1;
|
---|
703 | my $metadata_entry = "";
|
---|
704 | my $default="";
|
---|
705 | #iterate through the languages
|
---|
706 | foreach my $lang (keys (%{$self->{'collect_cfg'}->{'collectionmeta'}->{$metaname}})) {
|
---|
707 | if ($first) {
|
---|
708 | $first=0;
|
---|
709 | #set the default default to the first entry
|
---|
710 | $default=$self->{'collect_cfg'}->{'collectionmeta'}->{$metaname}->{$lang};
|
---|
711 | }
|
---|
712 | if ($lang =~ /default/) {
|
---|
713 | $defaultfound=1;
|
---|
714 | #the default entry goes first
|
---|
715 | $metadata_entry = "<$mapname>" .
|
---|
716 | $self->{'collect_cfg'}->{'collectionmeta'}->{$metaname}->{'default'} . "\n" . $metadata_entry;
|
---|
717 | }
|
---|
718 | else {
|
---|
719 | my ($l) = $lang =~ /^\[l=(\w*)\]$/;
|
---|
720 | if ($l) {
|
---|
721 | $metadata_entry .= "<$mapname:$l>" .
|
---|
722 | $self->{'collect_cfg'}->{'collectionmeta'}->{$metaname}->{$lang} . "\n";
|
---|
723 |
|
---|
724 | # Use the English value as the default if no default is specified
|
---|
725 | if ($l =~ /en/i) {
|
---|
726 | $default=$self->{'collect_cfg'}->{'collectionmeta'}->{$metaname}->{$lang};
|
---|
727 | }
|
---|
728 | }
|
---|
729 | }
|
---|
730 | } #foreach lang
|
---|
731 | #if we haven't found a default, put one in
|
---|
732 | if (!$defaultfound) {
|
---|
733 | $metadata_entry = "<$mapname>$default\n" . $metadata_entry;
|
---|
734 | }
|
---|
735 | return $metadata_entry;
|
---|
736 |
|
---|
737 | }
|
---|
738 |
|
---|
739 | # at the end of building, we have an indexfieldmap with all the mappings,
|
---|
740 | # plus some extras, and indexmap with any indexes in it that weren't
|
---|
741 | # specified in the index definition. we want to make an ordered list of
|
---|
742 | # fields that are indexed, and a list of mappings that are used. this will
|
---|
743 | # be used for the build.cfg file, and for collection meta definition we
|
---|
744 | # store these in a build.cfg bit
|
---|
745 | sub make_final_field_list {
|
---|
746 | my $self = shift (@_);
|
---|
747 |
|
---|
748 | $self->{'build_cfg'} = {};
|
---|
749 |
|
---|
750 | # store the indexfieldmap information
|
---|
751 | my @indexfieldmap = ();
|
---|
752 | my @indexfields = ();
|
---|
753 | my $specifiedfields = {};
|
---|
754 | my @specifiedfieldorder = ();
|
---|
755 |
|
---|
756 | # go through the index definition and add each thing to a map, so we
|
---|
757 | # can easily check if it is already specified - when doing the
|
---|
758 | # metadata, we print out all the individual fields, but some may
|
---|
759 | # already be specified in the index definition, so we dont want to add
|
---|
760 | # those again.
|
---|
761 |
|
---|
762 | my $field;
|
---|
763 | foreach $field (@{$self->{'collect_cfg'}->{'indexes'}}) {
|
---|
764 | # remove subcoll stuff
|
---|
765 | my $parts = $field;
|
---|
766 | $parts =~ s/:.*$//;
|
---|
767 | my @fs = split(',', $parts);
|
---|
768 | foreach my $f(@fs) {
|
---|
769 | if (!defined $specifiedfields->{$f}) {
|
---|
770 | $specifiedfields->{$f}=1;
|
---|
771 | push (@specifiedfieldorder, "$f");
|
---|
772 | }
|
---|
773 | }
|
---|
774 | }
|
---|
775 |
|
---|
776 | #add all fields bit
|
---|
777 | foreach $field (@specifiedfieldorder) {
|
---|
778 | if ($field eq "metadata") {
|
---|
779 | foreach my $newfield (keys %{$self->{'buildproc'}->{'indexfields'}}) {
|
---|
780 | if (!defined $specifiedfields->{$newfield}) {
|
---|
781 | push (@indexfieldmap, "$newfield\-\>$self->{'buildproc'}->{'indexfieldmap'}->{$newfield}");
|
---|
782 | push (@indexfields, "$newfield");
|
---|
783 | }
|
---|
784 | }
|
---|
785 |
|
---|
786 | } elsif ($field eq 'text') {
|
---|
787 | push (@indexfieldmap, "text\-\>TX");
|
---|
788 | push (@indexfields, "text");
|
---|
789 | } elsif ($field eq 'allfields') {
|
---|
790 | push (@indexfieldmap, "allfields\-\>ZZ");
|
---|
791 | push (@indexfields, "allfields");
|
---|
792 | } else {
|
---|
793 | push (@indexfieldmap, "$field\-\>$self->{'buildproc'}->{'indexfieldmap'}->{$field}");
|
---|
794 | push (@indexfields, "$field");
|
---|
795 |
|
---|
796 | }
|
---|
797 | }
|
---|
798 |
|
---|
799 | $self->{'build_cfg'}->{'indexfieldmap'} = \@indexfieldmap;
|
---|
800 | $self->{'build_cfg'}->{'indexfields'} = \@indexfields;
|
---|
801 | }
|
---|
802 |
|
---|
803 |
|
---|
804 | # recreate the field list from the build.cfg file, look first in building,
|
---|
805 | # then in index to find it. if there is no build.cfg, we can't do the field
|
---|
806 | # list (there is unlikely to be any index anyway.)
|
---|
807 | sub read_final_field_list {
|
---|
808 | my $self = shift (@_);
|
---|
809 | $self->{'build_cfg'} = {};
|
---|
810 | my @indexfieldmap = ();
|
---|
811 | my @indexfields = ();
|
---|
812 |
|
---|
813 | if (scalar(keys %{$self->{'buildproc'}->{'indexfieldmap'}}) == 0) {
|
---|
814 | # set the default mapping
|
---|
815 | $self->{'buildproc'}->set_indexfieldmap ($self->{'indexfieldmap'});
|
---|
816 | }
|
---|
817 | # we read the stuff in from the build.cfg file - if its there
|
---|
818 | my $buildconfigfile = &util::filename_cat($self->{'build_dir'}, "build.cfg");
|
---|
819 |
|
---|
820 | if (!-e $buildconfigfile) {
|
---|
821 | # try the index dir - but do we know where it is?? try here
|
---|
822 | $buildconfigfile = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "index", "build.cfg");
|
---|
823 | if (!-e $buildconfigfile) {
|
---|
824 | #we cant find a config file - just ignore the field list
|
---|
825 | return;
|
---|
826 | }
|
---|
827 | }
|
---|
828 |
|
---|
829 | my $buildcfg = &colcfg::read_build_cfg( $buildconfigfile);
|
---|
830 | my $field;
|
---|
831 | if (defined $buildcfg->{'indexfields'}) {
|
---|
832 | foreach $field (@{$buildcfg->{'indexfields'}}) {
|
---|
833 | push (@indexfields, "$field");
|
---|
834 | }
|
---|
835 | }
|
---|
836 |
|
---|
837 | if (defined $buildcfg->{'indexfieldmap'}) {
|
---|
838 | foreach $field (@{$buildcfg->{'indexfieldmap'}}) {
|
---|
839 | push (@indexfieldmap, "$field");
|
---|
840 | my ($f, $v) = $field =~ /^(.*)\-\>(.*)$/;
|
---|
841 | $self->{'buildproc'}->{'indexfieldmap'}->{$f} = $v;
|
---|
842 | }
|
---|
843 | }
|
---|
844 |
|
---|
845 | $self->{'build_cfg'}->{'indexfieldmap'} = \@indexfieldmap;
|
---|
846 | $self->{'build_cfg'}->{'indexfields'} = \@indexfields;
|
---|
847 | }
|
---|
848 |
|
---|
849 |
|
---|
850 | sub write_cfg_file {
|
---|
851 | my $self = shift(@_);
|
---|
852 | my ($build_cfg) = @_;
|
---|
853 |
|
---|
854 | # write out the build information
|
---|
855 | &cfgread::write_cfg_file("$self->{'build_dir'}/build.cfg", $build_cfg,
|
---|
856 | '^(builddate|buildtype|numdocs|numsections|numbytes|textlevel|indexstem|maxnumeric)$',
|
---|
857 | '^(indexmap|subcollectionmap|languagemap|indexfieldmap|notbuilt|indexfields|indexlevels|levelmap)$');
|
---|
858 |
|
---|
859 | }
|
---|
860 |
|
---|
861 | sub build_cfg_extra {
|
---|
862 | my $self = shift (@_);
|
---|
863 | my ($build_cfg) = @_;
|
---|
864 |
|
---|
865 | $build_cfg->{'numsections'} = $self->{'buildproc'}->get_num_sections();
|
---|
866 |
|
---|
867 | # store the level info
|
---|
868 | my @indexlevels = ();
|
---|
869 | my @levelmap = ();
|
---|
870 | foreach my $l (@{$self->{'levelorder'}}) {
|
---|
871 | push (@indexlevels, $level_map{$l});
|
---|
872 | push (@levelmap, "$l\-\>$level_map{$l}");
|
---|
873 | }
|
---|
874 | $build_cfg->{'indexlevels'} = \@indexlevels;
|
---|
875 | $build_cfg->{'levelmap'} = \@levelmap;
|
---|
876 |
|
---|
877 | if ($self->{'levels'}->{'section'}) {
|
---|
878 | $build_cfg->{'textlevel'} = $level_map{'section'};
|
---|
879 | } else {
|
---|
880 | $build_cfg->{'textlevel'} = $level_map{'document'};
|
---|
881 | }
|
---|
882 |
|
---|
883 | }
|
---|
884 |
|
---|
885 | 1;
|
---|
886 |
|
---|
887 |
|
---|