An ugly duckling stats perl program

Senna Jawa

Literotica Guru
Joined
May 13, 2002
Posts
3,272
This is still the old program. The indentations are surpressed in your html viewing window but they are still present in the html source.

I've added the stats related to the comments on submissions. (Thus there is now even more of the ugly copy+paste+modify stuff, which makes the code unnecessarily long; I've simplified one detail though :)). I intend to have a new, cleaner program and to post it here too.

In a separate post I'll present the output of the present program.

The whole approach should be different, via a professional data base, but that's a different story.
Senna Jawa​

############################################

#!/usr/bin/perl

## author: Senna Jawa ## program: litS.pl (in perl)

print "Enter the Literotica submission file\n path+name ==> ";
(chomp($subFile = <>));
open (SUB, $subFile) or die "can't open $subFile";

print "Enter the date ==> ";
chomp($day = <>);
$outF= ">litStat".$day."o";
open (STAT,$outF);
print $outF,"\n";

while (<SUB>) # skip the irrelevant part of the file
{
last if /colspan=\"2\"/
}

$vv=0; # votes/views switch

while (<SUB>)
{ ++$subTot if /colspan=\"2\"/;
++$noDescr if /No Description/;
if (/(\d\.\d\d)/)
{ ++$graded;
$vot=$1;

if ($1 == 5) {++$g5}
elsif($1 > 4) {++$g4p}
elsif($1 == 4) {++$g4}
elsif($1 > 3) {++$g3p}
elsif($1 == 3) {++$g3}
elsif($1 > 2) {++$g2p}
elsif($1 == 2) {++$g2}
elsif($1 > 1) {++$g1p}
elsif($1 == 1) {++$g1}
}
if(/x\.xx/) {++$nG; $vot=0}

if(/>(\d+)</)
{ if($vv)
{ if ($vot==5) {$vie5 += $1}
elsif($vot>4) {$vie4p += $1}
elsif($vot==4) {$vie4 += $1}
elsif($vot>3) {$vie3p += $1}
elsif($vot==3) {$vie3 += $1}
elsif($vot>2) {$vie2p += $1}
elsif($vot==2) {$vie2 += $1}
elsif($vot>1) {$vie1p += $1}
elsif($vot==1) {$vie1 += $1}
else {$vienG += $1}

++$v100[int($1/100)];
++$v500[int($1/500)]
$vv=1-$vv;
}
else
{ if ($vot==5) {$vts5 += $1}
elsif($vot>4) {$vts4p += $1}
elsif($vot==4) {$vts4 += $1}
elsif($vot>3) {$vts3p += $1}
elsif($vot==3) {$vts3 += $1}
elsif($vot>2) {$vts2p += $1}
elsif($vot==2) {$vts2 += $1}
elsif($vot>1) {$vts1p += $1}
elsif($vot==1) {$vts1 += $1}

++$votes[$1]; $vv=1-$vv
}
}
++$nonE if /\">Non-Erotic/;
++$erot if /\">Erotic/;

if(/Comments: (\d+)/)
{ ++$comments[$1];
if($1)
{
if ($vot==5) {$comT5 += $1; ++$comS5}
elsif($vot>4) {$comT4p += $1; ++$comS4p}
elsif($vot==4) {$comT4 += $1; ++$comS4}
elsif($vot>3) {$comT3p += $1; ++$comS3p}
elsif($vot==3) {$comT3 += $1; ++$comS3}
elsif($vot>2) {$comT2p += $1; ++$comS2p}
elsif($vot==2) {$comT2 += $1; ++$comS2}
elsif($vot>1) {$comT1p += $1; ++$comS1p}
elsif($vot==1) {$comT1 += $1; ++$comS1}
} } }

print STAT "date: $day\n\n";
print STAT "\nThe total number of submissions = $subTot\n";
print STAT "The number of submissions w/o description = $noDescr\n";
print STAT "Erotic poems: $erot\n";
print STAT "Non-Erotic poems: $nonE\n";
print STAT "The number of rated submissions : $graded\n";

print STAT "\nThe number of\n";
print STAT '-'x8," SUBM-s VOTES VIEWS ** COMsubs COMM-s --within the given\n";
print STAT "RATING range:\n\n";
$format = "-- %4d %4d %7d ** %3d %4d\n";
printf STAT "5.00 --------".$format, $g5, $vts5, $vie5, $comS5, $comT5;
printf STAT "4.01 to 4.99 ".$format, $g4p,$vts4p,$vie4p, $comS4p, $comT4p;
printf STAT "4.00 --------".$format, $g4, $vts4, $vie4, $comS4, $comT4;
printf STAT "3.01 to 3.99 ".$format, $g3p,$vts3p,$vie3p, $comS3p, $comT3p;
printf STAT "3.00 --------".$format, $g3, $vts3, $vie3, $comS3, $comT3;
printf STAT "2.01 to 2.99 ".$format, $g2p,$vts2p,$vie2p, $comS2p, $comT2p;
printf STAT "2.00 --------".$format, $g2, $vts2, $vie2, $comS2, $comT2;
printf STAT "1.01 to 1.99 ".$format, $g1p,$vts1p,$vie1p, $comS1p, $comT1p;
printf STAT "1.00 --------".$format, $g1, $vts1, $vie1, $comS1, $comT1;
printf STAT "x.xx --------".$format, $nG, 0, $vienG, 0, 0;;

