nanog mailing list archives

Re: Quick fix


From: Randy Bush <randy () psg com>
Date: Thu, 02 Mar 2000 00:41:44 -0800


there is a bug in your mail system.  it is regurgigating mail which, from
the content, is clearly from the mid '70s, but it seems to have current
dates in the header.

Received: from segue.merit.edu ([198.108.1.41])
      by psg.com with esmtp (Exim 3.12 #1)
      id 12QMzj-0008bv-00; Wed, 01 Mar 2000 20:13:47 -0800
Received: by segue.merit.edu (Postfix)
      id 1EFD35DDB9; Wed,  1 Mar 2000 23:11:08 -0500 (EST)
Delivered-To: nanog-outgoing () merit edu
Received: by segue.merit.edu (Postfix, from userid 56)
      id EC52B5DDB5; Wed,  1 Mar 2000 23:11:07 -0500 (EST)
Received: from c012.sfo.cp.net (c012-h010.c012.sfo.cp.net [209.228.13.104])
      by segue.merit.edu (Postfix) with SMTP id B07735DDA8
      for <nanog () merit edu>; Wed,  1 Mar 2000 23:11:05 -0500 (EST)
Received: (cpmta 4757 invoked from network); 1 Mar 2000 20:11:04 -0800
Message-ID: <20000302041104.4756.cpmta () c012 sfo cp net>
X-Sent: 2 Mar 2000 04:11:04 GMT
Received: from [24.15.185.142] by mail.altavista.com with HTTP;
    01 Mar 2000 20:11:04 PST
Content-Type: text/plain
Content-Disposition: inline
Mime-Version: 1.0
X-Mailer: Web Mail 3.5.1.4
Sender: owner-nanog () merit edu
Precedence: bulk
Errors-To: owner-nanog-outgoing () merit edu
X-Loop: nanog
Date: 1 Mar 2000 20:11:04 -0800
To: nanog () merit edu
From: Bandy Rush <bandyrush () altavista com>
Subject: Quick fix


I noticed that a number of individuals who post regularly to the NANOG mailing list have keyboards with 
malfunctioning shift keys.  Since working keyboards are so expensive, far beyond the financial means of most 
poorly-paid technical workers, I humbly offer the following Perl program, which you can use to filter your NANOG 
e-mail to correct capitalization errors (procmail should do the trick for that).  For example:

    i abhor cross-posting.  but sometimes ...

Gets converted to:

    I abhor cross-posting.  But sometimes ... 

It's not perfect, but it catches most occurrances.  If you have a slow computer, you probably want to disable the 
dictionary.  You can do this by setting @DICT_FILES=().  As is, it is configured to search for the word list in the 
default locations in Linux and Solaris.

And oh yes, it's a joke.  ;)

#!/usr/bin/perl -w  
 
# use good Perl form
use strict;
use English;
 
# location of plain-text word list
my @DICT_FILES = ("/usr/dict/words", "/usr/share/lib/dict/words");
 
# slurp in all input  
undef $INPUT_RECORD_SEPARATOR;
my $input = <>;
exit unless (defined($input));
 
# Fix end of paragraph
$input =~ s/([a-z])(\n\n.)/$1.$2/g;
 
# Fix start of sentence
$input =~ s/(\n\n+)([a-z])/$1\u$2/g;
$input =~ s/(\.\s+)([a-z])/$1\u$2/g;
 
# Fix self-referental problems
$input =~ s/(\b)i(\b)/$1I$2/g;
$input =~ s/(\b)randy(\b)/$1Randy$2/g;
$input =~ s/(\b)bush(\b)/$1Bush$2/g;
 
# Fix words that should be capitalized (based on the dictionary)
$INPUT_RECORD_SEPARATOR = "\n";
foreach my $dict_file (@DICT_FILES) {
    if (open(DICT, "< $dict_file")) {
        while (defined (my $uc_word=<DICT>)) {
            if ($uc_word =~ /[A-Z]/) {
                chomp($uc_word);
                my $lc_word = lc($uc_word);
                $input =~ s/(\b)$lc_word(\b)/$1$uc_word$2/g;
            }
        }
        last;
    }
}
 
# output our fixed text
print $input;
 
# The author releases this software into the public domain.  


--------------------------------------
AltaVista     Smart is Beautiful     http://www.altavista.com

Raging Bull?  Sleeping Bear?  Live stock quotes at AltaVista Live!
http://money.altavista.com

--------------------------------------




Current thread: