-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (25 loc) · 1.21 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
"Ver5.1-This version separates functions,connects to DB and gets reviews (GetReviews.py), analyses them (Analysis.py), and print results in main"
import os
from Analysis import Semantic_analysis
import DBfuncs
def main():
Path = os.getcwd()+'\AFINN-111.txt'
f=open(Path)
Data=DBfuncs.QuerryDB("Select distinct p_id,review_id from reviews") #Tuples of : (product_ID, Review_ID)
"Connects to DB and gets Reviews Without html tags"
for Prod in Data:
pid="%d" % Prod[0] #For each Product_ID
reviews=DBfuncs.GetReviews(pid) #Retreive all Reviews of Product_ID
Results=Semantic_analysis(reviews,f) #Analyze Reviews
for res in Results:
print "Product id: %d, attr: %s score: %6.2f review: %s" % (Prod[0],res[0],res[1],res[2])
os.system('pause')
"IMPORTENT: The AFINN-111.txt file most be in the same folder as the main.py file"
Path = os.getcwd()+'\AFINN-111.txt'
f=open(Path)
Results=Semantic_analysis(reviews,f)
print "end of program"
for rev in Results:
print rev[0], rev[1]
os.system('pause')
main()