Changeset 28121

Show
Ignore:
Timestamp:
22.08.2013 18:41:08 (6 years ago)
Author:
ak19
Message:

Better error checking after system commands in mgpbuilder too. Could not use bitwise flags for this, since mg needs to generate all the indexes, stemming, casefolding and casefolding and stemming, even when one of them (such as casefolding) is not turned on. And if ever one of them doesn't work, the original comment seemed to indicate that then none of it will work.

Location:
main/trunk/greenstone2/perllib
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/mgbuilder.pm

    r27986 r28121  
    205205        die "mgbuilder::compress_text - couldn't run $mg_compression_dict_exe\n"; 
    206206    } 
    207     system ("mg_compression_dict$exe -f \"$fulltextprefix\" -S -H -2 -k 5120 $osextra"); 
     207    my $comp_dict_status = system ("mg_compression_dict$exe -f \"$fulltextprefix\" -S -H -2 -k 5120 $osextra"); 
     208    if($comp_dict_status != 0) { 
     209        print $outhandle "\nmgbuilder::compress_text - Warning: there's no compressed text\n"; 
     210        $self->{'notbuilt'}->{'compressedtext'} = 1; 
     211        print STDERR "<Warning name='NoCompressedText'/>\n</Stage>\n" if $self->{'gli'}; 
     212        return; 
     213    } 
    208214 
    209215    # -b $maxdocsize sets the maximum document size to be 12 meg 
     
    456462    my $hash_status = system ($hash_cmd); 
    457463    print $outhandle "\nstatus from running hash_cmd: $hash_status\n" if ($self->{'verbosity'} >= 4); 
     464    # check that perf hash was generated - if not, don't carry on 
     465    if ($hash_status !=0) { 
     466        print $outhandle "mgbuilder::build_index - Couldn't create index $index as there are too few words in the index.\n"; 
     467        print STDERR "<Warning name='NoIndex'/>\n</Stage>\n" if $self->{'gli'}; 
     468        $self->{'notbuilt'}->{$index}=1; 
     469        return; 
     470         
     471    } 
    458472 
    459473    if (!-e "$mg_passes_exe" ||  
     
    493507    my $weights_cmd = "mg_weights_build$exe -f \"$fullindexprefix\" -t \"$fulltextprefix\" $osextra"; 
    494508    print $outhandle "\ncmd: $weights_cmd\n" if ($self->{'verbosity'} >= 4); 
    495     system ($weights_cmd); 
     509    my $weights_status = system ($weights_cmd); 
     510    # check that it worked - if not, don't carry on 
     511    if ($weights_status !=0) { 
     512        print $outhandle "mgbuilder::build_index - No Index: couldn't create weights file, error calling mg_weights_build.\n"; 
     513        print STDERR "<Warning name='NoIndex'/>\n</Stage>\n" if $self->{'gli'}; 
     514        $self->{'notbuilt'}->{$index}=1; 
     515        return; 
     516         
     517    } 
    496518 
    497519    # create 'on-disk' stemmed dictionary 
     
    502524        die "mgbuilder::build_index - couldn't run $mg_invf_dict_exe\n"; 
    503525    } 
    504     system ("mg_invf_dict$exe -f \"$fullindexprefix\" $osextra"); 
    505  
     526    my $invdict_status = system ("mg_invf_dict$exe -f \"$fullindexprefix\" $osextra"); 
     527    # check that it worked - if not, don't carry on 
     528    if ($invdict_status !=0) { 
     529        print $outhandle "mgbuilder::build_index - No Index: couldn't create on-disk stemmed dictionary, error calling mg_invf_dict.\n"; 
     530        print STDERR "<Warning name='NoIndex'/>\n</Stage>\n" if $self->{'gli'}; 
     531        $self->{'notbuilt'}->{$index}=1; 
     532        return; 
     533         
     534    } 
    506535 
    507536    # creates stem index files for the various stemming methods 
     
    515544    # so we generate them whatever, but don't advertise the fact 
    516545    #if ($self->{'casefold'}) { 
    517     system ("mg_stem_idx$exe -b 4096 -s1 -f \"$fullindexprefix\" $osextra"); 
     546#   system ("mg_stem_idx$exe -b 4096 -s1 -f \"$fullindexprefix\" $osextra"); 
    518547    #} 
    519548    #if ($self->{'stem'}) { 
    520     system ("mg_stem_idx$exe -b 4096 -s2 -f \"$fullindexprefix\" $osextra"); 
     549#   system ("mg_stem_idx$exe -b 4096 -s2 -f \"$fullindexprefix\" $osextra"); 
    521550    #} 
    522551    #if ($self->{'casefold'} && $self->{'stem'}) { 
    523     system ("mg_stem_idx$exe -b 4096 -s3 -f \"$fullindexprefix\" $osextra"); 
     552#   system ("mg_stem_idx$exe -b 4096 -s3 -f \"$fullindexprefix\" $osextra"); 
    524553    #} 
     554 
     555    # same as above: generate all the stem idexes. But don't bother stemming if 
     556    # casefolding failed, and don't try generating indexes for both if stemming failed 
     557    my $stem_index_status = system ("mg_stem_idx$exe -b 4096 -s1 -f \"$fullindexprefix\" $osextra"); 
     558    if($stem_index_status != 0) { 
     559        print $outhandle "\nCase folding failed: mg_stem_idx exit status $stem_index_status\n" if ($self->{'verbosity'} >= 4); 
     560    } else { 
     561        $stem_index_status = system ("mg_stem_idx$exe -b 4096 -s2 -f \"$fullindexprefix\" $osextra"); 
     562 
     563        if($stem_index_status != 0) { 
     564        print $outhandle "\nStemming failed: mg_stem_idx exit status $stem_index_status\n" if ($self->{'verbosity'} >= 4); 
     565        } else { 
     566        $stem_index_status = system ("mg_stem_idx$exe -b 4096 -s3 -f \"$fullindexprefix\" $osextra"); 
     567 
     568        if($stem_index_status != 0) { 
     569            print $outhandle "\nCasefolding and stemming failed: mg_stem_idx exit status $stem_index_status\n" if ($self->{'verbosity'} >= 4); 
     570        } 
     571        } 
     572    } 
    525573 
    526574    # remove unwanted files 
  • main/trunk/greenstone2/perllib/mgppbuilder.pm

    r28119 r28121  
    573573    # check that it worked - if not, don't carry on 
    574574    if ($weights_status !=0) { 
    575         print $outhandle "mgppbuilder::build_index - No Index: couldn't create weights file, error calling mggp_weights_build.\n"; 
     575        print $outhandle "mgppbuilder::build_index - No Index: couldn't create weights file, error calling mgpp_weights_build.\n"; 
    576576        print STDERR "<Warning name='NoIndex'/>\n</Stage>\n" if $self->{'gli'}; 
    577577        $self->{'notbuilt'}->{$index}=1; 
     
    589589    # check that it worked - if not, don't carry on 
    590590    if ($invdict_status !=0) { 
    591         print $outhandle "mgppbuilder::build_index - No Index: couldn't create on-disk stemmed dictionary, error calling mggp_invf_dict.\n"; 
     591        print $outhandle "mgppbuilder::build_index - No Index: couldn't create on-disk stemmed dictionary, error calling mgpp_invf_dict.\n"; 
    592592        print STDERR "<Warning name='NoIndex'/>\n</Stage>\n" if $self->{'gli'}; 
    593593        $self->{'notbuilt'}->{$index}=1;