Changeset 6956


Ignore:
Timestamp:
2004-03-08T12:41:23+13:00 (20 years ago)
Author:
kjdon
Message:

removed some commented out stuff, added a new subroutine: format_metadata_for_sorting. all classifiers do this stuff, and they all do it a bit differently - put it here so they can share it and keep it consistent

File:
1 edited

Legend:

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

    r6945 r6956  
    210210
    211211
    212 #  sub print_general_usage {
    213 #      my ($plugin_name) = @_;
    214 #      print STDERR "
    215 #     -verbosity N    Controls the quantity of output. 
    216 #                     Defaults to verbosity of buildcol.pl, which is usually 2.
    217 
    218 #     (Most general classifier options are set internally by buildcol.)
    219 
    220 #  ";
    221 #  }
    222 
    223 # sub print_usage {
    224 #     print STDERR "
    225 # This classifier has no classifier-specific options
    226 #
    227 # ";
    228 # }
    229 
    230212sub new {
    231213    my $class = shift (@_);
     
    247229
    248230    &gsprintf(STDERR, "\n{BasClas.bad_general_option}\n", $name);
    249     # print STDERR "\nThe $name classifier uses an incorrect general option\n";
    250     # print STDERR "(general options are those available to all classifiers).\n";
    251     # print STDERR "Check your collect.cfg configuration file.\n";
    252231    $self->print_txt_usage("");  # Use default resource bundle
    253232    die "\n";
     
    267246    my $outhandle = $self->{'outhandle'};
    268247    &gsprintf($outhandle, "BasClass::classify {common.must_be_implemented}\n");
    269     # print $outhandle "BasClas::classify function must be implemented in sub-class\n";
    270248}
    271249
     
    275253    my $outhandle = $self->{'outhandle'};
    276254    &gsprintf($outhandle, "BasClass::get_classify_info {common.must_be_implemented}\n");
    277     # print $outhandle "BasClas::get_classify_info function must be implemented in sub-class\n";
    278 }
     255}
     256
     257# all classifiers do something like this, but all slightly different
     258# so put it here so they can all share it.
     259sub format_metadata_for_sorting {
     260
     261    my $self = shift (@_);
     262
     263    my ($metaname, $metavalue, $doc_obj) = @_;
     264   
     265    if ($metaname eq "Language") {
     266    $metavalue = $iso639::fromiso639{$metavalue};
     267    return $metavalue;
     268    }
     269   
     270    my $lang = $doc_obj->get_metadata_element ($doc_obj->get_top_section(), 'Language');
     271    $lang = 'en' unless defined $lang;
     272    if ($lang eq 'en') {
     273    if ($metaname eq "Creator") {
     274        &sorttools::format_string_name_english (\$metavalue);
     275    } else {
     276        &sorttools::format_string_english (\$metavalue);
     277    }
     278    }
     279    return $metavalue;
     280}
     281
    279282
    2802831;
Note: See TracChangeset for help on using the changeset viewer.