Changeset 24691 for main/trunk/greenstone2
- Timestamp:
- 2011-09-29T16:51:48+13:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/classify/AZCompactList.pm
r23354 r24691 27 27 package AZCompactList; 28 28 29 use strict; 30 no strict 'refs'; # allow filehandles to be variables and viceversa 31 29 32 use BaseClassifier; 30 33 use sorttools; 31 34 32 use strict; 33 no strict 'refs'; # allow filehandles to be variables and viceversa 35 use Unicode::Normalize; 34 36 35 37 sub BEGIN { … … 40 42 [ { 'name' => "top", 41 43 'desc' => "{AZCompactList.doclevel.top}" }, 44 { 'name' => "firstlevel", 45 'desc' => "{AZCompactList.doclevel.firstlevel}" }, 42 46 { 'name' => "section", 43 47 'desc' => "{AZCompactList.doclevel.section}" } ]; … … 200 204 push(@sectionlist,$topsection); 201 205 } 202 else 206 elsif ($self->{'doclevel'} =~ /^first(level)?/i) 207 { 208 my $toplevel_children = $doc_obj->get_children($topsection); 209 push(@sectionlist,@$toplevel_children); 210 } 211 else # (all)?section(s)? 203 212 { 204 213 my $thissection = $doc_obj->get_next_section($topsection); … … 389 398 else 390 399 { 400 # first(level)? or (all)?section(s)? 391 401 eval ("\$listclassobj = new SectionList([],\$ptArgs)"); 392 402 } … … 489 499 { 490 500 my $section=$1; 491 if ($self->{'doclevel'} =~ m/^top /i) { # toplevel501 if ($self->{'doclevel'} =~ m/^top(level)?/i) { # toplevel 492 502 $self->{'classifiers'}->{$node_name}->{'classifyobj'} 493 503 ->classify($doc_obj,"Section=$section"); 494 } else { # section level 495 # Thanks to Don Gourley for this... 496 # classify can't handle multi-level section 504 } else { 505 # first(level)? or (all)?section(s)? 506 507 # classify() can't handle multi-level section, so use 508 # classify_section() 509 # ... thanks to Don Gourley for this... 510 497 511 $self->{'classifiers'}->{$node_name}->{'classifyobj'} 498 512 ->classify_section($section, $doc_obj, $sortmeta); … … 683 697 my $title = $self->{'reclassifylist'}->{$classification}; 684 698 $title =~ s/&(.){2,4};//g; # remove any HTML special chars 685 $title =~ s/^ \W+//g; # remove leading non-word chars699 $title =~ s/^(\W|_)+//g; # remove leading non-word chars 686 700 687 701 # only want first character for classification … … 689 703 if (defined($1) && $1 ne "") { 690 704 $title=$1; 705 706 # remove any accents on initial character by mapping to Unicode's 707 # normalized decomposed form (accents follow initial letter) 708 # and then pick off the initial letter 709 my $title_decomposed = NFD($title); 710 $title = substr($title_decomposed,0,1); 691 711 } else { 692 712 print STDERR "no first character found for \"$title\" - \"" .
Note:
See TracChangeset
for help on using the changeset viewer.