Changeset 27904 for main/trunk/greenstone2
- Timestamp:
- 2013-07-18T19:40:51+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/classify/Phind.pm
r23116 r27904 33 33 34 34 use BaseClassifier; 35 use FileUtils; 35 36 use util; 36 37 use ghtml; … … 77 78 if (!defined $suffix || !defined $wanted_index_files{$suffix}) { 78 79 # delete it! 79 & util::rm (&util::filename_cat($dir, $file));80 &FileUtils::removeFiles (&FileUtils::filenameConcatenate ($dir, $file)); 80 81 } 81 82 } … … 166 167 167 168 # 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"); 169 170 $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"); 171 172 if (!(-e $file1)) { 172 173 print STDERR "Phind.pm: ERROR: The Phind \"suffix\" program is not installed.\n\n"; … … 186 187 $self->{'collectiondir'} = $ENV{'GSDLCOLLECTDIR'}; # collection directories 187 188 if (! defined $self->{'builddir'}) { 188 $self->{'builddir'} = & util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "building");189 $self->{'builddir'} = &FileUtils::filenameConcatenate($ENV{'GSDLCOLLECTDIR'}, "building"); 189 190 } 190 191 $self->{'total'} = 0; … … 212 213 # create Phind directory 213 214 my $phnumber = 1; 214 my $phinddir = & util::filename_cat($builddir, "phind1");215 my $phinddir = &FileUtils::filenameConcatenate($builddir, "phind1"); 215 216 while (-e "$phinddir") { 216 217 $phnumber++; 217 $phinddir = & util::filename_cat($builddir, "phind$phnumber");218 $phinddir = &FileUtils::filenameConcatenate($builddir, "phind$phnumber"); 218 219 } 219 220 &util::mk_dir("$phinddir"); … … 224 225 225 226 # 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); 228 229 229 230 my $txthandle = 'TEXT' . $phnumber; … … 231 232 $self->{'txthandle'} = $txthandle; 232 233 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); 235 236 236 237 my $dochandle = 'DOC' . $phnumber; … … 392 393 # check that we generated some files. It's not necessarily an error if 393 394 # 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'); 395 396 if (! -r $phrasesfile) { 396 397 print STDERR "<Warning name='NoPhrasesFound'/>\n" if $gli; … … 406 407 print $out "\nCreating phrase databases\n"; 407 408 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"); 410 411 411 412 &execute("mgpp_passes $osextra -f \"$mg_stem\" -T1 \"$mg_input\"", $verbosity, $out); … … 416 417 print $out "\nCreating word-level search indexes\n"; 417 418 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"); 420 421 421 422 &execute("mgpp_passes $osextra -f \"$mg_stem\" -T1 -I1 \"$mg_input\"", $verbosity, $out); … … 433 434 print $out "\nCreating document information databases\n"; 434 435 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"); 437 438 438 439 &execute("mgpp_passes $osextra -f \"$mg_stem\" -T1 \"$mg_input\"", $verbosity, $out); … … 714 715 715 716 # 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"); 717 718 my $stopword_files = (); 718 719 my ($language, $language_dir, $file, $file_name); … … 725 726 # Ignore entries that do not match the classifier's language 726 727 next unless ($language =~ /$language_exp/); 727 $language_dir = & util::filename_cat($stopdir, $language);728 $language_dir = &FileUtils::filenameConcatenate($stopdir, $language); 728 729 next unless (-d "$language_dir"); 729 730 … … 733 734 # Ignore entries that are not stopword files 734 735 next unless ($file =~ /sw$/); 735 $file_name = & util::filename_cat($language_dir, $file);736 $file_name = &FileUtils::filenameConcatenate($language_dir, $file); 736 737 next unless (-f "$file_name"); 737 738 … … 756 757 757 758 # link file exists 758 $thesaurus_links = & util::filename_cat($collectiondir, "etc", "$thesaurus.lnk");759 $thesaurus_links = &FileUtils::filenameConcatenate($collectiondir, "etc", "$thesaurus.lnk"); 759 760 die "Cannot find thesaurus link file" unless (-e "$thesaurus_links"); 760 761 … … 765 766 $language = 'en'; 766 767 } 767 $thesaurus_terms = & util::filename_cat($collectiondir, "etc", "$thesaurus.$language");768 $thesaurus_terms = &FileUtils::filenameConcatenate($collectiondir, "etc", "$thesaurus.$language"); 768 769 die "Cannot find thesaurus term file" unless (-e "$thesaurus_terms"); 769 770 … … 905 906 # Output statistics about the vocablary 906 907 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"); 908 909 909 910 open(STAT, ">$phinddir/clauses.stats") … … 972 973 if ($thesaurus) { 973 974 974 my $thesaurusfile = & util::filename_cat($phinddir, "$thesaurus.numbers");975 my $thesaurusfile = &FileUtils::filenameConcatenate($phinddir, "$thesaurus.numbers"); 975 976 976 977 … … 1074 1075 1075 1076 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'); 1078 1079 1079 1080 # Read the phrase file. Calculate initial set of phind-id … … 1186 1187 1187 1188 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"); 1190 1191 1191 1192 … … 1194 1195 print $out "Translate phrases.2: no thesaurus data\n" 1195 1196 if ($verbosity); 1196 & util::mv($infile, $outfile);1197 &FileUtils::moveFiles($infile, $outfile); 1197 1198 return; 1198 1199 } … … 1203 1204 # 1. 1204 1205 # 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"); 1206 1207 my %symbolstothesid; 1207 1208 my (@fields, $thesid, $symbols); … … 1276 1277 # Translate thesaurus file, replacing thesaurus-id numbers with 1277 1278 # phind-id numbers. 1278 my $newthesaurusfile = & util::filename_cat($phinddir, "$thesaurus.phindid");1279 my $newthesaurusfile = &FileUtils::filenameConcatenate($phinddir, "$thesaurus.phindid"); 1279 1280 my ($relations, $linkcounter, $linktext, $linktype, @linkdata); 1280 1281 my (@links, $linkid, %linkidtotype, $newrelation); … … 1416 1417 1417 1418 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'); 1422 1423 1423 1424 my $savephrases = $self->{'savephrases'};
Note:
See TracChangeset
for help on using the changeset viewer.