Ignore:
Timestamp:
2001-01-16T11:50:05+13:00 (23 years ago)
Author:
paynter
Message:

Updated classifiers to use the parsearg library instead of ad-hoc
"x=y" style parsing. (Backwards compatability maintained through
a quick hack to the load_classifier function in classfy.pm.)

File:
1 edited

Legend:

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

    r1515 r1839  
    3434
    3535sub load_classifiers {
    36     my ($classify_list) = @_;
     36    my ($classify_list, $build_dir, $outhandle) = @_;
    3737    my @classify_objects = ();
    3838   
    39     my $outhandle = pop (@_);
    40 
    4139    foreach $classifyoption (@$classify_list) {
    4240
     
    4442    my $classname = shift @$classifyoption;
    4543    next unless defined $classname;
    46    
     44
    4745    # find the classifier
    4846    my $colclassname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib/classify",
     
    5755    # create the classify object
    5856    my ($classobj);
    59     map { $_ = "\"$_\""; } @$classifyoption;
    60     my $options = join (",", @$classifyoption, $outhandle);
     57
     58    # backwards compatability hack: if the classifier options are
     59    # in "x=y" format, convert them to parsearg ("-x y") format.
     60    my ($opt, $key, $value);
     61    my @newoptions;
     62    foreach $opt (@$classifyoption) {
     63        if ($opt =~ /^(\w+)=(.*)$/) {
     64        push @newoptions, "-$1", $2;
     65        } else {
     66        push @newoptions, $opt;
     67        }
     68    }
     69    push @newoptions, "-builddir", "$build_dir";
     70    push @newoptions, "-outhandle", "$outhandle";
     71    push @newoptions, "-verbosity", "2";
     72
     73    map { $_ = "\"$_\""; } @newoptions;
     74    my $options .= join (",", @newoptions);
     75
     76    # print STDERR "$classname\noptions: $options\n";
    6177    eval ("\$classobj = new \$classname($options)");
    6278    die "$@" if $@;
    63    
    64     # add this object to the list
     79
     80        # add this object to the list
    6581    push (@classify_objects, $classobj);
    6682    }
Note: See TracChangeset for help on using the changeset viewer.