# Statistics setup
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
# You can modify 'local.d/statistic.conf' to add and merge
# parameters defined inside this section
#
# You can modify 'override.d/statistic.conf' to strictly override all
# parameters defined inside this section
#
# If you just need to change the default bayes classifier, you can also use
# 'local.d/classifier-bayes.conf' or 'override.d/classifier-bayes.conf'. But
# never ever use both `statistic.conf` and `classifier-bayes.conf` locals files
# together!
#
# See https://rspamd.com/doc/faq.html#what-are-the-locald-and-overrided-directories
# for details
#
# Module documentation: https://rspamd.com/doc/configuration/statistic.html

classifier "bayes" {
  # name = "custom";  # 'name' parameter must be set if multiple classifiers are defined
  tokenizer {
    name = "osb";
  }
  cache {
  }
  new_schema = true; # Always use new schema
  store_tokens = false; # Redefine if storing of tokens is desired
  signatures = false; # Store learn signatures
  #per_user = true; # Enable per user classifier
  min_tokens = 11;
  backend = "redis";
  min_learns = 200;

  statfile {
    symbol = "BAYES_HAM";
    spam = false;
  }
  statfile {
    symbol = "BAYES_SPAM";
    spam = true;
  }
  # Reuse the shared Bayes helper so all classifiers get the same guards
  learn_condition = "return require('lua_bayes_learn').can_learn";

  # Autolearn sample
  # autolearn {
  #  spam_threshold = 6.0; # Learn spam when score >= threshold
  #  junk_threshold = 4.0; # Learn spam from junk when score >= threshold
  #  ham_threshold = -0.5; # Learn ham when score <= threshold
  #  check_balance = true; # Keep spam/ham learns roughly balanced
  #  min_balance = 0.9; # Allow at most 1/min_balance ratio difference
  #  options { # Optional fine grained overrides merged into defaults
  #    probability_check { # Tune the probability guard used by can_learn
  #      spam_min = 0.9; # Consider messages with P>=0.9 already spam
  #      ham_max = 0.1; # Consider messages with P<=0.1 already ham
  #    }
  #    logging { enabled = true; } # Disable if you need quieter logs
  #  }
  #}

  .include(try=true; priority=1) "$LOCAL_CONFDIR/local.d/classifier-bayes.conf"
  .include(try=true; priority=10) "$LOCAL_CONFDIR/override.d/classifier-bayes.conf"
}

.include(try=true; priority=1) "$LOCAL_CONFDIR/local.d/statistic.conf"
.include(try=true; priority=10) "$LOCAL_CONFDIR/override.d/statistic.conf"
