🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
3 messages
3 total messages Started by Christopher B. Browne Sat, 29 Jun 1996 00:00
slrn score-file fiddling
#23543
Author: Christopher B. Browne
Date: Sat, 29 Jun 1996 00:00
106 lines
3820 bytes
I posted some comments about slrn and scoring, and I think it behooves
me to do more than just talk about things I'd like to see in slrn.

I was looking for two things:

a) A utility to clean up slrn score files
This would do things like:
  - re-arranging rules into some sort of coherent order
  - Deleting comment lines (not universally a good thing, but I'm
    happy enough doing it...)
  - Folding duplicated scores together.

The following Perl script does this sort of thing.  Change the filename
that it reads score info from; you'll need to have a temporary file to
sent output to.  (Redirecting output to the score file that you started
with will result in an *empty* score file.)

It may not handle expiry dates very well; I don't use expiry much, so
I didn't much care.  It should be a simple extension...

#!/usr/bin/perl
# $Id$
# Reformat score file
open(SCORES, "</home/cbbrowne/News/scores/Scores");

while (<SCORES>) {
    if (/^%/) {
	# Skip comment line
    } else {
	if (/\s*Score:(.*)\s*/) {
	    $score = $1;
	}
	if ((/^\s*\[/) || (/^\s*Score:/ )) {
	    # New entry
	    # Process last entry
	    # Clear from/to/sub/score/xref/newsgroup
	    $key = "$group:$exp:$from:$ref:$sub:$xref:$grp";
	    $RULE{$key} += $score;
	    ($exp, $from, $sub, $xref, $grp) = ();
	}
        if (/\s*\[(.*)\]\s*$/) {
	    $group = $1;
	} elsif (/\s*Expires:(.*)\s*/) {
	    $exp = $1;
	} elsif (/\s*Subject:(.*)\s*/) {
	    $sub = $1;
	} elsif (/\s*Newsgroup:(.*)\s*/) {
	    $grp = $1;
	} elsif (/\s*References:(.*)\s*/) {
	    $ref = $1;
	} elsif (/\s*From:(.*)\s*$/) {
	    $from = $1;
	} elsif (/\s*Xref:(.*)\s*$/) {
	    $xref = $1;
	}
    }
}

foreach $i (sort keys %RULE) {
    $score = $RULE{$i};
    if ($score < -9999) {
	$score = -9999;
    }
#    print $i, $score, "\n";
    ($group, $exp,$from,$ref,$sub,$xref,$grp) = split(/:/, $i);
    if ($group eq $lastgroup) {
	# Skip group - hasn't changed
    } else {
	$lastgroup = $group;
	print "\[$group\]\n";
    }
    print "Score: $score\n";
    print "\tExpires: $exp\n" unless $exp eq "";
    print "\tSubject: $sub\n" unless $sub eq "";
    print "\tNewsgroup: $grp\n" unless $grp eq "";
    print "\tReferences: $ref\n" unless $ref eq "";
    print "\tFrom: $from\n" unless $from eq "";
    print "\tXref: $xref\n" unless $xref eq "";
    print "\n";
}
# End of Perl script

b) Different thresholds to kill/delete/favor articles.

I've made patches on the latest version (0.8.8.3) that provides new
variables, allowing one to have articles killed at other than a score
of -9999, deletion at other than <0, "favored" for selection at other
than >0.

*Very* simple changes; I'm still figuring out how to build the patch
file.

c) Automatic scoring based on slrn variables.

This looks more "entertaining;" more than a morning's worth of work.

I'm thinking of an approach; not certain yet of how best to link the
functionality in. 

-- 
Christopher B. Browne, cbbrowne@conline.com, chris_browne@sdt.com
Web: http://www.conline.com/~cbbrowne  SAP Basis Consultant, UNIX Guy,
Linux Guy.  "Windows?  Ah...  The Athena Project from MIT..."


Re: slrn score-file fiddling
#23501
Author: Christopher B. Browne
Date: Sat, 29 Jun 1996 00:00
84 lines
2964 bytes
It's bad form to follow-up yourself; there were some ugly bugs in the Perl
script.  (well, fairly ugly.  Colons in data were being interpreted as
data separators.  Ick.)

- Limitations
  - Can't have multiple "subject:" lines for a particular score.
  - Ignores expiry date

Otherwise, it nicely cleans up any automatically generated score files.


#!/usr/bin/perl
# Reformat score file
open(SCORES, "</home/cbbrowne/News/scores/Scores");

while (<SCORES>) {
    if (/^%/) {
	# Skip comment line
    } else {
	if (/\s*Score:(.*)\s*/) {
	    $score = $1;
	}
	if ((/^\s*\[/) || (/^\s*Score:/ )) {
	    # New entry
	    # Process last entry
	    # Clear from/to/sub/score/xref/newsgroup
	    $key = "$group\t$exp\t$from\t$ref\t$sub\t$xref\t$grp";
	    $RULE{$key} += $score;
	    ($exp, $from, $sub, $xref, $grp) = ();
	}
        if (/\s*\[(.*)\]\s*$/) {
	    $group = $1;
	} elsif (/\s*Expires:(.*)\s*/) {
	    $exp = $1;
	} elsif (/\s*Subject:(.*)\s*/) {
	    $sub = $1;
	} elsif (/\s*Newsgroup:(.*)\s*/) {
	    $grp = $1;
	} elsif (/\s*References:(.*)\s*/) {
	    $ref = $1;
	} elsif (/\s*From:(.*)\s*$/) {
	    $from = $1;
	} elsif (/\s*Xref:(.*)\s*$/) {
	    $xref = $1;
	}
    }
}

# toss in a rule guaranteed to fall in at the end so that we get the
# final score dumped out.
foreach $i (sort keys %RULE) {
    $score = $RULE{$i};
    if ($score < -9999) {
	$score = -9999;
    }
#    print $i, $score, "\n";
    ($group, $exp,$from,$ref,$sub,$xref,$grp) = split(/\t/, $i);
    if (/\t\t\t\t\t\t/) {
	# Don't do it - no data!
    } else {
	if ($group eq $lastgroup) {
	    # Skip group - hasn't changed
	} else {
	    $lastgroup = $group;
	    print "\[$group\]\n";
	}
	print "Score: $score\n";
	print "\tExpires: $exp\n" unless $exp eq "";
	print "\tSubject: $sub\n" unless $sub eq "";
	print "\tNewsgroup: $grp\n" unless $grp eq "";
	print "\tReferences: $ref\n" unless $ref eq "";
	print "\tFrom: $from\n" unless $from eq "";
	print "\tXref: $xref\n" unless $xref eq "";
	print "\n";
    }
}

-- 
Christopher B. Browne, cbbrowne@conline.com, chris_browne@sdt.com
Web: http://www.conline.com/~cbbrowne  SAP Basis Consultant, UNIX Guy,
Linux Guy.  "Windows?  Ah...  The Athena Project from MIT..."


Re: slrn score-file fiddling
#23565
Author: Sven Guckes
Date: Sun, 30 Jun 1996 00:00
12 lines
875 bytes
cbbrowne@dantzig.nodomain.nowhere (Christopher B. Browne):
> #!/usr/bin/perl

Nice!  :-)

Now, there are a few things I'd like to have modified...  :-)

Sven


Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads