Changeset 12896
- Timestamp:
- 2006-09-28T13:40:40+12:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/classify/GenericList.pm
r12895 r12896 174 174 175 175 176 # Called for each document in the collection 176 177 sub classify 177 178 { … … 179 180 my $doc_obj = shift(@_); 180 181 181 my $doc_OID = $doc_obj->get_OID(); 182 182 # If "-classify_sections" is set, classify every section of the document 183 183 if ($self->{'classify_sections'}) { 184 184 my $section = $doc_obj->get_next_section($doc_obj->get_top_section()); 185 185 while (defined $section) { 186 $self->classify_section($doc_obj, $doc_ OID. ".$section", $section);186 $self->classify_section($doc_obj, $doc_obj->get_OID() . ".$section", $section); 187 187 $section = $doc_obj->get_next_section($section); 188 188 } 189 189 } 190 # Otherwise just classify the top document section 190 191 else { 191 $self->classify_section($doc_obj, $doc_ OID, $doc_obj->get_top_section());192 $self->classify_section($doc_obj, $doc_obj->get_OID(), $doc_obj->get_top_section()); 192 193 } 193 194 } … … 198 199 my $self = shift(@_); 199 200 my $doc_obj = shift(@_); 200 my $ doc_OID = shift(@_);201 my $section_OID = shift(@_); 201 202 my $section = shift(@_); 202 203 203 204 my @metadata_groups = @{$self->{'metadata_groups'}}; 204 205 205 # Only classify the document if it has a value for one of the metadata elements in the first group 206 foreach my $firstmetagroupelem (split(/\;/, $metadata_groups[0])) { 207 my $firstmetagroupelemvalue = $doc_obj->get_metadata_element($section, $firstmetagroupelem); 208 if (defined($firstmetagroupelemvalue) && $firstmetagroupelemvalue ne "") { 209 push(@{$self->{'OIDs'}}, $doc_OID); 210 211 # Create a hash for the metadata values of each metadata element we're interested in 212 my %metagroupsdone = (); 213 foreach my $metadata_group (@metadata_groups, @{$self->{'sort_leaf_nodes_using_metadata_groups'}}) { 214 # Take care not to do a metadata group more than once 215 unless ($metagroupsdone{$metadata_group}) { 216 foreach my $metaelem (split(/\;/, $metadata_group)) { 217 my @metavalues = @{$doc_obj->get_metadata($section, $metaelem)}; 218 foreach my $metavalue (@metavalues) { 219 # Strip leading and trailing whitespace 220 $metavalue =~ s/^\s*//; 221 $metavalue =~ s/\s*$//; 222 push(@{$self->{$metadata_group . ".list"}->{$doc_OID}}, $metavalue); 223 } 224 last if (@metavalues > 0); 225 } 226 227 $metagroupsdone{$metadata_group} = 1; 206 # Only classify the section if it has a value for one of the metadata elements in the first group 207 my $classify_section = 0; 208 my $first_metadata_group = $metadata_groups[0]; 209 foreach my $first_metadata_group_element (split(/\;/, $first_metadata_group)) { 210 my $first_metadata_group_element_value = $doc_obj->get_metadata_element($section, $first_metadata_group_element); 211 if (defined($first_metadata_group_element_value) && $first_metadata_group_element_value ne "") { 212 # This section must be included in the classifier 213 $classify_section = 1; 214 last; 215 } 216 } 217 218 # We're not classifying this section because it doesn't have the required metadata 219 return if (!$classify_section); 220 221 # Otherwise, include this section in the classifier 222 push(@{$self->{'OIDs'}}, $section_OID); 223 224 # Create a hash for the metadata values of each metadata element we're interested in 225 my %metadata_groups_done = (); 226 foreach my $metadata_group (@metadata_groups, @{$self->{'sort_leaf_nodes_using_metadata_groups'}}) { 227 # Take care not to do a metadata group more than once 228 unless ($metadata_groups_done{$metadata_group}) { 229 foreach my $metadata_element (split(/\;/, $metadata_group)) { 230 my @metadata_values = @{$doc_obj->get_metadata($section, $metadata_element)}; 231 foreach my $metadata_value (@metadata_values) { 232 # Strip leading and trailing whitespace 233 $metadata_value =~ s/^\s*//; 234 $metadata_value =~ s/\s*$//; 235 push(@{$self->{$metadata_group . ".list"}->{$section_OID}}, $metadata_value); 228 236 } 229 } 230 231 last; 237 last if (@metadata_values > 0); 238 } 239 240 $metadata_groups_done{$metadata_group} = 1; 232 241 } 233 242 } … … 239 248 my $self = shift(@_); 240 249 241 # The metadata elements to classify by250 # The metadata groups to classify by 242 251 my @metadata_groups = @{$self->{'metadata_groups'}}; 243 252 my $first_metadata_group = $metadata_groups[0]; 244 253 245 # The OID values of the documents to include in the classifi cation254 # The OID values of the documents to include in the classifier 246 255 my @OIDs = @{$self->{'OIDs'}}; 247 256 248 # The root node of the classification hierarchy257 # Create the root node of the classification hierarchy 249 258 my %classifier_node = ( 'thistype' => "Invisible", 250 259 'childtype' => $self->{$first_metadata_group . ".list_type"},
Note:
See TracChangeset
for help on using the changeset viewer.