Changeset 22175

Show
Ignore:
Timestamp:
26.05.2010 10:56:52 (9 years ago)
Author:
kjdon
Message:

remove prefix and suffix are defined per metadata group, not per element in the group. So find the expr for the group then use it on each element

Files:
1 modified

Legend:

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

    r21969 r22175  
    317317    my $classify_section = 0; 
    318318    my $first_metadata_group = $metadata_groups[0]; 
     319    my $remove_prefix_expr = $self->{$first_metadata_group . ".remove_prefix_expr"}; 
     320    my $remove_suffix_expr = $self->{$first_metadata_group . ".remove_suffix_expr"}; 
    319321    foreach my $first_metadata_group_element (split(/\;|,/, $first_metadata_group)) { 
    320322    my $real_first_metadata_group_element = $self->strip_ex_from_metadata($first_metadata_group_element); 
     
    322324     
    323325    # Remove prefix/suffix if requested 
    324     my $remove_prefix_expr = $self->{$first_metadata_group_element . ".remove_prefix_expr"}; 
    325     if (defined $remove_prefix_expr && $remove_prefix_expr ne "") {      
    326         $first_metadata_group_element_value =~ s/^$remove_prefix_expr//; 
    327     } 
    328     my $remove_suffix_expr = $self->{$first_metadata_group_element . ".remove_suffix_expr"}; 
    329     if (defined $remove_suffix_expr && $remove_suffix_expr ne "") { 
    330         $first_metadata_group_element_value =~ s/$remove_suffix_expr$//; 
    331     } 
    332  
     326    if (defined ($first_metadata_group_element_value)) { 
     327        if (defined $remove_prefix_expr && $remove_prefix_expr ne "") {      
     328        $first_metadata_group_element_value =~ s/^$remove_prefix_expr//; 
     329        } 
     330         
     331        if (defined $remove_suffix_expr && $remove_suffix_expr ne "") { 
     332        $first_metadata_group_element_value =~ s/$remove_suffix_expr$//; 
     333        } 
     334    } 
    333335    if (defined($first_metadata_group_element_value) && $first_metadata_group_element_value ne "") { 
    334336        # This section must be included in the classifier 
     
    362364        delete $self->{$metadata_group . ".list"}->{$section_OID}; 
    363365        } 
     366 
     367        my $remove_prefix_expr = $self->{$metadata_group . ".remove_prefix_expr"}; 
     368        my $remove_suffix_expr = $self->{$metadata_group . ".remove_suffix_expr"}; 
    364369        foreach my $metadata_element (split(/\;|,/, $metadata_group)) {      
    365370        my $real_metadata_element = $self->strip_ex_from_metadata($metadata_element); 
    366371         
    367         my $remove_prefix_expr = $self->{$metadata_element . ".remove_prefix_expr"}; 
    368         my $remove_suffix_expr = $self->{$metadata_element . ".remove_suffix_expr"}; 
    369372        my @metadata_values = @{$doc_obj->get_metadata($section, $real_metadata_element)}; 
    370373        foreach my $metadata_value (@metadata_values) {