Ignore:
Timestamp:
2004-03-08T15:31:35+13:00 (20 years ago)
Author:
kjdon
Message:

added a new load_classifier_for_info method which is used by classinfo.pl - this one adds a new arg into the classifier options (-gsdlinfo), so that the arguments are not parsed - some classifiers die if their required args are not set, but don't want this to happen for classinfo.pl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/classify.pm

    r6964 r6967  
    4040$next_classify_num = 1;
    4141$collage = 0;
     42sub load_classifier_for_info {
     43    my ($classifier) = shift @_;
     44
     45    # find the classifier
     46    my $colclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},
     47                       "perllib/classify",
     48                       "${classifier}.pm");
     49    my $mainclassname = &util::filename_cat($ENV{'GSDLHOME'},
     50                        "perllib/classify",
     51                        "${classifier}.pm");
     52
     53    if (-e $colclassname) { require $colclassname; }
     54    elsif (-e $mainclassname) { require $mainclassname; }
     55    else {
     56    &gsprintf(STDERR, "{classify.could_not_find_classifier}\n", $classifier) && die "\n";
     57    }
     58    my ($classobj);
     59    my $options = "-gsdlinfo";
     60
     61    eval ("\$classobj = new \$classifier($options)");
     62    die "$@" if $@;
     63
     64    return $classobj;
     65}
    4266
    4367sub load_classifiers {
     
    6690    my ($classobj);
    6791
    68     # backwards compatability hack: if the classifier options are
    69     # in "x=y" format, convert them to parsearg ("-x y") format.
    70     my ($opt, $key, $value);
    7192    my @newoptions;
    7293
     
    7697    push @newoptions, "-verbosity", "2";
    7798
     99    # backwards compatability hack: if the classifier options are
     100    # in "x=y" format, convert them to parsearg ("-x y") format.
     101    my ($opt, $key, $value);
    78102    foreach $opt (@$classifyoption) {
    79103        if ($opt =~ /^(\w+)=(.*)$/) {
Note: See TracChangeset for help on using the changeset viewer.