Article View: news.software.readers
Article #22071Re: don't put in a useless quoting warning (was Re: What's this 'Mozilla' trash anyway?)
From: Tom Christiansen
Date: Sat, 25 May 1996 00:00
Date: Sat, 25 May 1996 00:00
139 lines
5020 bytes
5020 bytes
[courtesy cc of this posting sent to cited authors via email]
In news.software.readers, gberigan@cse.unl.edu (Greg Berigan) writes:
:Russell_Schulz@locutus.ofB.ORG (Russell Schulz) wrote:
:>I _like_ 6-line articles which are 4 lines of text, one blank, one new.
:
:That would be the quoted text and an attribution line, separated by one
:blank line. That would technically be zero new lines. That wouldn't
:even trip up an 80% threshold. That example is only 66% quoted.
If you check out my cfoq (check fascistly overquoted) program,
you may find that it correctly decides whether there's too much
text quoted. It doesn't count the attribution line, or the signaure
(if well formed), and it even merges idiotic broken quote lines
as are purpetrated on the net by morons running PC crapware.
Try running it on various messages with the -v flag to see
what it's finding.
--tom
#!/usr/bin/perl
#
# cfoq: check fascistly overquoted by tchrist@mox.perl.com
# version 1.1 Sat May 25 07:07:33 MDT 1996
# (wants perl 5.0 or better, but was developed under 5.002)
#
# INPUT: a news article
# OUTPUT: if -v, then shows how much it found and where
#
# OPTIONS: -v for verbose flag
# -t NN to change tolerance percentage from 50%
# -m for minimum lines that get subject to percentage counting;
# otherwise, it just checks for ANY new lines. This way
# short little 6-line messages with 4 lines of quoting don't
# get hassled
#
# EXIT: 2 (bad failure) if no new lines
# 1 (failure) if tolerance exceeded
# 0 (success) otherwise
# 5.0 might work, but I developed it under 5.002
require 5.002;
## ### next lines need 5.002
##
## use strict;
## use vars qw{
## $MINLINES $opt_m
## $VERBOSE $opt_v
## $TOLERANCE $opt_t
## };
##
use Getopt::Std;
getopts("vt:m:") || die "usage: $0 [-v] [-t tolerance] [-m minlines] [input_file]\n";
my (
$total, # total number of lines, minus sig and attribution
$quoted_lines, # how many lines were quoted
$percent, # what percentage this in
$pcount, # how many in this paragraph were counted
$match_part, # holding space for current match
$gotsig, # is this the sig paragraph?
);
$total = $quoted_lines = $pcount = $percent = 0;
$MINLINES = $opt_m || 20;
$VERBOSE = $opt_v;
$TOLERANCE = $opt_t || 50;
$/ = ''; # set record reading to paragraph mode
<ARGV>; # consume and discard header of message
while (<ARGV>) {
# strip sig line, remember we found it
$gotsig = s/^-- \n.*//ms;
# strip attribution, possibly multiline
if ($. == 2) { s/\A.*?(<.*?>|\@).*?:\n//s }
# toss trailing blank lines into one single line
s/\n+\Z/\n/;
# now reduce miswrapped lines from idiotic broken PC newsreaders
# into what they should have been
s/(>.*)\n\s*([a-zA-Z])/$1 $2/g;
# count lines in this paragraph
$total++ while /^./mg;
# is it a single line, quoted in the customary fashion?
if ( /^(>+).*\n\Z/ ) {
$quoted_lines++;
print " 1 line quoted with $1\n" if $VERBOSE;
next;
}
# otherwise, it's a multiline block, which may be quoted
# with any leading repeated string that's neither alphanumeric
# nor string
while (/^(([^\w\s]+).*\n)(\2.*\n)+/mg) { # YANETUT
$quoted_lines += $pcount = ($match_part = $&) =~ tr/\n//;
printf "%2d lines quoted with $2\n", $pcount if $VERBOSE;
}
last if $gotsig;
}
$percent = int($quoted_lines / $total * 100);
print "$quoted_lines lines quoted out of $total: $percent%\n"
if $VERBOSE;
if ($total == $quoted_lines) {
print "All $total lines were quoted lines!\n" if $VERBOSE;
exit 2;
}
if ($percent > $TOLERANCE) {
if ($total < $MINLINES) {
print "but since $total is less than $MINLINES lines, that's ok\n"
if $VERBOSE;
exit 0;
} else {
exit 1;
}
} else {
exit 0;
}
--
Tom Christiansen Perl Consultant, Gamer, Hiker tchrist@mox.perl.com
"Patriotism is the virtue of the vicious."
- Oscar Wilde
Technical Details
Message-ID:
<4o70ro$evf@csnews.cs.colorado.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailReferences:
<DrK7qu.E64@midway.uchicago.edu> <01bb47ae.7d94b580$a05378c7@msftrncs> <960524.185020.1j5.rnr.w164w_-_@locutus.ofB.ORG> <4o67bm$cr4@crcnis3.unl.edu>Show Full Headers
Complete Article Headers
Message-ID: <4o70ro$evf@csnews.cs.colorado.edu> Subject: Re: don't put in a useless quoting warning (was Re: What's this 'Mozilla' trash anyway?) Date: Sat, 25 May 1996 00:00:00 +0000 From: Tom Christiansen <tchrist@mox.perl.com> References: <DrK7qu.E64@midway.uchicago.edu> <01bb47ae.7d94b580$a05378c7@msftrncs> <960524.185020.1j5.rnr.w164w_-_@locutus.ofB.ORG> <4o67bm$cr4@crcnis3.unl.edu> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 156695282 Content-type: text/plain; charset=ISO-8859-1 Organization: Perl Consulting and Training Reply-to: tchrist@mox.perl.com (Tom Christiansen) Newsgroups: news.software.readers Originator: tchrist@mox.perl.com