# # FORM{'comments'} contains the original message. # sub hudlomer{ # # Determines so-called "functional style" of a text sample. # A text size should be larger than 100 words. # $maxthreshold=18; # Maximal acceptable word length. Longer words should be ignored. $ss=$FORM{'comments'}; # buffer $ss=~s/[\.,\-"\!\?()\[\]]/ /g; # Delete punctuation signs $ss=~s/[^áâ÷çäå³öúéêëìíîïðòóôõæèãþûýÿùøüàñÁÂ×ÇÄÅ£ÖÚÉÊËÌÍÎÏÐÒÓÔÕÆÈÃÞÛÝßÙØÜÀÑ ]//g; #capitalize @words=split(/\s+/,$ss); # split the message into an array ($totalwords,$wordlensum,$wordlensumsq)=(); foreach $word( @words){ # Math $l=length($word); if( $l > 0 ){ if( $l > $maxthreshold ){$next}; # dicard long words $wordlensum+=$l; # total length $wordlensumsq+=$l*$l; # squared sum of lengths $totalwords++; #total number of words } } if( $totalwords > 0 ){ $averl=$wordlensum/$totalwords; # average length $varl=$wordlensumsq/$totalwords-$averl*$averl; # variance $varlteor=3.89*$averl-10.67; # theoretical variance. Used to compute the limits for 'natural' texts }else{ $averl=0; $varl=0; } if( $totalwords < 100 ){# Text is too short. Hudlomer is useless. return 2; } if( !$FORM{'hudlomer'}){ # hudlomer is turned off. The average length is still logged by some other subroutine return 3; } if( $varlteor - $varl > 3.89 ){ # Check whether this text is 'natural' $termcolor="#00FF00"; #green == too small dispersion }elsif( ($varlteor - $varl < -3.89)|| ($averl<3.9) ){ $termcolor="#5555FF"; #blue == too large dispersion. (too short words) }else{ $termcolor="#FF0000"; # normal dispersion } if( $averl < 3.9 ){ $averl=3.9}; # too short average word length. Limit by 3.9 if( $averl > 7.9 ){ $averl=7.9}; # too long average word length. Limit by 7.9 $width=int(25*($averl-3.9)); # width of the HTML-table # output the table print GUEST<<__E1__; __E1__ $c1=$c2=$c3=$c4=""; # Choose a cell to highlight if( $width < 25 ){ $c1=" BGCOLOR=$termcolor "; }elsif( $width < 50 ){ $c2=" BGCOLOR=$termcolor "; }elsif( $width < 75 ){ $c3=" BGCOLOR=$termcolor "; }else{ $c4=" BGCOLOR=$termcolor "; } # draw a scale print GUEST ""; print GUEST ""; print GUEST ""; print GUEST ""; print GUEST<<__E2__;
ÕÓÄËÎÌÅÐ Ñ×ÈÒÀÅÒ, ×ÒÎ ÝÒÎÒ ÎÒÇÛÂ:
ÐÀÇÃÎÂÎÐÍÀß ÐÅ×ÜÕÓÄËÎÃÀÇÅÒÍÀß ÑÒÀÒÜßÍÀÓ×ÍÀß ÑÒÀÒÜß
__E2__ if( $width > 0){ print GUEST<<__E22__;
  
__E22__ } return 1; }