erlug
[Top] [All Lists]

Re: [Erlug] Contare le parole

To: erlug@xxxxxxxxxxxxxx
Subject: Re: [Erlug] Contare le parole
From: Ivan Sergio Borgonovo <mail@xxxxxxxxxxxxxxx>
Date: Thu, 4 Nov 2004 22:24:24 +0100
On Thu, 4 Nov 2004 22:06:19 +0100
Sythos <sythos@xxxxxxxxxx> wrote:

> Supponiamo che io abbia una maildir, supponiamo che io abbia una
> lista di parole tipo "parola1, parola2, parola3", supponiamo che io
> debba contare quante volte quella parola viene citata nelle varie
> email contenute nella maildir, supponiamo anche che voglia contarle

tokenizzi (NdR spezzetti , " ", \t...), upper/lowercasi, sorti,
conti:

/* spam --
    Copyright (C) 2002 Ivan Sergio Borgonovo

    This file is part of spam.

    spam is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
by    the Free Software Foundation; either version 2 of the License.

    spam is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 
02111-1307  USA*/
/*
Ivan Sergio Borgonovo mail@xxxxxxxxxxxxxxx
*/

#include <stdio.h>
#define LINELENGTH 255
int main(int argc, char* argv[]){
    unsigned int lines=0;
    char linea[LINELENGTH]="";
    char lineatmp[LINELENGTH]="\n";
    if (fgets(linea,LINELENGTH,stdin)) {
        memccpy(lineatmp,linea,0,LINELENGTH);
        lines++;
        while (fgets(linea,LINELENGTH,stdin)) {
            if (0!=strcmp(linea,lineatmp)) {
                printf("%04x%s%s",lines,"\t",lineatmp);
                lines=0;
                memccpy(lineatmp,linea,0,LINELENGTH);
            }
            lines++;
        }
    }
    else {
        return 1;
    }
    printf("%04x%s%s",lines,"\t",lineatmp);
    return 0;
}


dovrebbe fare quello che vuoi... ma ha 2 anni e non mi ricordo più
cosa faccia... era un pezzo di un coso per statistica sullo spam.


> SOLO dalla parte onlytext delle email (se no mi esce conteggio
> doppio per le email che mi arrivano in HTML)

Qua non so aiutarti.


<Prev in Thread] Current Thread [Next in Thread>