Frederick Gotham wrote:
Somebody posted:
Has anyone computed the percentage of off topic posts in this group
No.
using ANSI C?
ANSI C does not provide a facility for accessing Usenet, and thus one
cannot write a portable program for calculating such a percentage.
--
Frederick Gotham
Hypothetically, if one were to run a news server, one could write a
program to analyze content. Such a program might look like this:
<code>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum {
BUFLEN = 131072,
MAXTOK = 4096
};
static int fgetline(char *, int, FILE *);
static int count(FILE *);
int
main(int argc, char *argv[])
{
FILE *fp;
if (argc < 2) {
fprintf(stderr, "usage: %s file \n", argv[0]);
return 2;
}
if ((fp = fopen(argv[1], "rt")) == NULL) {
fprintf(stderr, "can't open %s\n", argv[1]);
return 2;
}
return count(fp);
}
static int
count(FILE *fp)
{
char *tok[MAXTOK], *p;
char buf[BUFLEN];
int len, n, i, count = 0;
while ( (len = fgetline(buf, BUFLEN, fp)) 0) {
p = buf;
tok[0] = strtok(p, " ,\t\n");
for (n = 1; n < MAXTOK && (tok[n] = strtok(NULL, " ,\t\n"));
n++)
;
for (i =0; i < n; i++)
if (0 == strncasecmp(tok[i], "off topic"))
++count;
}
return count;
}
/* fgetline: read a line from fp, return length */
static int
fgetline(char *line, int max, FILE *fp)
{
if (fgets(line, max, fp) == NULL)
return 0;
else
return strlen(line);
}
</code>
Were such a person to pass in the file containing the comp.lang.c
cache, a rough estimate of the count of off topic posts could be
obtained.
Using the value the program returned, divided by the number of posts,
would give a percentage.
Please excuse the sloppy programming, as it was intended to be a proof
of concept, not an actual program.
I think the percentage would be above 80%
usenet is still a strange place