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