Changeset 7835


Ignore:
Timestamp:
2004-08-02T15:41:33+12:00 (20 years ago)
Author:
jrm21
Message:

record mdoffset for each document when adding to a sub list. List.pm checks
for this offset in the document, and uses it if found.

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

Legend:

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

    r7704 r7835  
    237237$tmp = 0;
    238238
    239 sub classify 
     239sub classify
    240240{
    241241    my $self = shift (@_);
     
    414414    if ($mtfreq{$metavalue} >= $self->{'mingroup'})
    415415    {
     416        # occurs more often than minimum required to compact into a group
    416417        my $listclassobj;
    417418        my $doclevel = $self->{'doclevel'};
     
    518519        my ($doc_obj,$date) = @{$self->{'reclassify'}->{$doc_OID}};
    519520
     521        # record the metadata value offset temporarily, so eg AZList can
     522        # get the correct metadata value (for multi-valued metadata fields)
     523        $doc_obj->{'mdoffset'}=$mdoffset;
     524
    520525        ## date appears to not be used in classifier call ####
    521526
     
    723728
    724729    # only want first character for classification
    725     $title =~ m/^(.)/;
     730    $title =~ m/^(.)/; # always a char, or first byte of wide char?
    726731    if (defined($1) && $1 ne "") {
    727732        $title=$1;
     
    753758    push (@tmparr, '0-9');
    754759    }
    755 
    756760    foreach $subclass (@tmparr)
    757761    {
     
    767771        && defined $self->{'classifiers'}->{$1})
    768772        {
     773        # this is a "bookshelf" node... >1 entry compacted
    769774                push (@{$tempclassify->{'contains'}},
    770775              $self->{'classifiers'}->{$1}->{'classifyinfo'});
     776        # set the metadata field name, for mdoffset to work
     777        $self->{'classifiers'}->{$1}->{'classifyinfo'}->{'mdtype'}=
     778            $metaname;
    771779        }
    772780        else
    773781        {
    774782        $subsubOID =~ s/^Metavalue_(\d+)\.//;
     783        # record the offset if this metadata type has multiple values
    775784        my $metaname_offset = $1 -1;
    776785        my $oid_rec = {'OID'=>$subsubOID, 'offset'=>$metaname_offset};
  • trunk/gsdl/perllib/classify/List.pm

    r6968 r7835  
    153153    my $metaname;
    154154    if (defined $self->{'meta_list'}) {
    155     # find the first available metadata
    156     foreach $m (@{$self->{'meta_list'}}) {
    157         $metavalue = $doc_obj->get_metadata_element($doc_obj->get_top_section(), $m);
    158         $metaname = $m;
    159         last if defined $metavalue;
     155    my $topsection=$doc_obj->get_top_section();
     156
     157    # find the correct bit of metadata, if multi-valued metadata field
     158    if (exists $doc_obj->{'mdoffset'}) { # set by AZCompactList
     159        my $mdoffset=$doc_obj->{'mdoffset'} - 1;
     160        # if this List is used by AZCompactList, then $metavalue is
     161        # only really needed for sorting.
     162        # assume (!!) there is only one fieldname in the meta_list
     163        $metaname=(@{$self->{'meta_list'}})[0];
     164        # get all metadata values for this field
     165        my $values_listref=
     166        $doc_obj->get_metadata($topsection, $metaname);
     167        # get the correct one (from the offset)
     168        $metavalue=@$values_listref[$mdoffset];
     169        # use a special format for docOID...
     170        $doc_OID .= ".offset$mdoffset";
     171
     172    } else {
     173        # use the first available metadata
     174        foreach my $m (@{$self->{'meta_list'}}) {
     175        $metavalue = $doc_obj->
     176            get_metadata_element($topsection, $m);
     177        $metaname = $m;
     178        last if defined $metavalue;
     179        }
    160180    }
    161     #if we haven't found a metavalue here, then the doc shouldn't be included
     181    # if we haven't found a metavalue, then the doc shouldn't be included
    162182    return unless defined $metavalue;
    163183    }
     
    213233
    214234    foreach $OID (@list) {
    215     push (@{$classifyinfo{'contains'}}, {'OID'=>$OID});
     235    my $hashref={};
     236    # special oid format, if using offsets (from AZCompactList)
     237    if ($OID =~ s/\.offset(\d+)$//) {
     238        $hashref->{'offset'}=$1;
     239    }
     240    $hashref->{'OID'}=$OID;
     241
     242    push (@{$classifyinfo{'contains'}}, $hashref);
    216243    }
    217244
Note: See TracChangeset for help on using the changeset viewer.