source: gsdl/trunk/perllib/mgbuilder.pm@ 16013

Last change on this file since 16013 was 15716, checked in by mdewsnip, 16 years ago

Added "use strict" and fixed various problems that it found.

  • Property svn:keywords set to Author Date Id Revision
File size: 18.6 KB
RevLine 
[537]1###########################################################################
[4]2#
[537]3# mgbuilder.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###########################################################################
[4]25
26package mgbuilder;
27
[10468]28use basebuilder;
[4]29use plugin;
[15716]30use strict; no strict 'refs';
[4]31use util;
32
[15716]33
[1304]34BEGIN {
[10468]35 @mgbuilder::ISA = ('basebuilder');
[1304]36}
37
38
[8716]39my %wanted_index_files = ('td'=>1,
[4]40 't'=>1,
41 'idb'=>1,
42 'ib1'=>1,
43 'ib2'=>1,
44 'ib3'=>1,
45 'i'=>1,
46 'ip'=>1,
47 'tiw'=>1,
48 'wa'=>1);
49
[10468]50my $maxdocsize = $basebuilder::maxdocsize;
[4]51
[10468]52
[4]53sub new {
[10468]54 my $class = shift(@_);
55
56 my $self = new basebuilder (@_);
57 $self = bless $self, $class;
[1424]58
[10468]59 $self->{'buildtype'} = "mg";
60 return $self;
61}
[4]62
[10468]63sub default_buildproc {
64 my $self = shift (@_);
[4]65
[10468]66 return "mgbuildproc";
67}
[4]68
[10468]69sub generate_index_list {
70 my $self = shift (@_);
71
[5225]72 if (!defined($self->{'collect_cfg'}->{'indexes'})) {
73 $self->{'collect_cfg'}->{'indexes'} = [];
74 }
[4743]75 if (scalar(@{$self->{'collect_cfg'}->{'indexes'}}) == 0) {
76 # no indexes have been specified so we'll build a "dummy:text" index
77 push (@{$self->{'collect_cfg'}->{'indexes'}}, "dummy:text");
78 }
79
[4]80}
81
[12910]82sub generate_index_options {
83 my $self = shift (@_);
[4]84
[12910]85 $self->{'casefold'} = 0;
86 $self->{'stem'} = 0;
87 $self->{'accentfold'} = 0; #not yet implemented for mg
88
89 if (!defined($self->{'collect_cfg'}->{'indexoptions'})) {
90 # just use default options
91 $self->{'casefold'} = 1;
92 $self->{'stem'} = 1;
93 } else {
94 foreach my $option (@{$self->{'collect_cfg'}->{'indexoptions'}}) {
95 if ($option =~ /stem/) {
96 $self->{'stem'} = 1;
97 } elsif ($option =~ /casefold/) {
98 $self->{'casefold'} = 1;
99 }
100 }
101 }
102
103 # now we record this for the build cfg
104 $self->{'stemindexes'} = 0;
105 if ($self->{'casefold'}) {
106 $self->{'stemindexes'} += 1;
107 }
108 if ($self->{'stem'}) {
109 $self->{'stemindexes'} += 2;
110 }
111
112
113}
114
[4]115sub compress_text {
116 my $self = shift (@_);
[134]117 my ($textindex) = @_;
[4]118 my $exedir = "$ENV{'GSDLHOME'}/bin/$ENV{'GSDLOS'}";
119 my $exe = &util::get_os_exe ();
[486]120 my $mg_passes_exe = &util::filename_cat($exedir, "mg_passes$exe");
121 my $mg_compression_dict_exe = &util::filename_cat($exedir, "mg_compression_dict$exe");
[1424]122 my $outhandle = $self->{'outhandle'};
[4]123
[12340]124 my $maxnumeric = $self->{'maxnumeric'};
[4192]125
[4]126 &util::mk_all_dir (&util::filename_cat($self->{'build_dir'}, "text"));
[15003]127
128 my $collect_tail = &util::get_dirsep_tail($self->{'collection'});
129 my $basefilename = &util::filename_cat("text",$collect_tail);
[4]130 my $fulltextprefix = &util::filename_cat ($self->{'build_dir'}, $basefilename);
131
132 my $osextra = "";
133 if ($ENV{'GSDLOS'} =~ /^windows$/i) {
[3115]134 $fulltextprefix =~ s@/@\\@g;
[4]135 } else {
136 $osextra = " -d /";
137 }
138
[1424]139 print $outhandle "\n*** creating the compressed text\n" if ($self->{'verbosity'} >= 1);
[6332]140 print STDERR "<Stage name='CompressText'>\n" if $self->{'gli'};
[4]141
142 # collect the statistics for the text
143 # -b $maxdocsize sets the maximum document size to be 12 meg
[1424]144 print $outhandle "\n collecting text statistics\n" if ($self->{'verbosity'} >= 1);
[6407]145 print STDERR "<Phase name='CollectTextStats'/>\n" if $self->{'gli'};
[782]146
147 my ($handle);
148 if ($self->{'debug'}) {
[15716]149 $handle = *STDOUT;
150 }
151 else {
[782]152 if (!-e "$mg_passes_exe" ||
[15716]153 !open($handle, "| mg_passes$exe -f \"$fulltextprefix\" -b $maxdocsize -T1 -M $maxnumeric $osextra")) {
[6407]154 print STDERR "<FatalError name='NoRunMGPasses'>\n</Stage>\n" if $self->{'gli'};
[782]155 die "mgbuilder::compress_text - couldn't run $mg_passes_exe\n";
156 }
[4]157 }
[782]158
159 $self->{'buildproc'}->set_output_handle ($handle);
160 $self->{'buildproc'}->set_mode ('text');
161 $self->{'buildproc'}->set_index ($textindex);
162 $self->{'buildproc'}->set_indexing_text (0);
[7904]163
164
[2336]165 if ($self->{'no_text'}) {
166 $self->{'buildproc'}->set_store_text(0);
167 } else {
168 $self->{'buildproc'}->set_store_text(1);
169 }
[4]170 $self->{'buildproc'}->reset();
[7904]171
[835]172 &plugin::begin($self->{'pluginfo'}, $self->{'source_dir'},
173 $self->{'buildproc'}, $self->{'maxdocs'});
174 &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
[9853]175 "", {}, $self->{'buildproc'}, $self->{'maxdocs'}, 0, $self->{'gli'});
[835]176 &plugin::end($self->{'pluginfo'});
[7904]177
[4]178
[782]179 close ($handle) unless $self->{'debug'};
180
[1251]181 $self->print_stats();
182
[4]183 # create the compression dictionary
184 # the compression dictionary is built by assuming the stats are from a seed
185 # dictionary (-S), if a novel word is encountered it is spelled out (-H),
186 # and the resulting dictionary must be less than 5 meg with the most frequent
187 # words being put into the dictionary first (-2 -k 5120)
[782]188 if (!$self->{'debug'}) {
[1424]189 print $outhandle "\n creating the compression dictionary\n" if ($self->{'verbosity'} >= 1);
[6407]190 print STDERR "<Phase name='CreatingCompress'/>\n" if $self->{'gli'};
[782]191 if (!-e "$mg_compression_dict_exe") {
192 die "mgbuilder::compress_text - couldn't run $mg_compression_dict_exe\n";
193 }
[1679]194 system ("mg_compression_dict$exe -f \"$fulltextprefix\" -S -H -2 -k 5120 $osextra");
[782]195
196 # -b $maxdocsize sets the maximum document size to be 12 meg
[1072]197 if (!-e "$mg_passes_exe" ||
[4192]198 !open ($handle, "| mg_passes$exe -f \"$fulltextprefix\" -b $maxdocsize -T2 -M $maxnumeric $osextra")) {
[6407]199 print STDERR "<FatalError name='NoRunMGPasses'/>\n</Stage>\n" if $self->{'gli'};
[1072]200 die "mgbuilder::compress_text - couldn't run $mg_passes_exe\n";
[782]201 }
[4]202 }
[6332]203 else {
[6407]204 print STDERR "<Phase name='SkipCreatingComp'/>\n" if $self->{'gli'};
[6332]205 }
[4]206
[782]207 $self->{'buildproc'}->reset();
[4]208 # compress the text
[1424]209 print $outhandle "\n compressing the text\n" if ($self->{'verbosity'} >= 1);
[6407]210 print STDERR "<Phase name='CompressingText'/>\n" if $self->{'gli'};
[6332]211
[4]212 &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
[9853]213 "", {}, $self->{'buildproc'}, $self->{'maxdocs'}, 0, $self->{'gli'});
[7904]214
[782]215 close ($handle) unless $self->{'debug'};
[1251]216
217 $self->print_stats();
[6407]218 print STDERR "</Stage>\n" if $self->{'gli'};
[4]219}
220
[486]221
[4]222# creates directory names for each of the index descriptions
223sub create_index_mapping {
224 my $self = shift (@_);
225 my ($indexes) = @_;
226
227 my %mapping = ();
[290]228 $mapping{'indexmaporder'} = [];
229 $mapping{'subcollectionmaporder'} = [];
230 $mapping{'languagemaporder'} = [];
[4]231
232 # dirnames is used to check for collisions. Start this off
233 # with the manditory directory names
234 my %dirnames = ('text'=>'text',
235 'extra'=>'extra');
[8716]236 my %pnames = ('index' => {}, 'subcollection' => {}, 'languages' => {});
237 foreach my $index (@$indexes) {
[139]238 my ($level, $gran, $subcollection, $languages) = split (":", $index);
[4]239
[139]240 # the directory name starts with the first character of the index level
241 my ($pindex) = $level =~ /^(.)/;
[4]242
[139]243 # next comes a processed version of the index
244 $pindex .= $self->process_field ($gran);
245 $pindex = lc ($pindex);
246
[69]247 # next comes a processed version of the subcollection if there is one.
[139]248 my $psub = $self->process_field ($subcollection);
249 $psub = lc ($psub);
[69]250
[139]251 # next comes a processed version of the language if there is one.
252 my $plang = $self->process_field ($languages);
253 $plang = lc ($plang);
[4]254
[139]255 my $dirname = $pindex . $psub . $plang;
256
257 # check to be sure all index names are unique
258 while (defined ($dirnames{$dirname})) {
259 $dirname = $self->make_unique (\%pnames, $index, \$pindex, \$psub, \$plang);
[4]260 }
[1973]261 $mapping{$index} = $dirname;
[139]262
[290]263 # store the mapping orders as well as the maps
[1973]264 # also put index, subcollection and language fields into the mapping thing -
265 # (the full index name (eg document:text:subcol:lang) is not used on
266 # the query page) -these are used for collectionmeta later on
[290]267 if (!defined $mapping{'indexmap'}{"$level:$gran"}) {
268 $mapping{'indexmap'}{"$level:$gran"} = $pindex;
269 push (@{$mapping{'indexmaporder'}}, "$level:$gran");
[1973]270 if (!defined $mapping{"$level:$gran"}) {
271 $mapping{"$level:$gran"} = $pindex;
272 }
[290]273 }
274 if ($psub =~ /\w/ && !defined ($mapping{'subcollectionmap'}{$subcollection})) {
275 $mapping{'subcollectionmap'}{$subcollection} = $psub;
276 push (@{$mapping{'subcollectionmaporder'}}, $subcollection);
[1973]277 $mapping{$subcollection} = $psub;
[290]278 }
279 if ($plang =~ /\w/ && !defined ($mapping{'languagemap'}{$languages})) {
280 $mapping{'languagemap'}{$languages} = $plang;
[1973]281 push (@{$mapping{'languagemaporder'}}, $languages);
282 $mapping{$languages} = $plang;
[290]283 }
[4]284 $dirnames{$dirname} = $index;
[8716]285 $pnames{'index'}->{$pindex} = "$level:$gran";
286 $pnames{'subcollection'}->{$psub} = $subcollection;
287 $pnames{'languages'}->{$plang} = $languages;
[4]288 }
289
290 return \%mapping;
291}
292
293
[139]294sub make_unique {
295 my $self = shift (@_);
296 my ($namehash, $index, $indexref, $subref, $langref) = @_;
297 my ($level, $gran, $subcollection, $languages) = split (":", $index);
298
299 if ($namehash->{'index'}->{$$indexref} ne "$level:$gran") {
300 $self->get_next_version ($indexref);
301 } elsif ($namehash->{'subcollection'}->{$$subref} ne $subcollection) {
302 $self->get_next_version ($subref);
303 } elsif ($namehash->{'languages'}->{$$langref} ne $languages) {
304 $self->get_next_version ($langref);
305 }
306 return "$$indexref$$subref$$langref";
307}
308
[4]309sub build_index {
310 my $self = shift (@_);
311 my ($index) = @_;
[1424]312 my $outhandle = $self->{'outhandle'};
[4]313
314 # get the full index directory path and make sure it exists
315 my $indexdir = $self->{'index_mapping'}->{$index};
316 &util::mk_all_dir (&util::filename_cat($self->{'build_dir'}, $indexdir));
[15003]317
318 my $collect_tail = &util::get_dirsep_tail($self->{'collection'});
[4]319 my $fullindexprefix = &util::filename_cat ($self->{'build_dir'}, $indexdir,
[15003]320 $collect_tail);
[4]321 my $fulltextprefix = &util::filename_cat ($self->{'build_dir'}, "text",
[15003]322 $collect_tail);
[4]323
324 # get any os specific stuff
325 my $exedir = "$ENV{'GSDLHOME'}/bin/$ENV{'GSDLOS'}";
326 my $exe = &util::get_os_exe ();
[486]327 my $mg_passes_exe = &util::filename_cat($exedir, "mg_passes$exe");
328 my $mg_perf_hash_build_exe =
329 &util::filename_cat($exedir, "mg_perf_hash_build$exe");
330 my $mg_weights_build_exe =
331 &util::filename_cat ($exedir, "mg_weights_build$exe");
332 my $mg_invf_dict_exe =
333 &util::filename_cat ($exedir, "mg_invf_dict$exe");
334 my $mg_stem_idx_exe =
335 &util::filename_cat ($exedir, "mg_stem_idx$exe");
336
[12340]337 my $maxnumeric = $self->{'maxnumeric'};
[4192]338
[4]339 my $osextra = "";
340 if ($ENV{'GSDLOS'} =~ /^windows$/i) {
[3115]341 $fullindexprefix =~ s@/@\\@g;
[4]342 } else {
343 $osextra = " -d /";
[3115]344 if ($outhandle ne "STDERR") {
345 # so mg_passes doesn't print to stderr if we redirect output
346 $osextra .= " 2>/dev/null";
347 }
[4]348 }
349
350 # get the index level from the index description
351 # the index will be level 2 unless we are building a
352 # paragraph level index
353 my $index_level = 2;
354 $index_level = 3 if $index =~ /^paragraph/i;
355
[69]356 # get the index expression if this index belongs
357 # to a subcollection
358 my $indexexparr = [];
[9669]359 my $langarr = [];
[1973]360 # there may be subcollection info, and language info.
361 my ($level, $fields, $subcollection, $language) = split (":", $index);
[85]362 my @subcollections = ();
363 @subcollections = split /,/, $subcollection if (defined $subcollection);
[69]364
[8716]365 foreach my $subcollection (@subcollections) {
[69]366 if (defined ($self->{'collect_cfg'}->{'subcollection'}->{$subcollection})) {
367 push (@$indexexparr, $self->{'collect_cfg'}->{'subcollection'}->{$subcollection});
368 }
369 }
370
[139]371 # add expressions for languages if this index belongs to
[1973]372 # a language subcollection - only put languages expressions for the
373 # ones we want in the index
374
375 my @languages = ();
[9548]376 my $language_metadata = "Language";
377 if (defined ($self->{'collect_cfg'}->{'language_metadata'})) {
378 $language_metadata = $self->{'collect_cfg'}->{'language_metadata'};
379 }
[1973]380 @languages = split /,/, $language if (defined $language);
[8716]381 foreach my $language (@languages) {
[1973]382 my $not=0;
[139]383 if ($language =~ s/^\!//) {
[1973]384 $not = 1;
[139]385 }
[6543]386 if($not) {
[9669]387 push (@$langarr, "!$language");
[6543]388 } else {
[9669]389 push (@$langarr, "$language");
[1973]390 }
[139]391 }
[9669]392
[782]393 # Build index dictionary. Uses verbatim stem method
[1424]394 print $outhandle "\n creating index dictionary\n" if ($self->{'verbosity'} >= 1);
[6407]395 print STDERR "<Phase name='CreatingIndexDic'/>\n" if $self->{'gli'};
[782]396 my ($handle);
397 if ($self->{'debug'}) {
[15716]398 $handle = *STDOUT;
399 }
400 else {
[782]401 if (!-e "$mg_passes_exe" ||
[15716]402 !open($handle, "| mg_passes$exe -f \"$fullindexprefix\" -b $maxdocsize " .
[4192]403 "-$index_level -m 32 -s 0 -G -t 10 -N1 -M $maxnumeric $osextra")) {
[6407]404 print STDERR "<FatalError name='NoRunMGPasses'/>\n</Stage>\n" if $self->{'gli'};
[782]405 die "mgbuilder::build_index - couldn't run $mg_passes_exe\n";
406 }
407 }
408
[4]409 # set up the document processor
[782]410 $self->{'buildproc'}->set_output_handle ($handle);
[4]411 $self->{'buildproc'}->set_mode ('text');
[69]412 $self->{'buildproc'}->set_index ($index, $indexexparr);
[9669]413 $self->{'buildproc'}->set_index_languages ($language_metadata, $langarr) if (defined $language);
[292]414 $self->{'buildproc'}->set_indexing_text (1);
[2336]415 $self->{'buildproc'}->set_store_text(1);
[4]416
417 $self->{'buildproc'}->reset();
418 &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
[9853]419 "", {}, $self->{'buildproc'}, $self->{'maxdocs'},0, $self->{'gli'});
[782]420 close ($handle) unless $self->{'debug'};
[4]421
[1251]422 $self->print_stats();
423
[5768]424 # 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.
425 # we check on the .id file - index dictionary
426 my $dict_file = "$fullindexprefix.id";
427 if (!-e $dict_file) {
428 print $outhandle "mgbuilder::build_index - Couldn't create index $index\n";
429 $self->{'notbuilt'}->{$index}=1;
430 return;
431 }
[782]432 if (!$self->{'debug'}) {
433 # create the perfect hash function
434 if (!-e "$mg_perf_hash_build_exe") {
[6407]435 print STDERR "<FatalError name='NoRunMGHash'/>\n</Stage>\n" if $self->{'gli'};
[782]436 die "mgbuilder::build_index - couldn't run $mg_perf_hash_build_exe\n";
437 }
[1679]438 system ("mg_perf_hash_build$exe -f \"$fullindexprefix\" $osextra");
[782]439
440 if (!-e "$mg_passes_exe" ||
[1679]441 !open ($handle, "| mg_passes$exe -f \"$fullindexprefix\" -b $maxdocsize " .
[4192]442 "-$index_level -c 3 -G -t 10 -N2 -M $maxnumeric $osextra")) {
[6407]443 print STDERR "<FatalError name='NoRunMGPasses'/>\n</Stage>\n" if $self->{'gli'};
[782]444 die "mgbuilder::build_index - couldn't run $mg_passes_exe\n";
445 }
[4]446 }
[782]447
[4]448 # invert the text
[1424]449 print $outhandle "\n inverting the text\n" if ($self->{'verbosity'} >= 1);
[6407]450 print STDERR "<Phase name='InvertingText'/>\n" if $self->{'gli'};
[4]451 $self->{'buildproc'}->reset();
452 &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'},
[9853]453 "", {}, $self->{'buildproc'}, $self->{'maxdocs'},0, $self->{'gli'});
[1304]454
[7904]455
[1251]456 $self->print_stats ();
457
[782]458 if (!$self->{'debug'}) {
[4]459
[782]460 close ($handle);
461
462 # create the weights file
[1424]463 print $outhandle "\n create the weights file\n" if ($self->{'verbosity'} >= 1);
[6407]464 print STDERR "<Phase name='CreateTheWeights'/>\n" if $self->{'gli'};
[782]465 if (!-e "$mg_weights_build_exe") {
[6407]466 print STDERR "<FatalError name='NoRunMGWeights'/>\n</Stage>\n" if $self->{'gli'};
[782]467 die "mgbuilder::build_index - couldn't run $mg_weights_build_exe\n";
468 }
[1679]469 system ("mg_weights_build$exe -f \"$fullindexprefix\" -t \"$fulltextprefix\" $osextra");
[4]470
[782]471 # create 'on-disk' stemmed dictionary
[1424]472 print $outhandle "\n creating 'on-disk' stemmed dictionary\n" if ($self->{'verbosity'} >= 1);
[6407]473 print STDERR "<Phase name='CreateStemmedDic'/>\n" if $self->{'gli'};
[782]474 if (!-e "$mg_invf_dict_exe") {
[6407]475 print STDERR "<FatalError name='NoRunMGInvf'/>\n</Stage>\n" if $self->{'gli'};
[782]476 die "mgbuilder::build_index - couldn't run $mg_invf_dict_exe\n";
477 }
[1679]478 system ("mg_invf_dict$exe -f \"$fullindexprefix\" $osextra");
[4]479
480
[782]481 # creates stem index files for the various stemming methods
[1424]482 print $outhandle "\n creating stem indexes\n" if ($self->{'verbosity'} >= 1);
[6407]483 print STDERR "<Phase name='CreatingStemIndx'/>\n" if $self->{'gli'};
[782]484 if (!-e "$mg_stem_idx_exe") {
[6407]485 print STDERR "<FatalError name='NoRunMGStem'/>\n</Stage>\n" if $self->{'gli'};
[782]486 die "mgbuilder::build_index - couldn't run $mg_stem_idx_exe\n";
487 }
[12910]488 # currently mg wont work if we don't generate all the stem idexes
489 # so we generate them whatever, but don't advertise the fact
490 #if ($self->{'casefold'}) {
[12971]491 system ("mg_stem_idx$exe -b 4096 -s1 -f \"$fullindexprefix\" $osextra");
[12910]492 #}
493 #if ($self->{'stem'}) {
[12971]494 system ("mg_stem_idx$exe -b 4096 -s2 -f \"$fullindexprefix\" $osextra");
[12910]495 #}
496 #if ($self->{'casefold'} && $self->{'stem'}) {
[12971]497 system ("mg_stem_idx$exe -b 4096 -s3 -f \"$fullindexprefix\" $osextra");
[12910]498 #}
499
[782]500 # remove unwanted files
501 my $tmpdir = &util::filename_cat ($self->{'build_dir'}, $indexdir);
502 opendir (DIR, $tmpdir) || die
503 "mgbuilder::build_index - couldn't read directory $tmpdir\n";
[8716]504 foreach my $file (readdir(DIR)) {
[782]505 next if $file =~ /^\./;
506 my ($suffix) = $file =~ /\.([^\.]+)$/;
507 if (defined $suffix && !defined $wanted_index_files{$suffix}) {
508 # delete it!
[1424]509 print $outhandle "deleting $file\n" if $self->{'verbosity'} > 2;
[782]510 &util::rm (&util::filename_cat ($tmpdir, $file));
511 }
[4]512 }
[782]513 closedir (DIR);
[4]514 }
[6407]515 print STDERR "</Stage>\n" if $self->{'gli'};
[4]516}
517
[10468]518sub build_cfg_extra {
519 my $self = shift(@_);
520 my ($build_cfg) = @_;
[2506]521
[1252]522 # get additional stats from mg
523 my $exedir = "$ENV{'GSDLHOME'}/bin/$ENV{'GSDLOS'}";
524 my $exe = &util::get_os_exe ();
525 my $mgstat_exe = &util::filename_cat($exedir, "mgstat$exe");
[15003]526
527 my $collect_tail = &util::get_dirsep_tail($self->{'collection'});
528 my $input_file = &util::filename_cat ("text", $collect_tail);
[1679]529 if (!-e "$mgstat_exe" || !open (PIPEIN, "mgstat$exe -d \"$self->{'build_dir'}\" -f \"$input_file\" |")) {
[15716]530 my $outhandle = $self->{'outhandle'};
[1424]531 print $outhandle "Warning: Couldn't open pipe to $mgstat_exe to get additional stats\n";
[1252]532 } else {
533 my $line = "";
534 while (defined ($line = <PIPEIN>)) {
535 if ($line =~ /^Words in collection \[dict\]\s+:\s+(\d+)/) {
536 ($build_cfg->{'numwords'}) = $1;
537 } elsif ($line =~ /^Documents\s+:\s+(\d+)/) {
538 ($build_cfg->{'numsections'}) = $1;
539 }
540 }
541 close PIPEIN;
542 }
[4]543}
544
5451;
[7904]546
547
548
Note: See TracBrowser for help on using the repository browser.