--- loncom/thesaurus/build_thesaurus_db.pl 2002/07/11 20:48:31 1.1 +++ loncom/thesaurus/build_thesaurus_db.pl 2003/08/05 15:51:37 1.2 @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: build_thesaurus_db.pl,v 1.1 2002/07/11 20:48:31 matthew Exp $ +# $Id: build_thesaurus_db.pl,v 1.2 2003/08/05 15:51:37 matthew Exp $ # # # build_thesaurus_db.pl creates the LON-CAPA thesaurus database. @@ -124,13 +124,15 @@ build_thesaurus_db.pl --badwordfile ./un ## ## Get command line parameters ## -my ($badwordfile,$outputdbfile,$keywordfile,$help,$test); +my ($badwordfile,$outputdbfile,$keywordfile,$help,$checkdates,$test); GetOptions( "badwordfile=s" => \$badwordfile, # --badwordfile "outputdb=s" => \$outputdbfile, # --outputdb "keywordfile=s" => \$keywordfile, # --keywordfile "help" => \$help, # --help + "checkdates" => \$checkdates, # --checkdates "test" => \$test); # --test + ## ## Help! Help! ## @@ -143,6 +145,9 @@ Command line arguements put in the thesaurus. Each word must appear on its own line and currently comments are not supported. + --checkdates Check the creation dates on the files involved + and only run if the outputdb file was created + prior to one of the badword or keyword files. --keywordfile File containing the raw word data for the thesaurus. Each line must be comma seperated list of related keywords. @@ -171,6 +176,25 @@ foreach my $file ($badwordfile,$keywordf die "$file does not exist." if (! -e $file); } +# +# Check the dates on the input files to be sure we need to run +if ($checkdates && -s $outputdbfile) { + my @Results = stat($badwordfile); + my $highest_dependency_ctime = $Results[10]; + foreach ($keywordfile) { + if ($Results[10] > $highest_dependency_ctime) { + $highest_dependency_ctime = $Results[10]; + } + } + # + # if the outputdbfile was made AFTER the last version of one of the + # dependencies, exit quietly. + @Results = stat($outputdbfile); + if ($highest_dependency_ctime < $Results[10]) { + exit; + } +} + ## ## Global hashes. ##