if (isfinite (s) && isfinite (h)) {
final_prob = (s + 1.0 - h) / 2.;
msg_debug_bayes (
- "<%s> got ham prob %.2f -> %.2f and spam prob %.2f -> %.2f,"
+ "got ham prob %.2f -> %.2f and spam prob %.2f -> %.2f,"
" %L tokens processed of %ud total tokens;"
" %uL text tokens found of %ud text tokens)",
- task->message_id,
cl.ham_prob,
h,
cl.spam_prob,
*/
if (isfinite (h)) {
final_prob = 1.0;
- msg_debug_bayes ("<%s> spam class is overflowed, as we have no"
- " ham samples", task->message_id);
+ msg_debug_bayes ("spam class is overflowed, as we have no"
+ " ham samples");
}
else if (isfinite (s)) {
final_prob = 0.0;
- msg_debug_bayes ("<%s> ham class is overflowed, as we have no"
- " spam samples", task->message_id);
+ msg_debug_bayes ("ham class is overflowed, as we have no"
+ " spam samples");
}
else {
final_prob = 0.5;
- msg_warn_bayes ("<%s> spam and ham classes are both overflowed",
- task->message_id);
+ msg_warn_bayes ("spam and ham classes are both overflowed");
}
}
g_assert (st_ctx != NULL);
- for (i = 0; i < task->text_parts->len; i++) {
- part = g_ptr_array_index (task->text_parts, i);
-
+ PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, text_parts), i, part) {
if (!IS_PART_EMPTY (part) && part->utf_words != NULL) {
reserved_len += part->utf_words->len;
}
rspamd_ptr_array_free_hard, task->tokens);
pdiff = rspamd_mempool_get_variable (task->task_pool, "parts_distance");
- for (i = 0; i < task->text_parts->len; i ++) {
- part = g_ptr_array_index (task->text_parts, i);
-
+ PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, text_parts), i, part) {
if (!IS_PART_EMPTY (part) && part->utf_words != NULL) {
st_ctx->tokenizer->tokenize_func (st_ctx, task,
part->utf_words, IS_PART_UTF (part),
if (!skip) {
if (cl->cfg->min_tokens > 0 && task->tokens->len < cl->cfg->min_tokens) {
msg_debug_bayes (
- "<%s> contains less tokens than required for %s classifier: "
+ "contains less tokens than required for %s classifier: "
"%ud < %ud",
- task->message_id,
cl->cfg->name,
task->tokens->len,
cl->cfg->min_tokens);
}
else if (cl->cfg->max_tokens > 0 && task->tokens->len > cl->cfg->max_tokens) {
msg_debug_bayes (
- "<%s> contains more tokens than allowed for %s classifier: "
+ "contains more tokens than allowed for %s classifier: "
"%ud > %ud",
- task->message_id,
cl->cfg->name,
task->tokens->len,
cl->cfg->max_tokens);
if (learn_res == RSPAMD_LEARN_INGORE) {
/* Do not learn twice */
g_set_error (err, rspamd_stat_quark (), 404, "<%s> has been already "
- "learned as %s, ignore it", task->message_id,
+ "learned as %s, ignore it", MESSAGE_FIELD (task, message_id),
spam ? "spam" : "ham");
task->flags |= RSPAMD_TASK_FLAG_ALREADY_LEARNED;
*err == NULL) {
/* Do not learn twice */
g_set_error (err, rspamd_stat_quark (), 208, "<%s> has been already "
- "learned as %s, ignore it", task->message_id,
+ "learned as %s, ignore it", MESSAGE_FIELD (task, message_id),
spam ? "spam" : "ham");
return FALSE;
msg_info_task (
"<%s> contains less tokens than required for %s classifier: "
"%ud < %ud",
- task->message_id,
- cl->cfg->name,
- task->tokens->len,
- cl->cfg->min_tokens);
+ MESSAGE_FIELD (task, message_id),
+ cl->cfg->name,
+ task->tokens->len,
+ cl->cfg->min_tokens);
too_small = TRUE;
continue;
}
msg_info_task (
"<%s> contains more tokens than allowed for %s classifier: "
"%ud > %ud",
- task->message_id,
- cl->cfg->name,
- task->tokens->len,
- cl->cfg->max_tokens);
+ MESSAGE_FIELD (task, message_id),
+ cl->cfg->name,
+ task->tokens->len,
+ cl->cfg->max_tokens);
too_large = TRUE;
continue;
}
g_set_error (err, rspamd_stat_quark (), 204,
"<%s> contains more tokens than allowed for %s classifier: "
"%d > %d",
- task->message_id,
+ MESSAGE_FIELD (task, message_id),
sel->cfg->name,
task->tokens->len,
sel->cfg->max_tokens);
g_set_error (err, rspamd_stat_quark (), 204,
"<%s> contains less tokens than required for %s classifier: "
"%d < %d",
- task->message_id,
+ MESSAGE_FIELD (task, message_id),
sel->cfg->name,
task->tokens->len,
sel->cfg->min_tokens);
g_set_error (err, rspamd_stat_quark (), 204,
"<%s> is skipped for %s classifier: "
"%s",
- task->message_id,
+ MESSAGE_FIELD (task, message_id),
sel->cfg->name,
cond_str ? cond_str : "unknown reason");
}
msg_info_task ("<%s>: autolearn ham for classifier "
"'%s' as message's "
"score is negative: %.2f",
- task->message_id, cl->cfg->name,
+ MESSAGE_FIELD (task, message_id), cl->cfg->name,
mres->score);
}
else {
msg_info_task ("<%s>: autolearn spam for classifier "
"'%s' as message's "
"action is reject, score: %.2f",
- task->message_id, cl->cfg->name,
+ MESSAGE_FIELD (task, message_id), cl->cfg->name,
mres->score);
}
guint i = 0;
rspamd_stat_token_t *tok;
- if (task->subject) {
- rspamd_add_metawords_from_str (task->subject, strlen (task->subject), task);
+ if (MESSAGE_FIELD (task, subject)) {
+ rspamd_add_metawords_from_str (MESSAGE_FIELD (task, subject),
+ strlen (MESSAGE_FIELD (task, subject)), task);
}
- if (task->from_mime && task->from_mime->len > 0) {
+ if (MESSAGE_FIELD (task, from_mime) && MESSAGE_FIELD (task, from_mime)->len > 0) {
struct rspamd_email_address *addr;
- addr = g_ptr_array_index (task->from_mime, 0);
+ addr = g_ptr_array_index (MESSAGE_FIELD (task, from_mime), 0);
if (addr->name) {
rspamd_add_metawords_from_str (addr->name, strlen (addr->name), task);
if (task->meta_words != NULL) {
const gchar *language = NULL;
- if (task->text_parts && task->text_parts->len > 0) {
- struct rspamd_mime_text_part *tp = g_ptr_array_index (task->text_parts, 0);
+ if (MESSAGE_FIELD (task, text_parts) &&
+ MESSAGE_FIELD (task, text_parts)->len > 0) {
+ struct rspamd_mime_text_part *tp = g_ptr_array_index (
+ MESSAGE_FIELD (task, text_parts), 0);
if (tp->language) {
language = tp->language;