diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2019-02-10 20:50:03 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2019-02-10 20:50:03 +0100 |
commit | 78da72c29f56641b06e57fa72d9828325775832b (patch) | |
tree | 79981baf04d2667b904f7df26915616c777d62a4 | |
parent | f10860cdf7ef93cfaa3dbd154e00bc27686a4388 (diff) | |
download | nixos-78da72c29f56641b06e57fa72d9828325775832b.tar nixos-78da72c29f56641b06e57fa72d9828325775832b.tar.gz nixos-78da72c29f56641b06e57fa72d9828325775832b.tar.bz2 nixos-78da72c29f56641b06e57fa72d9828325775832b.tar.xz nixos-78da72c29f56641b06e57fa72d9828325775832b.zip |
...
-rw-r--r-- | ymir.nix | 55 |
1 files changed, 55 insertions, 0 deletions
@@ -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 | ||