-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
75 lines (54 loc) · 1.81 KB
/
main.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
63
64
65
66
67
68
69
70
71
72
73
74
75
import words
import utils
import sys
import em
import getngram
import google_solberg
def insert_by_sender(location, sender, agent):
"""Specify relative path or absolute path for location."""
keywords = [sender, "sent"]
filenames = utils.walkdir(location, keywords)
emails = utils.email_to_tuple(filenames)
#agent = words.EmailAgent("maintest.db")
agent.insert_email(emails)
# print emails
if __name__ == '__main__':
if len(sys.argv) < 3:
print "First argument is directory, second is the sender you want to filter by."
# python main.py emails/solberg-g/ solberg-g
elif len(sys.argv) > 3:
print "Ask Nicole for help."
agent = words.EmailAgent("maintest.db", True)
insert_by_sender(sys.argv[1], sys.argv[2], agent)
# print getngram.reqNgram("Princeton *, lol")
# print google_solberg.google_solberg["wheel,cut"]
# print google_solberg.google_solberg["wheel"]
ema = em.TestEMAlgorithm(agent.getMsg, agent.getSenders, agent.getReceiver, ())
# print google_solberg.google_solberg[u'if,you,submit']
# print google_solberg.google_solberg[u'you,said']
# print ema.getGoogleRequests()
# print google_solberg.google_solberg
# we use this line to get data, but we print it in a file. so we never need to run it any more
'''
ccc = ema.getGoogleRequests()[7000:]
tmp = getngram.reqNgram(ccc)
res = {}
for words in tmp.keys():
res[words.replace(' ', ',')] = tmp[words]
# print ccc
# print tmp
print res
'''
rt = []
rtb = []
for rec in ema.nameList:
rt.append(ema.test(rec))
rtb.append(ema.test_baseline(rec))
print ""
print "Testing finished."
print rt
print rtb
'''
ema.prediction_init()
ema.do_predict()
'''