populate_stats [was: random oddities and questions]
David Relson
relson at osagesoftware.com
Tue Oct 8 13:59:20 CEST 2002
At 07:35 AM 10/8/02, David Relson wrote:
>At 01:52 AM 10/8/02, Eric Seppanen wrote:
>>What is populate_stats() for? It's not called anywhere.
>
>It's the internal loop of select_indicators(). At one time
>select_indicators() was factored into a couple of component
>functions. This has been undone - possibly it was undone in the switch
>from Judy arrays to word hashes. Anyhow, I'll delete the function.
I took another look at select_indicators(). Refactored to use
populate_stats(), it becomes a short, readable function, i.e.
bogostat_t *select_indicators(wordhash_t *wordhash)
// selects the best spam/nonspam indicators and
// populates the stats structure.
{
hashnode_t *node;
init_stats( "tot", &stats );
for(node = wordhash_first(wordhash); node != NULL; node =
wordhash_next(wordhash))
{
char *token = node->key;
double prob = compute_probability( token );
populate_stats( &stats, token, prob, 1 );
}
return (&stats);
}
I rather like this version. Do you folks like or dislike it?
David
More information about the bogofilter-dev
mailing list