-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush_notifs.py
78 lines (46 loc) · 1.76 KB
/
push_notifs.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
76
77
import helpers2
import tag_all
import random
def get_sentiment_per_review(review_list):
interests, analysis = ['HDFC','ICICI','SBI','Canara'], []
for v in review_list:
op = tag_all.get_sentiment_and_tag(v)
sentiment, tags = op[0], op[1]
bank = ''
for item in interests:
if item in v.split() or item.lower() in v.lower().split():
bank = item
break
analysis.append([v, sentiment, tags, bank])
return analysis
def get_promotions(review_list):
analysis = get_sentiment_per_review(review_list)
promotions, notifs = [], {}
for item in analysis:
# print(item)
s, t, focus = item[1], item[2], item[3]
if len(t) != 0 and len(focus) != 0:
promotion = ''
if s == 'positive':
promotion+= '{} is now better than ever! Home Loans starting at {:.1f}%'.format(focus, random.uniform(5, 7))
promotions.append(promotion)
if focus not in notifs:
notifs[focus] = ['{} is now offering stand in coupons! Avail them at the nearest {} center'.format(focus, t[0])]
else:
notifs[focus].append('{} is offering a discount'.format(focus))
else:
promotion+='\n\n{} {} is now equipped to serve you better , taking your grievances into account. We are sorry you were dissatisfied with the service.'.format(focus, t[0])
promotions.append(promotion)
# if focus not in notifs:
# notifs[focus] = [promotion]
# else:
# notifs[focus].append(promotion)
# print(notifs)
# return promotions, notifs - use to get all
return notifs
# review_list = ['The service at the hdfc yelehanka branch is really good',
# 'The security at ICICI bank is pretty bad',
# 'The ac does not work near the hdfc bank',
# 'I loved the security near vvpuram, best for night time atm'
# ]
# get_promotions(review_list)