Ignore:
Timestamp:
1999-07-14T14:54:20+12:00 (25 years ago)
Author:
sjboddie
Message:

moved string formatting for sorting into it's own module

File:
1 edited

Legend:

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

    r316 r385  
    1010
    1111package List;
     12
     13use sorttools;
    1214
    1315sub new {
     
    4648    if (defined $metavalue) {
    4749        if ($self->{'metaname'} eq 'Creator') {
    48         $self->format_string_name_english (\$metavalue);
     50        &sorttools::format_string_name_english (\$metavalue);
    4951        } else {
    50         $self->format_string_english (\$metavalue);
     52        &sorttools::format_string_english (\$metavalue);
    5153        }
    5254        if (defined $self->{'list'}->{$doc_OID}) {
     
    8890
    8991
    90 # format an english name for sorting
    91 # i.e. convert to lowercase, put surname before
    92 # first names etc.   
    93 sub format_string_name_english {
    94     my $self = shift (@_);
    95     my ($stringref) = @_;
    96 
    97     $$stringref =~ tr/A-Z/a-z/;
    98     $$stringref =~ s/[^a-z0-9 ]//g;
    99     $$stringref =~ s/\s+/ /g;
    100     $$stringref =~ s/^\s+//;
    101     my @names = split / /, $$stringref;
    102     my $surname = pop @names;
    103     while (scalar @names && $surname =~ /^(jnr|snr)$/i) {
    104     $surname = pop @names;
    105     }
    106     $$stringref = $surname . " " . $$stringref;
    107 }
    108 
    109 # format an english string for sorting
    110 # i.e. convert to lowercase, remove the, a or an
    111 # from beginning of string etc.
    112 sub format_string_english {
    113     my $self = shift (@_);
    114     my ($stringref) = @_;
    115 
    116     $$stringref =~ tr/A-Z/a-z/;
    117     $$stringref =~ s/[^a-z0-9 ]//g;
    118     $$stringref =~ s/^\s*(the|a|an)\b//;
    119     $$stringref =~ s/^\s+//;
    120 }
    121 
    122 
    123921;
Note: See TracChangeset for help on using the changeset viewer.