Changeset 27904

Show
Ignore:
Timestamp:
18.07.2013 19:40:51 (6 years ago)
Author:
ak19
Message:

Replacing calls to deprecated utils:: subroutines with FileUtils:: equivalents.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/classify/Phind.pm

    r23116 r27904  
    3333 
    3434use BaseClassifier; 
     35use FileUtils; 
    3536use util; 
    3637use ghtml; 
     
    7778        if (!defined $suffix || !defined $wanted_index_files{$suffix}) { 
    7879            # delete it! 
    79             &util::rm (&util::filename_cat ($dir, $file)); 
     80            &FileUtils::removeFiles (&FileUtils::filenameConcatenate ($dir, $file)); 
    8081        } 
    8182        } 
     
    166167 
    167168    # Ensure the Phind generate scripts are in place 
    168     my $file1 = &util::filename_cat($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "suffix"); 
     169    my $file1 = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "suffix"); 
    169170    $file1 .= ".exe" if $ENV{'GSDLOS'} =~ /^windows$/; 
    170     my $src = &util::filename_cat($ENV{'GSDLHOME'}, "src", "phind", "generate"); 
     171    my $src = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "src", "phind", "generate"); 
    171172    if (!(-e $file1)) { 
    172173    print STDERR "Phind.pm: ERROR: The Phind \"suffix\" program is not installed.\n\n"; 
     
    186187    $self->{'collectiondir'} = $ENV{'GSDLCOLLECTDIR'}; # collection directories 
    187188    if (! defined $self->{'builddir'}) { 
    188     $self->{'builddir'} = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "building"); 
     189    $self->{'builddir'} = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "building"); 
    189190    }  
    190191    $self->{'total'} = 0; 
     
    212213    # create Phind directory 
    213214    my $phnumber = 1; 
    214     my $phinddir = &util::filename_cat($builddir, "phind1"); 
     215    my $phinddir = &FileUtils::filenameConcatenate($builddir, "phind1"); 
    215216    while (-e "$phinddir") { 
    216217    $phnumber++; 
    217     $phinddir = &util::filename_cat($builddir, "phind$phnumber"); 
     218    $phinddir = &FileUtils::filenameConcatenate($builddir, "phind$phnumber"); 
    218219    } 
    219220    &util::mk_dir("$phinddir"); 
     
    224225 
    225226    # open filehandles for documents and text 
    226     my $clausefile =  &util::filename_cat("$phinddir", "clauses"); 
    227     &util::rm($clausefile) if (-e $clausefile); 
     227    my $clausefile =  &FileUtils::filenameConcatenate("$phinddir", "clauses"); 
     228    &FileUtils::removeFiles($clausefile) if (-e $clausefile); 
    228229 
    229230    my $txthandle = 'TEXT' . $phnumber; 
     
    231232    $self->{'txthandle'} = $txthandle; 
    232233 
    233     my $docfile = &util::filename_cat("$phinddir", "docs.txt"); 
    234     &util::rm($docfile) if (-e $docfile); 
     234    my $docfile = &FileUtils::filenameConcatenate("$phinddir", "docs.txt"); 
     235    &FileUtils::removeFiles($docfile) if (-e $docfile); 
    235236 
    236237    my $dochandle = 'DOC' . $phnumber; 
     
    392393    # check that we generated some files. It's not necessarily an error if 
    393394    # we didn't (execute() would have quit on error), but we can't go on. 
    394     my $phrasesfile=&util::filename_cat($self->{'phinddir'}, 'phrases'); 
     395    my $phrasesfile=&FileUtils::filenameConcatenate($self->{'phinddir'}, 'phrases'); 
    395396    if (! -r $phrasesfile) { 
    396397    print STDERR "<Warning name='NoPhrasesFound'/>\n" if $gli; 
     
    406407    print $out "\nCreating phrase databases\n"; 
    407408    print STDERR "<Phase name='PhraseDatabases'/>\n" if $gli; 
    408     my $mg_input = &util::filename_cat($phinddir, "pdata.txt"); 
    409     my $mg_stem = &util::filename_cat($phinddir, "pdata"); 
     409    my $mg_input = &FileUtils::filenameConcatenate($phinddir, "pdata.txt"); 
     410    my $mg_stem = &FileUtils::filenameConcatenate($phinddir, "pdata"); 
    410411 
    411412    &execute("mgpp_passes $osextra -f \"$mg_stem\" -T1 \"$mg_input\"", $verbosity, $out); 
     
    416417    print $out "\nCreating word-level search indexes\n"; 
    417418    print STDERR "<Phase name='WordLevelIndexes'/>\n" if $gli; 
    418     $mg_input = &util::filename_cat($phinddir, "pword.txt"); 
    419     $mg_stem = &util::filename_cat($phinddir, "pword"); 
     419    $mg_input = &FileUtils::filenameConcatenate($phinddir, "pword.txt"); 
     420    $mg_stem = &FileUtils::filenameConcatenate($phinddir, "pword"); 
    420421 
    421422    &execute("mgpp_passes $osextra -f \"$mg_stem\" -T1 -I1 \"$mg_input\"", $verbosity, $out); 
     
    433434    print $out "\nCreating document information databases\n"; 
    434435    print STDERR "<Phase name='DocInfoDatabases'/>\n" if $gli; 
    435     $mg_input = &util::filename_cat($phinddir, "docs.txt"); 
    436     $mg_stem = &util::filename_cat($phinddir, "docs"); 
     436    $mg_input = &FileUtils::filenameConcatenate($phinddir, "docs.txt"); 
     437    $mg_stem = &FileUtils::filenameConcatenate($phinddir, "docs"); 
    437438 
    438439    &execute("mgpp_passes $osextra -f \"$mg_stem\" -T1 \"$mg_input\"", $verbosity, $out); 
     
    714715 
    715716    # Read and store the stopwords 
    716     my $stopdir = &util::filename_cat($ENV{'GSDLHOME'}, "etc", "packages", "phind", "stopword"); 
     717    my $stopdir = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "etc", "packages", "phind", "stopword"); 
    717718    my $stopword_files = (); 
    718719    my ($language, $language_dir, $file, $file_name); 
     
    725726    # Ignore entries that do not match the classifier's language 
    726727    next unless ($language =~ /$language_exp/); 
    727     $language_dir = &util::filename_cat($stopdir, $language); 
     728    $language_dir = &FileUtils::filenameConcatenate($stopdir, $language); 
    728729    next unless (-d "$language_dir"); 
    729730 
     
    733734        # Ignore entries that are not stopword files 
    734735        next unless ($file =~ /sw$/); 
    735         $file_name = &util::filename_cat($language_dir, $file); 
     736        $file_name = &FileUtils::filenameConcatenate($language_dir, $file); 
    736737        next unless (-f "$file_name"); 
    737738 
     
    756757 
    757758    # link file exists 
    758     $thesaurus_links = &util::filename_cat($collectiondir, "etc", "$thesaurus.lnk"); 
     759    $thesaurus_links = &FileUtils::filenameConcatenate($collectiondir, "etc", "$thesaurus.lnk"); 
    759760    die "Cannot find thesaurus link file" unless (-e "$thesaurus_links"); 
    760761 
     
    765766        $language = 'en'; 
    766767    } 
    767     $thesaurus_terms = &util::filename_cat($collectiondir, "etc", "$thesaurus.$language"); 
     768    $thesaurus_terms = &FileUtils::filenameConcatenate($collectiondir, "etc", "$thesaurus.$language"); 
    768769    die "Cannot find thesaurus term file" unless (-e "$thesaurus_terms"); 
    769770     
     
    905906    # Output statistics about the vocablary 
    906907    print $out "Saving statistics in $phinddir/clauses.stats\n" if ($verbosity > 1); 
    907     &util::rm("$phinddir/clauses.stats") if (-e "$phinddir/clauses.stats"); 
     908    &FileUtils::removeFiles("$phinddir/clauses.stats") if (-e "$phinddir/clauses.stats"); 
    908909 
    909910    open(STAT, ">$phinddir/clauses.stats") 
     
    972973    if ($thesaurus) { 
    973974 
    974     my $thesaurusfile = &util::filename_cat($phinddir, "$thesaurus.numbers"); 
     975    my $thesaurusfile = &FileUtils::filenameConcatenate($phinddir, "$thesaurus.numbers"); 
    975976 
    976977 
     
    10741075     
    10751076    my $phinddir = $self->{'phinddir'}; 
    1076     my $infile = &util::filename_cat($phinddir, 'phrases'); 
    1077     my $outfile = &util::filename_cat($phinddir, 'phrases.2'); 
     1077    my $infile = &FileUtils::filenameConcatenate($phinddir, 'phrases'); 
     1078    my $outfile = &FileUtils::filenameConcatenate($phinddir, 'phrases.2'); 
    10781079 
    10791080    # Read the phrase file.  Calculate initial set of phind-id 
     
    11861187 
    11871188    my $phinddir = $self->{'phinddir'}; 
    1188     my $infile = &util::filename_cat($phinddir, "phrases.2"); 
    1189     my $outfile = &util::filename_cat($phinddir, "phrases.3"); 
     1189    my $infile = &FileUtils::filenameConcatenate($phinddir, "phrases.2"); 
     1190    my $outfile = &FileUtils::filenameConcatenate($phinddir, "phrases.3"); 
    11901191 
    11911192 
     
    11941195    print $out "Translate phrases.2: no thesaurus data\n"  
    11951196        if ($verbosity); 
    1196     &util::mv($infile, $outfile); 
     1197    &FileUtils::moveFiles($infile, $outfile); 
    11971198    return; 
    11981199    } 
     
    12031204    # 1. 
    12041205    # Read thesaurus file and store (symbols->thesaurusid) mapping 
    1205     my $thesaurusfile = &util::filename_cat($phinddir, "$thesaurus.numbers"); 
     1206    my $thesaurusfile = &FileUtils::filenameConcatenate($phinddir, "$thesaurus.numbers"); 
    12061207    my %symbolstothesid; 
    12071208    my (@fields, $thesid, $symbols); 
     
    12761277    # Translate thesaurus file, replacing thesaurus-id numbers with  
    12771278    # phind-id numbers. 
    1278     my $newthesaurusfile = &util::filename_cat($phinddir, "$thesaurus.phindid"); 
     1279    my $newthesaurusfile = &FileUtils::filenameConcatenate($phinddir, "$thesaurus.phindid"); 
    12791280    my ($relations, $linkcounter, $linktext, $linktype, @linkdata); 
    12801281    my (@links, $linkid, %linkidtotype, $newrelation); 
     
    14161417 
    14171418    my $phinddir = $self->{'phinddir'}; 
    1418     my $infile = &util::filename_cat($phinddir, 'phrases.3'); 
    1419     my $vocabfile = &util::filename_cat($phinddir, 'clauses.vocab'); 
    1420     my $datafile = &util::filename_cat($phinddir, 'pdata.txt'); 
    1421     my $wordfile = &util::filename_cat($phinddir, 'pword.txt'); 
     1419    my $infile = &FileUtils::filenameConcatenate($phinddir, 'phrases.3'); 
     1420    my $vocabfile = &FileUtils::filenameConcatenate($phinddir, 'clauses.vocab'); 
     1421    my $datafile = &FileUtils::filenameConcatenate($phinddir, 'pdata.txt'); 
     1422    my $wordfile = &FileUtils::filenameConcatenate($phinddir, 'pword.txt'); 
    14221423 
    14231424    my $savephrases = $self->{'savephrases'};