summaryrefslogtreecommitdiff
path: root/ymir.nix
diff options
context:
space:
mode:
Diffstat (limited to 'ymir.nix')
-rw-r--r--ymir.nix55
1 files changed, 55 insertions, 0 deletions
diff --git a/ymir.nix b/ymir.nix
index 2d5be241..96a3cd30 100644
--- a/ymir.nix
+++ b/ymir.nix
@@ -1111,6 +1111,61 @@ in rec {
1111 ''; 1111 '';
1112 "dkim_signing.conf".text = "enabled = false;"; 1112 "dkim_signing.conf".text = "enabled = false;";
1113 "neural.conf".text = "enabled = false;"; 1113 "neural.conf".text = "enabled = false;";
1114 "classifier-bayes.conf".text = ''
1115 enable = true;
1116 expire = 8640000;
1117 new_schema = true;
1118 backend = "redis";
1119 autolearn = true;
1120
1121 per_user = <<EOD
1122 return function(task)
1123 local rcpt = task:get_recipients(1)
1124
1125 if rcpt then
1126 one_rcpt = rcpt[1]
1127 if one_rcpt['domain'] then
1128 return one_rcpt['domain']
1129 end
1130 end
1131
1132 return nil
1133 end
1134 EOD
1135
1136 statfile {
1137 symbol = "BAYES_HAM";
1138 spam = false;
1139 }
1140 statfile {
1141 symbol = "BAYES_SPAM";
1142 spam = true;
1143 }
1144 learn_condition =<<EOD
1145 return function(task, is_spam, is_unlearn)
1146 local prob = task:get_mempool():get_variable('bayes_prob', 'double')
1147
1148 if prob then
1149 local in_class = false
1150 local cl
1151 if is_spam then
1152 cl = 'spam'
1153 in_class = prob >= 0.95
1154 else
1155 cl = 'ham'
1156 in_class = prob <= 0.05
1157 end
1158
1159 if in_class then
1160 return false,string.format('already in class %s; probability %.2f%%',
1161 cl, math.abs((prob - 0.5) * 200.0))
1162 end
1163 end
1164
1165 return true
1166 end
1167 EOD
1168 '';
1114 }; 1169 };
1115 }; 1170 };
1116 1171