Changeset 2954


Ignore:
Timestamp:
2002-02-07T16:18:36+13:00 (22 years ago)
Author:
jrm21
Message:

added a remove_prefix option to strip from metadata before sorting for
classification. (eg remove "re:" or "fwd:" from email subject lines first).

Location:
trunk/gsdl/perllib/classify
Files:
2 edited

Legend:

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

    r2022 r2954  
    4141  options:
    4242 
    43   -metadata X     (required) Metadata field used for classification.
    44                   List will be sorted by this element.
    45 
    46   -buttonname X   (optional) Button name for this classification.
    47                   defaults to metadata name.
     43  -metadata X           (required) Metadata field used for classification.
     44                        List will be sorted by this element.
     45
     46  -buttonname X         (optional) Button name for this classification.
     47                        defaults to metadata name.
     48
     49  -removeprefix regex   (optional) A prefix to ignore in the Metadata values
     50                        for the field when sorting.
    4851";
    4952}
     
    5356    my $self = new BasClas($class, @_);
    5457   
    55     my ($metaname, $title);
     58    my ($metaname, $title, $removeprefix);
    5659   
    5760    if (!parsargv::parse(\@_,
    5861             q^metadata/.*/^, \$metaname,
    5962             q^buttonname/.*/^, \$title,
     63             q^removeprefix/.*/^, \$removeprefix,
    6064             "allow_extra_options")) {
    6165   
     
    7680    $self->{'metaname'} = $metaname;
    7781    $self->{'title'} = $title;
     82    if (defined($removeprefix) && $removeprefix) {
     83    $self->{'removeprefix'} = $removeprefix;
     84    }
    7885
    7986    return bless $self, $class;
     
    97104    # sorting by we won't include it in this classification
    98105    if (defined $metavalue && $metavalue ne "") {
     106    if ($self->{'removeprefix'}) {
     107        $metavalue =~ s/^$self->{'removeprefix'}//;
     108    }
     109
    99110    if ($self->{'metaname'} eq 'Language') {
    100111        $metavalue = $iso639::fromiso639{$metavalue};
  • trunk/gsdl/perllib/classify/AZSectionList.pm

    r2022 r2954  
    4545sub print_usage {
    4646    print STDERR "
    47   usage: classify AZSectionList [options]
     47  usage: classify AZSectionList -metadata X [options]
    4848  options:
    4949
    50    -metadata X    Metadata field used for classification,
    51                   list will be sorted by this element.
     50  -metadata X       (required) Metadata field used for classification.
     51            List will be sorted by this element.
    5252
    53    -buttonname X  (OPTIONAL) Title field for this classification.
    54                   if not included title field will be Metaname.
     53  -buttonname X     Button name for this classification.
     54            defaults to metadata name.
     55
     56  -removeprefix regex   A prefix to ignore in the Metadata values
     57            for the field when sorting.
    5558
    5659This is very similar to AZList except it sorts by section level metadata
     
    8992    # sorting by we won't include it in this classification
    9093    if (defined $metavalue && $metavalue ne "") {
     94    if ($self->{'removeprefix'}) {
     95        $metavalue =~ s/^$self->{'removeprefix'}//;
     96    }
     97
    9198    if ($self->{'metaname'} eq 'Creator') {
    9299        &sorttools::format_string_name_english (\$metavalue);
Note: See TracChangeset for help on using the changeset viewer.