/
main.py
42 lines (31 loc) · 1.03 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
from SQLHandler import SQLHandler
from Reddit import Reddit
from Analyzer import Analyzer
import time
def thenOrThan(words):
return "then" if "then" in words else "than"
count = 0
while True:
sql = SQLHandler()
reddit = Reddit()
analyzer = Analyzer()
count += 1
print "Beginning Iteration " + str(count)
print "Gathering Comments"
comments = reddit.getNewComments()
views = sql.getViews()
print "Processing Data"
for comment in comments:
flag = True
words = [x.lower().strip() for x in comment[0].split()]
thenorthan = thenOrThan(words)
for i in views:
if comment[1] == i[0]:
flag = False
break
if (flag):
flag = analyzer.analyze(sql, reddit, comment, words, thenorthan)
if (flag):
analyzer.processWordsForDB(sql, reddit, comment, words, thenorthan)
print "Sleeping for 1 minute"
time.sleep(60)