Przeglądaj źródła

New feature: 'average words per line'

Morten Brix Pedersen 25 lat temu
rodzic
commit
e1506ec3a4
3 zmienionych plików z 44 dodań i 0 usunięć
  1. 1 0
      Changelog
  2. 6 0
      lang.txt
  3. 37 0
      pisg.pl

+ 1 - 0
Changelog

@@ -15,6 +15,7 @@ pisg (0.18)
    * Norweigan translation (thanks to Andreas Blaafladt)
    * New feature: 'Those who couldnt control the shift key and wrote UPPERCASE'
    * New feature: 'Who got slapped the most'
+   * New feature; 'Average words per line'
    * Stop copying CVS dirs with distribution
    * Also count words in actions, and a new feature: 'most words' (thanks to
      Hanno Hecker)

+ 6 - 0
lang.txt

@@ -63,6 +63,9 @@ words3 = "Nobody said anything... what a strange channel..."
 mono1 = "<b>[:nick]</b> is talking to himself a lot, wrote over 5 lines in a row [:monos] times!"
 mono2 = "Another lonely one was <b>[:nick]</b>, who managed to hit [:monos] times"
 
+wpl1 = "<b>[:nick]</b> wrote an average of [:wpl] words per line..."
+wpl2 = "Channel average was [:avg] words per line."
+
 long1 = "<b>[:nick]</b> wrote longest lines, average of [:letters] per line..."
 long2 = "Channel average on [:channel] was [:avg] letters per line"
 
@@ -155,6 +158,9 @@ words3 = "Niemand hat etwas gesagt? Seltsamer Channel..."
 mono1 = "<b>[:nick]</b> spricht viel mit sich selbst, er/sie schrieb über 5 Zeilen in einer Reihe und das [:monos] mal!"
 mono2 = "Ein anderes einsames Herz ist <b>[:nick]</b>, der/die [:monos] mal mit sich selbst redete."
 
+wpl1 = "<b>[:nick]</b> schrieb im Schnitt [:wpl] Worte pro Zeile ..."
+wpl2 = "Der Channeldurchschnitt lag bei [:avg] Worten/Zeile."
+
 long1 = "<b>[:nick]</b> ist die Labertasche im Channel Er/Sie schrieb die längste Zeile mit durchschnittlich [:letters] Buchstaben pro Zeile..."
 long2 = "Channel-Durchschnitt in [:channel] war [:avg] Buchstaben pro Zeile."
 

+ 37 - 0
pisg.pl

@@ -1046,6 +1046,7 @@ sub create_html
     longlines();
     shortlines();
     mostwords();
+    mostwordsperline();
     html("</table>"); # Needed for sections
 
     mostusedword();
@@ -1278,6 +1279,42 @@ sub mostusedword
 
 }
 
+sub mostwordsperline
+{
+     # The person who got words the most
+
+     my %wpl = ();
+     my ($numlines,$avg,$numwords);
+     foreach my $n (keys %words) {
+         $wpl{$n} = sprintf("%.2f", $words{$n}/$line{$n});
+         $numlines += $line{$n};
+	 $numwords += $words{$n};
+     }
+     $avg = sprintf("%.2f", $numwords/$numlines);
+     my @wpl = sort { $wpl{$b} <=> $wpl{$a} } keys %wpl;
+
+     if (@wpl) {
+         my %hash = (
+             nick => $wpl[0],
+             wpl => $wpl{$wpl[0]}
+         );
+
+         my $text = template_text('wpl1', %hash);
+         html("<tr><td bgcolor=\"$conf->{hicell}\">$text");
+
+         %hash = (
+             avg => $avg
+         );
+
+         $text = template_text('wpl2', %hash);
+             html("<br><span class=\"small\">$text</span>");
+         html("</td></tr>");
+     } else {
+         my $text = template_text('wpl3');
+         html("<tr><td bgcolor=\"$conf->{hicell}\">$text</td></tr>");
+     }
+
+}
 
 sub mostreferenced
 {