You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

statistic.conf 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Please don't modify this file as your changes might be overwritten with
  2. # the next update.
  3. #
  4. # You can modify '$LOCAL_CONFDIR/rspamd.conf.local.override' to redefine
  5. # parameters defined on the top level
  6. #
  7. # You can modify '$LOCAL_CONFDIR/rspamd.conf.local' to add
  8. # parameters defined on the top level
  9. #
  10. # For specific modules or configuration you can also modify
  11. # '$LOCAL_CONFDIR/local.d/file.conf' - to add your options or rewrite defaults
  12. # '$LOCAL_CONFDIR/override.d/file.conf' - to override the defaults
  13. #
  14. # See https://rspamd.com/doc/tutorials/writing_rules.html for details
  15. # Rspamd statistic setup
  16. # Pre-built files could be loaded from:
  17. # http://rspamd.com/rspamd_statistics/bayes.spam.sqlite
  18. # - and -
  19. # http://rspamd.com/rspamd_statistics/bayes.ham.sqlite
  20. classifier "bayes" {
  21. tokenizer {
  22. name = "osb";
  23. }
  24. cache {
  25. }
  26. new_schema = true; # Always use new schema
  27. store_tokens = false; # Redefine if storing of tokens is desired
  28. signatures = false; # Store learn signatures
  29. #per_user = true; # Enable per user classifier
  30. min_tokens = 11;
  31. backend = "redis";
  32. min_learns = 200;
  33. statfile {
  34. symbol = "BAYES_HAM";
  35. spam = false;
  36. }
  37. statfile {
  38. symbol = "BAYES_SPAM";
  39. spam = true;
  40. }
  41. learn_condition =<<EOD
  42. return function(task, is_spam, is_unlearn)
  43. local learn_type = task:get_request_header('Learn-Type')
  44. if not (learn_type and tostring(learn_type) == 'bulk') then
  45. local prob = task:get_mempool():get_variable('bayes_prob', 'double')
  46. if prob then
  47. local in_class = false
  48. local cl
  49. if is_spam then
  50. cl = 'spam'
  51. in_class = prob >= 0.95
  52. else
  53. cl = 'ham'
  54. in_class = prob <= 0.05
  55. end
  56. if in_class then
  57. return false,string.format('already in class %s; probability %.2f%%',
  58. cl, math.abs((prob - 0.5) * 200.0))
  59. end
  60. end
  61. end
  62. return true
  63. end
  64. EOD
  65. .include(try=true; priority=1) "$LOCAL_CONFDIR/local.d/classifier-bayes.conf"
  66. .include(try=true; priority=10) "$LOCAL_CONFDIR/override.d/classifier-bayes.conf"
  67. }
  68. .include(try=true; priority=1) "$LOCAL_CONFDIR/local.d/statistic.conf"
  69. .include(try=true; priority=10) "$LOCAL_CONFDIR/override.d/statistic.conf"