print STAT "\n";

print STAT "votes submissions\n";
print STAT "====================\n";
print STAT "0 $nG\n";
for(1..$#votes)
{
print STAT $_," ",$votes[$_],"\n" if $votes[$_]
}
print STAT "\n";

print STAT "comments submissions\n";
print STAT "=======================\n";
for(0..$#comments)
{
print STAT $_," ",$comments[$_],"\n" if $comments[$_]
}
print STAT "\n";

print STAT "views/500 submissions\n";
print STAT "========================\n";
for(0..$#v500)
{
$lowR = 500*$_; $highR = $lowR + 499;
print STAT $lowR," to $highR --- ",$v500[$_],"\n"
if $v500[$_]
}
print STAT "\n";

print STAT "views/100 submissions\n";
print STAT "========================\n";
for(0..$#v100)
{
$lowR = 100*$_; $highR = $lowR + 99;
print STAT $lowR,," to $highR --- ",$v100[$_],"\n" if $v100[$_]
}
 
Last edited:
ugly duckling's output

I'll present only the new parts of the output, related to the number of "public comments" (plus the general header).

"SUBM-s" stands for "the number of submissions".
"COMsubs" for "the number of the commented submissions".
"COMM-s" for "the total number of comments".

The last table below tells you that only 39 of submissions were commented on (out of a total of my 285 submissions--246 submissions were not commented on). One submission has 7 comments, 2 submissions have 6 comments, etc (of course a few of the comments were my own, but never the first comment).

It's interesting that none of the 25 poems which has an average vote score 2.00 or less was ever commented, not a single one, not a single time. This despite the fact that they were voted on 58 times, and they have collected almost 32,000 views (reads).


Regards,
Senna Jawa​

***************
date: 05-09-21

The total number of submissions = 285
The number of submissions w/o description = 284
Erotic poems: 74
Non-Erotic poems: 210
The number of rated submissions : 229

The number of
-------- SUBM-s VOTES VIEWS ** COMsubs COMM-s --within the given
RATING range:

5.00 ---------- 62 77 56682 ** 4 7
4.01 to 4.99 -- 38 125 52386 ** 13 27
4.00 ---------- 42 67 38025 ** 6 10
3.01 to 3.99 -- 34 190 115147 ** 10 30
3.00 ---------- 20 36 21497 ** 2 4
2.01 to 2.99 -- 8 55 42029 ** 4 14
2.00 ---------- 10 12 8514 ** 0 0
1.01 to 1.99 -- 5 12 5669 ** 0 0
1.00 ---------- 10 10 10042 ** 0 0
x.xx ---------- 56 0 47256 ** 0 0



comments submissions
=======================
0 246
1 17
2 8
3 6
4 3
5 2
6 2
7 1
 
Last edited:
a bug and output fixed

I have edited my two earlier posts in this thread to fix a (relatively :)) minor bug, and the output. If you have copied my earlier program (Rybka?!) then please get rid of the earlier copy and get yourself a new one now.

This program also supercedes the one from the "stats" thread.

Sorry for all that, regards,
 
a typo fixed

When I "copy+paste+modify" then occasionally I may omit a necessary modification, just an element. Well, a typo is still a bug. It's fixed. Instead of vts2 (the number of votes 2.00) the program was outputing vts3 (the number of votes 3.00). I fixed the code in this thread (I also removed an instruction which was doing nothing except for wasting memory--and I fixed the output in the other post in this thread above).

Thus if you have copied this program (Rybka?) then please copy it again. I apologize.

Basically, I already have a new program too. I still want to add more features. Nobody is in any hurry, not even me, so I think that I will post it within a couple of days.

My present programs produce a rather large output file. That's the old way. Today a much better way is to provide a graphic user interface, so that the user can flexibly select and reselect the parameters and with each click can obtain one output module at the time. I would do it that way with the help of the Tk perl module. Unfortunately I am poor at downloading and I didn't succeed in getting Tk on my "Mac mini" (I have Tk on my PC, but my PC is so slowed down by viruses that I am not using it anymore).

Regards,

Senna Jawa​
 
Last edited:
Senna Jawa said:
When I "copy+paste+modify" then occasionally I may omit a necessary modification, just an element. Well, a typo is still a bug. It's fixed. Instead of vts2 (the number of votes 2.00) the program was outputing vts3 (the number of votes 3.00). I fixed the code in this thread (I also removed an instruction which was doing nothing except for wasting memory--and I fixed the output in the other post in this thread above).

Thus if you have copied this program (Rybka?) then please copy it again. I apologize.

Basically, I already have a new program too. I still want to add more features. Nobody is in any hurry, not even me, so I think that I will post it within a couple of days.

My present programs produce a rather large output file. That's the old way. Today a much better way is to provide a graphic user interface, so that the user can flexibly select and reselect the parameters and with each click can obtain one output module at the time. I would do it that way with the help of the Tk perl module. Unfortunately I am poor at downloading and I didn't succeed in getting Tk on my "Mac mini" (I have Tk on my PC, but my PC is so slowed down by viruses that I am not using it anymore).

Regards,

Senna Jawa​
Thank you, Senna Jawa. I have updated again.

What anti-virus program do you use? AVG has a pretty good one for free. you can find it at: http:///www.grifsoft.com


Regards, Rybka
 
Back
Top