43 #define KULLBACK_AVERAGE 4 47 which_average_method()
51 if ((env = getenv(
"BAYES_AVERAGE")) != NULL)
60 #define PROBVALUE(a) (fabs(0.5 - (a))) 63 probability_average(t, n)
75 method = which_average_method();
101 ks = nms < nm ? (nm / nms) : 1.;
102 kh = nmh < nm ? (nm / nmh) : 1.;
105 for (i = 0; i < n; i++)
109 double ns = 0, nh = 0;
111 double p = t[i].prob;
118 lodd += log((ns + 0.5) / (nh + 0.5));
121 lodd += t[i].nb * log((ns + 0.5) / (nh + 0.5));
126 hmt -= (p * log(p) + (1. - p) * log(1. - p));
134 hmt = 1 - hmt / (nt * log(2.));
138 return 1 / (1 + exp(-lodd));
144 #define TOK_PERT_CMP(a,b) ((a)->value > (b)->value ? 1 : -1) 147 bptokcmp(
const void *a,
const void *b)
173 browse_tokens(
void *node,
void *arg)
214 list_tokens(node, arg)
229 memset(buf, 0,
sizeof (buf));
237 printf(
"TOKEN %s %s %c %6d %s\n", bp->
timestr, bp->
id,
238 (bp->
spam ?
'S' :
'H'), t->
nb, s);
263 snprintf(
id,
sizeof (
id),
"%s.%06d",
"MSG", msgNb);
287 snprintf(timestr,
sizeof (timestr),
"%ld", now);
298 if (res && data->
check)
306 printf(
"TOKEN %3d %3d %6.3f %s\n", n, data->
bcheck.
tok[n].
nb,
311 printf(
"%5d : RESULT = %6.4f\n", msgNb, prob);
340 prob = probability_average(bcheck->
tok, bcheck->
nbt);
#define SHOW_CURSOR(zero)
double sfilter_check_message(char *id, char *fname, sfilter_vsm_T *bcheck)
bfilter_T * bfilter_ptr()
bool smodel_db_check_token(char *key, sfilter_token_T *token)
#define TOK_PERT_CMP(a, b)
bool sfilter_cli_handle_message(char *fname, int msgNb, void *arg)
bool str2hash2hex(int code, char *sout, char *sin, size_t szout)
#define ZE_MessageInfo(level,...)
sfilter_token_T tok[MAX_TOK]
#define SFILTER_VSM_INIT(bc, nbt, prob)
#define STRCASEEQUAL(a, b)
int get_bfilter_db_crypt()
bool bfilter_handle_message(char *id, char *fname, btsm_browse_F func, void *arg)