diff options
Diffstat (limited to 'train_ham.py')
-rw-r--r-- | train_ham.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/train_ham.py b/train_ham.py new file mode 100644 index 0000000..4989c7c --- /dev/null +++ b/train_ham.py | |||
@@ -0,0 +1,29 @@ | |||
1 | """ | ||
2 | A rudimentary way to train additional ham into our pickle file. | ||
3 | |||
4 | Example usage: | ||
5 | |||
6 | $ python train_spam.py /path/to/spam.pkl | ||
7 | blah blah blah^D | ||
8 | """ | ||
9 | import sys | ||
10 | from ConfigParser import SafeConfigParser as ConfigParser, \ | ||
11 | NoSectionError, NoOptionError | ||
12 | from spambayes.storage import PickledClassifier | ||
13 | |||
14 | |||
15 | config = ConfigParser() | ||
16 | with open("/etc/email_gateway.cfg") as fp: | ||
17 | config.readfp(fp) | ||
18 | |||
19 | |||
20 | def main(): | ||
21 | pickle_filename = sys.argv[-1] | ||
22 | bayes = PickledClassifier(pickle_filename) | ||
23 | message = sys.stdin.readlines() | ||
24 | bayes.learn(message, False) | ||
25 | bayes.store() | ||
26 | |||
27 | |||
28 | if __name__ == '__main__': | ||
29 | main() | ||