Changeset 27098

Show
Ignore:
Timestamp:
19.03.2013 15:27:51 (7 years ago)
Author:
kjdon
Message:

new option for List: standardize_capitalization. If set, then bookshelf names will be lowercase. If not set, the majority case variant will be used instead

Location:
main/trunk/greenstone2/perllib
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/classify/List.pm

    r26545 r27098  
    114114       'desc' => "{List.filter_regex}", 
    115115       'type' => "regexp"}, 
    116        
     116      { 'name' => "standardize_capitalization", 
     117    'desc' => "{List.standardize_capitalization}", 
     118    'type' => "flag"}, 
    117119      { 'name' => "removeprefix", 
    118120    'desc' => "{BasClas.removeprefix}", 
     
    404406            # text-transform the stored lowercase values as capitalize or uppercase (can't CSS  
    405407            # text-transform if stored uppercase). 2 CSS text-transforms have been added to core.css 
    406             $metadata_value = lc($metadata_value); 
     408            my $lc_metadata_value = lc($metadata_value); 
    407409             
    408410            # We are already working with unicode aware strings at this  
    409411            # stage, so we no longer need to convert from utf8 to unicode  
    410             my $metadata_value_unicode_string = $metadata_value; # $self->convert_utf8_string_to_unicode_string($metadata_value); 
     412            #my $metadata_value_unicode_string = $metadata_value; # $self->convert_utf8_string_to_unicode_string($metadata_value); 
    411413 
    412414            # Add the metadata value into the list for this combination of metadata group and section 
    413             push(@{$self->{$metadata_group . ".list"}->{$section_OID}}, $metadata_value_unicode_string); 
     415            push(@{$self->{$metadata_group . ".list"}->{$section_OID}}, $lc_metadata_value); 
     416            # add the actual value into the stored values so we can remember the case 
     417            if (!$self->{'standardize_capitalization'}) { 
     418            if (defined $self->{$metadata_group . ".actualvalues"}->{$lc_metadata_value}->{$metadata_value}) { 
     419                $self->{$metadata_group . ".actualvalues"}->{$lc_metadata_value}->{$metadata_value}++; 
     420            } else { 
     421                $self->{$metadata_group . ".actualvalues"}->{$lc_metadata_value}->{$metadata_value} = 1; 
     422            } 
     423            }        
    414424        } 
    415425        last if (@metadata_values > 0); 
     
    801811    # Otherwise create a sublist (bookshelf) for the metadata value 
    802812    else { 
     813        my $metadata_value_display = $self->get_metadata_value_display($metadata_group, $metadata_value); 
    803814        # Note that we don't need to convert from unicode-aware strings  
    804815        # to utf8 here, as that is handled elsewhere in the code 
    805         my %child_classifier_node = ( 'Title' => $metadata_value, # 'Title' => $self->convert_unicode_string_to_utf8_string($metadata_value), 
     816        my %child_classifier_node = ( 'Title' => $metadata_value_display, # 'Title' => $self->convert_unicode_string_to_utf8_string($metadata_value), 
    806817                      'childtype' => "VList", 
    807818                      'mdtype' => $metadata_group, 
     
    918929} 
    919930 
    920  
     931sub get_metadata_value_display { 
     932    my $self = shift(@_); 
     933    my ($metadata_group, $metadata_value) = @_; 
     934    return $metadata_value if $self->{'standardize_capitalization'}; 
     935    my $actual_values_hash = $self->{$metadata_group . ".actualvalues"}->{$metadata_value}; 
     936    my $display_value =""; 
     937    my $max_count=0; 
     938    foreach my $v (keys %$actual_values_hash) { 
     939    if ($actual_values_hash->{$v} > $max_count) { 
     940        $display_value = $v; 
     941        $max_count = $actual_values_hash->{$v}; 
     942    } 
     943    } 
     944    return $display_value; 
     945} 
    9219461; 
  • main/trunk/greenstone2/perllib/strings.properties

    r26976 r27098  
    654654List.sort_using_unicode_collation:Sort using the Unicode Collation Algorithm. Requires http://www.unicode.org/Public/UCA/latest/allkeys.txt file to be downloaded into perl's lib/Unicode/Collate folder. 
    655655 
     656List.standardize_capitalization:Metadata values are lowercased for sorting into bookshelves. Set this option to use these lowercase values for bookshelf display names. Otherwise, the majority case variant will be used. 
     657 
    656658List.use_hlist_for:Metadata fields to use a hlist rather than a vlist. Use ',' to separate the metadata groups and ';' to separate the metadata fields within each group. 
    657659