Changeset 2955 for trunk/gsdl/perllib/classify/AZCompactList.pm
- Timestamp:
- 2002-02-07T16:28:48+13:00 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/classify/AZCompactList.pm
r2897 r2955 52 52 sub print_usage { 53 53 print STDERR " 54 usage: classify AZCompactList [options]54 usage: classify AZCompactList -metadata X [options] 55 55 options: 56 -metadata 57 -buttonname Title to use on web pages58 59 - mingroup60 -min nesting61 -min compact62 -m axcompact63 - doclevel64 -onlyfirst 56 -metadata X (required) Metadata field used for classification 57 -buttonname X Title to use on web pages (defaults to metadata) 58 -removeprefix regex pattern to remove from metadata before sorting 59 -doclevel top|section (Defaults to top) 60 -mingroup N Minimum num of documents required to form a new group 61 -minnesting N Minimum list size to become a nested list 62 -mincompact N Used in compact list 63 -maxcompact N Used in compact list 64 -onlyfirst Only use the first value if metadata is repeated. 65 65 -recopt 66 66 "; … … 71 71 my $self = new BasClas($class, @_); 72 72 73 my ($metaname, $title );73 my ($metaname, $title, $removeprefix); 74 74 my $mingroup = 2; 75 75 my $minnesting = 20; … … 83 83 q^metadata/.*/^, \$metaname, 84 84 q^buttonname/.*/^, \$title, 85 85 q^removeprefix/.*/^, \$removeprefix, 86 86 q^mingroup/.*/2^, \$mingroup, 87 87 q^minnesting/.*/20^, \$minnesting, … … 99 99 } 100 100 101 # These are the old-fashioned optins to AZCompactList.102 # They should be deleted once we're sure the parsearg version is working.103 # foreach $option (@options) {104 # if ($option =~ /^metadata=(.*)$/i) {105 # $metaname = $1;106 # } elsif ($option =~ /^title=(.*)$/i) {107 # $title = $1;108 # } elsif ($option =~ /^mingroup(size)?=(.*)$/i) {109 # $mingroup = $2;110 # } elsif ($option =~ /^minnesting=(.*)$/i) {111 # $minnesting = $1;112 # } elsif ($option =~ /^mincompact=(.*)$/i) {113 # $mincompact = $1;114 # } elsif ($option =~ /^maxcompact=(.*)$/i) {115 # $maxcompact = $1;116 # } elsif ($option =~ /^doclevel=(.*)$/i) {117 # $doclevel = $1;118 # } elsif ($option =~ /^onlyfirst$/i) {119 # $onlyfirst = 1;120 # } elsif ($option =~ /^recopt$/i) {121 # $recopt = "on";122 # }123 # }124 125 101 if (!defined $metaname) { 126 102 my $outhandle = $self->{'outhandle'}; … … 137 113 $self->{'metaname'} = $metaname; 138 114 $self->{'title'} = "$title"; # title for the titlebar. 115 if (defined($removeprefix) && $removeprefix) { 116 $self->{'removeprefix'} = $removeprefix; 117 } 139 118 $self->{'mingroup'} = $mingroup; 140 119 $self->{'minnesting'} = $minnesting; … … 216 195 foreach $metavalue (@$metavalues) 217 196 { 218 ### print STDERR "$metaname :\tmetavalue = $metavalue\n";219 197 # if this document doesn't contain the metadata element we're 220 198 # sorting by we won't include it in this classification 221 199 if (defined $metavalue && $metavalue =~ /\w/) 222 200 { 201 if ($self->{'removeprefix'}) { 202 $metavalue =~ s/^$self->{'removeprefix'}//; 203 } 204 223 205 my $formatted_metavalue = $metavalue; 206 224 207 if ($self->{'metaname'} =~ m/^Creator(:.*)?$/) 225 208 { … … 231 214 } 232 215 216 #### prefix-str 217 if (! defined($formatted_metavalue)) { 218 print $outhandle "Warning: AZCompactList: metavalue is "; 219 print $outhandle "empty\n"; 220 $formatted_metavalue=""; 221 } 222 233 223 push(@{$self->{'list'}->{$full_doc_OID}},$formatted_metavalue); 234 224 push(@{$self->{'listmetavalue'}->{$full_doc_OID}} ,$metavalue); … … 245 235 { 246 236 my ($self,$classlist_ref) = @_; 237 my $outhandle = $self->{'outhandle'}; 247 238 248 239 my %mtfreq = (); … … 294 285 else 295 286 { 296 my $outhandle = $self->{'outhandle'};297 287 print $outhandle "AZCompactList ERROR - couldn't find classifier \"$listname\"\n"; 298 288 die "\n"; … … 342 332 } 343 333 if ($@) { 344 my $outhandle = $self->{'outhandle'};345 334 print $outhandle "$@"; 346 335 die "\n"; … … 352 341 { 353 342 my $formatted_node = $metavalue; 343 344 if ($self->{'removeprefix'}) { 345 $formatted_node =~ s/^$self->{'removeprefix'}//; 346 } 347 354 348 if ($self->{'metaname'} =~ m/^Creator(:.*)?$/) 355 349 { … … 360 354 &sorttools::format_string_english(\$formatted_node); 361 355 } 362 356 357 # In case our formatted string is empty... 358 if (! defined($formatted_node)) { 359 print $outhandle "Warning: AZCompactList: metavalue is "; 360 print $outhandle "empty\n"; 361 $formatted_node=""; 362 } 363 363 364 $self->{'classifiers'}->{$metavalue} 364 365 = { 'classifyobj' => $listclassobj, … … 418 419 my $outhandle=$self->{outhandle}; 419 420 print $outhandle "Warning: AZCompactList::reclassify "; 420 print $outhandle "could not find sub-node for $metavaluewith doc_OID $doc_OID\n";421 print $outhandle "could not find sub-node for metadata=`$metavalue' with doc_OID $doc_OID\n"; 421 422 } 422 423 }
Note:
See TracChangeset
for help on using the changeset viewer.