forked from youzan/YZSpamFilter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautorefresh.py
63 lines (48 loc) · 1.64 KB
/
autorefresh.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-
import os
import sys
import pickle
from config import configs
from classifier import Algorithm
class filter:
def __init__(self, Algorithm):
self.Algorithm = Algorithm
self.tar = 0.0
self.trr = 0.0
self.accuracy = 0.0
self.hashset = set()
if __name__ == '__main__':
"""
usage: python autorefresh.py
"""
reload(sys)
sys.setdefaultencoding('utf-8')
classify_model = configs['classify_model']
##############################
# 1.train or load model
##############################
if not os.path.exists(classify_model):
print "you should have a model first"
exit(-1)
else:
with open(classify_model, 'rb') as file:
f = filter(Algorithm)
t = pickle.load(file)
f.Algorithm.loadmodel(t)
file.close()
##############################
# 1.错误的将正常信息当做垃圾信息(误抓取)
##############################
FalseRejectstr = ['新开','店铺','买','送','欢迎','大家' ,'关顾']
f.Algorithm.discover(FalseRejectstr, True)
f.Algorithm.cover(FalseRejectstr, False)
##############################
# 1.错误的将垃圾信息当做正常信息(漏抓取)
##############################
FalseAcceptstr = ['官网','诚招','手机','电脑','打字员','日入','百百']
f.Algorithm.cover(FalseAcceptstr, True)
file = open(classify_model, 'wb')
t = f.Algorithm.getmodel()
pickle.dump(t, file)
file.close()
print 'Finish updating model'